From 9763d9e8c4ca01a4df0d70877020ec7351403b75 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 15 Mar 2021 09:32:06 +0100 Subject: Enable searching for builtin types --- crates/ide_db/src/search.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'crates/ide_db/src/search.rs') diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs index ddcfbd3f3..1615d407e 100644 --- a/crates/ide_db/src/search.rs +++ b/crates/ide_db/src/search.rs @@ -6,7 +6,7 @@ use std::{convert::TryInto, mem}; -use base_db::{FileId, FileRange, SourceDatabaseExt}; +use base_db::{FileId, FileRange, SourceDatabase, SourceDatabaseExt}; use hir::{DefWithBody, HasSource, Module, ModuleSource, Semantics, Visibility}; use once_cell::unsync::Lazy; use rustc_hash::FxHashMap; @@ -134,6 +134,20 @@ impl IntoIterator for SearchScope { impl Definition { fn search_scope(&self, db: &RootDatabase) -> SearchScope { let _p = profile::span("search_scope"); + + if let Definition::ModuleDef(hir::ModuleDef::BuiltinType(_)) = self { + let mut res = FxHashMap::default(); + + let graph = db.crate_graph(); + for krate in graph.iter() { + let root_file = graph[krate].root_file_id; + let source_root_id = db.file_source_root(root_file); + let source_root = db.source_root(source_root_id); + res.extend(source_root.iter().map(|id| (id, None))); + } + return SearchScope::new(res); + } + let module = match self.module(db) { Some(it) => it, None => return SearchScope::empty(), -- cgit v1.2.3