]> git.lizzy.rs Git - rust.git/commitdiff
Basic hover for builtin-attr and tool modules
authorLukas Wirth <lukastw97@gmail.com>
Fri, 3 Dec 2021 16:10:56 +0000 (17:10 +0100)
committerLukas Wirth <lukastw97@gmail.com>
Fri, 3 Dec 2021 16:10:56 +0000 (17:10 +0100)
crates/hir/src/lib.rs
crates/ide/src/hover/render.rs

index cfa674cafa654e45683f03fbcbe206e4007ebb3a..e64a8182c9cff909dbf80fdecae1ab19191be4e0 100644 (file)
@@ -2031,6 +2031,11 @@ pub(crate) fn by_name(name: &str) -> Option<Self> {
         // FIXME: def maps registered attrs?
         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)]
@@ -2041,6 +2046,11 @@ pub(crate) fn by_name(name: &str) -> Option<Self> {
         // FIXME: def maps registered tools
         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)]
index e72ed8c2b286a7d3e50a15b9edee23b315be7671..46f5b2e35be122d337640a9cd0e4b389110cab4f 100644 (file)
@@ -369,8 +369,9 @@ pub(super) fn definition(
         }
         Definition::GenericParam(it) => label_and_docs(db, it),
         Definition::Label(it) => return Some(Markup::fenced_block(&it.name(db))),
-        Definition::BuiltinAttr(_) => return None, // FIXME
-        Definition::Tool(_) => return None,        // FIXME
+        // FIXME: We should be able to show more info about these
+        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)