diff options
Diffstat (limited to 'crates/ide/src/display')
-rw-r--r-- | crates/ide/src/display/navigation_target.rs | 4 | ||||
-rw-r--r-- | crates/ide/src/display/short_label.rs | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index 8d08e4763..16fa828ad 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs | |||
@@ -130,8 +130,7 @@ impl NavigationTarget { | |||
130 | node: InFile<&dyn ast::NameOwner>, | 130 | node: InFile<&dyn ast::NameOwner>, |
131 | kind: SymbolKind, | 131 | kind: SymbolKind, |
132 | ) -> NavigationTarget { | 132 | ) -> NavigationTarget { |
133 | let name = | 133 | let name = node.value.name().map(|it| it.text().into()).unwrap_or_else(|| "_".into()); |
134 | node.value.name().map(|it| it.text().clone()).unwrap_or_else(|| SmolStr::new("_")); | ||
135 | let focus_range = | 134 | let focus_range = |
136 | node.value.name().map(|it| node.with_value(it.syntax()).original_file_range(db).range); | 135 | node.value.name().map(|it| node.with_value(it.syntax()).original_file_range(db).range); |
137 | let frange = node.map(|it| it.syntax()).original_file_range(db); | 136 | let frange = node.map(|it| it.syntax()).original_file_range(db); |
@@ -272,6 +271,7 @@ impl ToNav for hir::Module { | |||
272 | ModuleSource::Module(node) => { | 271 | ModuleSource::Module(node) => { |
273 | (node.syntax(), node.name().map(|it| it.syntax().text_range())) | 272 | (node.syntax(), node.name().map(|it| it.syntax().text_range())) |
274 | } | 273 | } |
274 | ModuleSource::BlockExpr(node) => (node.syntax(), None), | ||
275 | }; | 275 | }; |
276 | let frange = src.with_value(syntax).original_file_range(db); | 276 | let frange = src.with_value(syntax).original_file_range(db); |
277 | NavigationTarget::from_syntax(frange.file_id, name, focus, frange.range, SymbolKind::Module) | 277 | NavigationTarget::from_syntax(frange.file_id, name, focus, frange.range, SymbolKind::Module) |
diff --git a/crates/ide/src/display/short_label.rs b/crates/ide/src/display/short_label.rs index 990f740b8..7ac050473 100644 --- a/crates/ide/src/display/short_label.rs +++ b/crates/ide/src/display/short_label.rs | |||
@@ -53,6 +53,12 @@ impl ShortLabel for ast::SourceFile { | |||
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | impl ShortLabel for ast::BlockExpr { | ||
57 | fn short_label(&self) -> Option<String> { | ||
58 | None | ||
59 | } | ||
60 | } | ||
61 | |||
56 | impl ShortLabel for ast::TypeAlias { | 62 | impl ShortLabel for ast::TypeAlias { |
57 | fn short_label(&self) -> Option<String> { | 63 | fn short_label(&self) -> Option<String> { |
58 | short_label_from_node(self, "type ") | 64 | short_label_from_node(self, "type ") |
@@ -90,7 +96,7 @@ impl ShortLabel for ast::Variant { | |||
90 | impl ShortLabel for ast::ConstParam { | 96 | impl ShortLabel for ast::ConstParam { |
91 | fn short_label(&self) -> Option<String> { | 97 | fn short_label(&self) -> Option<String> { |
92 | let mut buf = "const ".to_owned(); | 98 | let mut buf = "const ".to_owned(); |
93 | buf.push_str(self.name()?.text().as_str()); | 99 | buf.push_str(self.name()?.text()); |
94 | if let Some(type_ref) = self.ty() { | 100 | if let Some(type_ref) = self.ty() { |
95 | format_to!(buf, ": {}", type_ref.syntax()); | 101 | format_to!(buf, ": {}", type_ref.syntax()); |
96 | } | 102 | } |
@@ -117,6 +123,6 @@ where | |||
117 | { | 123 | { |
118 | let mut buf = node.visibility().map(|v| format!("{} ", v.syntax())).unwrap_or_default(); | 124 | let mut buf = node.visibility().map(|v| format!("{} ", v.syntax())).unwrap_or_default(); |
119 | buf.push_str(label); | 125 | buf.push_str(label); |
120 | buf.push_str(node.name()?.text().as_str()); | 126 | buf.push_str(node.name()?.text()); |
121 | Some(buf) | 127 | Some(buf) |
122 | } | 128 | } |