aboutsummaryrefslogtreecommitdiff
path: root/crates/ide
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-01-20 19:05:48 +0000
committerJonas Schievink <[email protected]>2021-01-20 19:05:48 +0000
commit82146737acc74b2483f39f1dd0ae4dfffcfda824 (patch)
tree2f3c97e5f45a8579cc860dc9a57123dbb5302b8b /crates/ide
parent7d5ed18c42c4ee80e776d04254d69750b70e14ba (diff)
Treat BlockExpr as a potential module origin
Diffstat (limited to 'crates/ide')
-rw-r--r--crates/ide/src/display/navigation_target.rs1
-rw-r--r--crates/ide/src/display/short_label.rs6
-rw-r--r--crates/ide/src/hover.rs1
-rw-r--r--crates/ide/src/runnables.rs1
4 files changed, 9 insertions, 0 deletions
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs
index 671aa1373..9c568c90c 100644
--- a/crates/ide/src/display/navigation_target.rs
+++ b/crates/ide/src/display/navigation_target.rs
@@ -294,6 +294,7 @@ impl ToNav for hir::Module {
294 ModuleSource::Module(node) => { 294 ModuleSource::Module(node) => {
295 (node.syntax(), node.name().map(|it| it.syntax().text_range())) 295 (node.syntax(), node.name().map(|it| it.syntax().text_range()))
296 } 296 }
297 ModuleSource::BlockExpr(node) => (node.syntax(), None),
297 }; 298 };
298 let frange = src.with_value(syntax).original_file_range(db); 299 let frange = src.with_value(syntax).original_file_range(db);
299 NavigationTarget::from_syntax(frange.file_id, name, focus, frange.range, SymbolKind::Module) 300 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 b8e4cc181..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
56impl ShortLabel for ast::BlockExpr {
57 fn short_label(&self) -> Option<String> {
58 None
59 }
60}
61
56impl ShortLabel for ast::TypeAlias { 62impl 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 ")
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index 44ebdbd35..ec1631486 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -321,6 +321,7 @@ fn hover_for_definition(db: &RootDatabase, def: Definition) -> Option<Markup> {
321 match it.definition_source(db).value { 321 match it.definition_source(db).value {
322 ModuleSource::Module(it) => it.short_label(), 322 ModuleSource::Module(it) => it.short_label(),
323 ModuleSource::SourceFile(it) => it.short_label(), 323 ModuleSource::SourceFile(it) => it.short_label(),
324 ModuleSource::BlockExpr(it) => it.short_label(),
324 }, 325 },
325 mod_path, 326 mod_path,
326 ), 327 ),
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs
index 47a85dc45..975abf47f 100644
--- a/crates/ide/src/runnables.rs
+++ b/crates/ide/src/runnables.rs
@@ -131,6 +131,7 @@ fn runnables_mod(sema: &Semantics<RootDatabase>, acc: &mut Vec<Runnable>, module
131 match submodule.definition_source(sema.db).value { 131 match submodule.definition_source(sema.db).value {
132 hir::ModuleSource::Module(_) => runnables_mod(sema, acc, submodule), 132 hir::ModuleSource::Module(_) => runnables_mod(sema, acc, submodule),
133 hir::ModuleSource::SourceFile(_) => mark::hit!(dont_recurse_in_outline_submodules), 133 hir::ModuleSource::SourceFile(_) => mark::hit!(dont_recurse_in_outline_submodules),
134 hir::ModuleSource::BlockExpr(_) => {} // inner items aren't runnable
134 } 135 }
135 } 136 }
136 } 137 }