Basic hover for builtin-attr and tool modules

This commit is contained in:
Lukas Wirth 2021-12-03 17:10:56 +01:00
parent db559e5049
commit 70b8331fd5
2 changed files with 13 additions and 2 deletions

View File

@ -2031,6 +2031,11 @@ impl BuiltinAttr {
// FIXME: def maps registered attrs? // FIXME: def maps registered attrs?
hir_def::builtin_attr::find_builtin_attr_idx(name).map(Self) hir_def::builtin_attr::find_builtin_attr_idx(name).map(Self)
} }
pub fn name(&self, _: &dyn HirDatabase) -> &str {
// FIXME: Return a `Name` here
hir_def::builtin_attr::INERT_ATTRIBUTES[self.0].name
}
} }
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
@ -2041,6 +2046,11 @@ impl Tool {
// FIXME: def maps registered tools // FIXME: def maps registered tools
hir_def::builtin_attr::TOOL_MODULES.iter().position(|&tool| tool == name).map(Self) hir_def::builtin_attr::TOOL_MODULES.iter().position(|&tool| tool == name).map(Self)
} }
pub fn name(&self, _: &dyn HirDatabase) -> &str {
// FIXME: Return a `Name` here
hir_def::builtin_attr::TOOL_MODULES[self.0]
}
} }
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]

View File

@ -369,8 +369,9 @@ pub(super) fn definition(
} }
Definition::GenericParam(it) => label_and_docs(db, it), Definition::GenericParam(it) => label_and_docs(db, it),
Definition::Label(it) => return Some(Markup::fenced_block(&it.name(db))), Definition::Label(it) => return Some(Markup::fenced_block(&it.name(db))),
Definition::BuiltinAttr(_) => return None, // FIXME // FIXME: We should be able to show more info about these
Definition::Tool(_) => return None, // FIXME Definition::BuiltinAttr(it) => return Some(Markup::fenced_block(&it.name(db))),
Definition::Tool(it) => return Some(Markup::fenced_block(&it.name(db))),
}; };
markup(docs.filter(|_| config.documentation.is_some()).map(Into::into), label, mod_path) markup(docs.filter(|_| config.documentation.is_some()).map(Into::into), label, mod_path)