diff options
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r-- | crates/ide_db/src/apply_change.rs | 1 | ||||
-rw-r--r-- | crates/ide_db/src/defs.rs | 2 | ||||
-rw-r--r-- | crates/ide_db/src/helpers/insert_use.rs | 2 | ||||
-rw-r--r-- | crates/ide_db/src/search.rs | 10 | ||||
-rw-r--r-- | crates/ide_db/src/symbol_index.rs | 6 |
5 files changed, 16 insertions, 5 deletions
diff --git a/crates/ide_db/src/apply_change.rs b/crates/ide_db/src/apply_change.rs index c770a236b..9d9b6de7a 100644 --- a/crates/ide_db/src/apply_change.rs +++ b/crates/ide_db/src/apply_change.rs | |||
@@ -149,6 +149,7 @@ impl RootDatabase { | |||
149 | 149 | ||
150 | // DefDatabase | 150 | // DefDatabase |
151 | hir::db::ItemTreeQuery | 151 | hir::db::ItemTreeQuery |
152 | hir::db::BlockDefMapQuery | ||
152 | hir::db::CrateDefMapQueryQuery | 153 | hir::db::CrateDefMapQueryQuery |
153 | hir::db::StructDataQuery | 154 | hir::db::StructDataQuery |
154 | hir::db::UnionDataQuery | 155 | hir::db::UnionDataQuery |
diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs index d9875ffef..a8091dbee 100644 --- a/crates/ide_db/src/defs.rs +++ b/crates/ide_db/src/defs.rs | |||
@@ -343,7 +343,7 @@ impl NameRefClass { | |||
343 | hir::AssocItem::TypeAlias(it) => Some(*it), | 343 | hir::AssocItem::TypeAlias(it) => Some(*it), |
344 | _ => None, | 344 | _ => None, |
345 | }) | 345 | }) |
346 | .find(|alias| alias.name(sema.db).to_string() == **name_ref.text()) | 346 | .find(|alias| &alias.name(sema.db).to_string() == name_ref.text()) |
347 | { | 347 | { |
348 | return Some(NameRefClass::Definition(Definition::ModuleDef( | 348 | return Some(NameRefClass::Definition(Definition::ModuleDef( |
349 | ModuleDef::TypeAlias(ty), | 349 | ModuleDef::TypeAlias(ty), |
diff --git a/crates/ide_db/src/helpers/insert_use.rs b/crates/ide_db/src/helpers/insert_use.rs index 877d4f1c7..fd4035198 100644 --- a/crates/ide_db/src/helpers/insert_use.rs +++ b/crates/ide_db/src/helpers/insert_use.rs | |||
@@ -507,7 +507,7 @@ impl ImportGroup { | |||
507 | PathSegmentKind::SelfKw => ImportGroup::ThisModule, | 507 | PathSegmentKind::SelfKw => ImportGroup::ThisModule, |
508 | PathSegmentKind::SuperKw => ImportGroup::SuperModule, | 508 | PathSegmentKind::SuperKw => ImportGroup::SuperModule, |
509 | PathSegmentKind::CrateKw => ImportGroup::ThisCrate, | 509 | PathSegmentKind::CrateKw => ImportGroup::ThisCrate, |
510 | PathSegmentKind::Name(name) => match name.text().as_str() { | 510 | PathSegmentKind::Name(name) => match name.text() { |
511 | "std" => ImportGroup::Std, | 511 | "std" => ImportGroup::Std, |
512 | "core" => ImportGroup::Std, | 512 | "core" => ImportGroup::Std, |
513 | _ => ImportGroup::ExternCrate, | 513 | _ => ImportGroup::ExternCrate, |
diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs index 0ecb13a64..b9ba0aed5 100644 --- a/crates/ide_db/src/search.rs +++ b/crates/ide_db/src/search.rs | |||
@@ -228,6 +228,15 @@ impl Definition { | |||
228 | // so do nothing. | 228 | // so do nothing. |
229 | } | 229 | } |
230 | } | 230 | } |
231 | ModuleSource::BlockExpr(b) => { | ||
232 | if is_first { | ||
233 | let range = Some(b.syntax().text_range()); | ||
234 | res.insert(file_id, range); | ||
235 | } else { | ||
236 | // We have already added the enclosing file to the search scope, | ||
237 | // so do nothing. | ||
238 | } | ||
239 | } | ||
231 | ModuleSource::SourceFile(_) => { | 240 | ModuleSource::SourceFile(_) => { |
232 | res.insert(file_id, None); | 241 | res.insert(file_id, None); |
233 | } | 242 | } |
@@ -257,6 +266,7 @@ impl Definition { | |||
257 | let mut res = FxHashMap::default(); | 266 | let mut res = FxHashMap::default(); |
258 | let range = match module_src.value { | 267 | let range = match module_src.value { |
259 | ModuleSource::Module(m) => Some(m.syntax().text_range()), | 268 | ModuleSource::Module(m) => Some(m.syntax().text_range()), |
269 | ModuleSource::BlockExpr(b) => Some(b.syntax().text_range()), | ||
260 | ModuleSource::SourceFile(_) => None, | 270 | ModuleSource::SourceFile(_) => None, |
261 | }; | 271 | }; |
262 | res.insert(file_id, range); | 272 | res.insert(file_id, range); |
diff --git a/crates/ide_db/src/symbol_index.rs b/crates/ide_db/src/symbol_index.rs index 0aa6a0765..e954bd72e 100644 --- a/crates/ide_db/src/symbol_index.rs +++ b/crates/ide_db/src/symbol_index.rs | |||
@@ -191,7 +191,7 @@ pub fn crate_symbols(db: &RootDatabase, krate: CrateId, query: Query) -> Vec<Fil | |||
191 | 191 | ||
192 | let def_map = db.crate_def_map(krate); | 192 | let def_map = db.crate_def_map(krate); |
193 | let mut files = Vec::new(); | 193 | let mut files = Vec::new(); |
194 | let mut modules = vec![def_map.root]; | 194 | let mut modules = vec![def_map.root()]; |
195 | while let Some(module) = modules.pop() { | 195 | while let Some(module) = modules.pop() { |
196 | let data = &def_map[module]; | 196 | let data = &def_map[module]; |
197 | files.extend(data.origin.file_id()); | 197 | files.extend(data.origin.file_id()); |
@@ -209,7 +209,7 @@ pub fn crate_symbols(db: &RootDatabase, krate: CrateId, query: Query) -> Vec<Fil | |||
209 | query.search(&buf) | 209 | query.search(&buf) |
210 | } | 210 | } |
211 | 211 | ||
212 | pub fn index_resolve(db: &RootDatabase, name: &SmolStr) -> Vec<FileSymbol> { | 212 | pub fn index_resolve(db: &RootDatabase, name: &str) -> Vec<FileSymbol> { |
213 | let mut query = Query::new(name.to_string()); | 213 | let mut query = Query::new(name.to_string()); |
214 | query.exact(); | 214 | query.exact(); |
215 | query.limit(4); | 215 | query.limit(4); |
@@ -409,7 +409,7 @@ fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> { | |||
409 | fn decl<N: NameOwner>(node: N) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> { | 409 | fn decl<N: NameOwner>(node: N) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> { |
410 | let name = node.name()?; | 410 | let name = node.name()?; |
411 | let name_range = name.syntax().text_range(); | 411 | let name_range = name.syntax().text_range(); |
412 | let name = name.text().clone(); | 412 | let name = name.text().into(); |
413 | let ptr = SyntaxNodePtr::new(node.syntax()); | 413 | let ptr = SyntaxNodePtr::new(node.syntax()); |
414 | 414 | ||
415 | Some((name, ptr, name_range)) | 415 | Some((name, ptr, name_range)) |