From 82146737acc74b2483f39f1dd0ae4dfffcfda824 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 20 Jan 2021 20:05:48 +0100 Subject: Treat BlockExpr as a potential module origin --- crates/ide/src/display/navigation_target.rs | 1 + crates/ide/src/display/short_label.rs | 6 ++++++ crates/ide/src/hover.rs | 1 + crates/ide/src/runnables.rs | 1 + 4 files changed, 9 insertions(+) (limited to 'crates/ide') 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 { ModuleSource::Module(node) => { (node.syntax(), node.name().map(|it| it.syntax().text_range())) } + ModuleSource::BlockExpr(node) => (node.syntax(), None), }; let frange = src.with_value(syntax).original_file_range(db); 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 { } } +impl ShortLabel for ast::BlockExpr { + fn short_label(&self) -> Option { + None + } +} + impl ShortLabel for ast::TypeAlias { fn short_label(&self) -> Option { 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 { match it.definition_source(db).value { ModuleSource::Module(it) => it.short_label(), ModuleSource::SourceFile(it) => it.short_label(), + ModuleSource::BlockExpr(it) => it.short_label(), }, mod_path, ), 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, acc: &mut Vec, module match submodule.definition_source(sema.db).value { hir::ModuleSource::Module(_) => runnables_mod(sema, acc, submodule), hir::ModuleSource::SourceFile(_) => mark::hit!(dont_recurse_in_outline_submodules), + hir::ModuleSource::BlockExpr(_) => {} // inner items aren't runnable } } } -- cgit v1.2.3