diff options
Diffstat (limited to 'crates/ide_db/src/symbol_index.rs')
-rw-r--r-- | crates/ide_db/src/symbol_index.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/crates/ide_db/src/symbol_index.rs b/crates/ide_db/src/symbol_index.rs index 0aa6a0765..9ed9568ce 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); |
@@ -356,15 +356,16 @@ pub struct FileSymbol { | |||
356 | 356 | ||
357 | #[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] | 357 | #[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)] |
358 | pub enum FileSymbolKind { | 358 | pub enum FileSymbolKind { |
359 | Const, | ||
360 | Enum, | ||
359 | Function, | 361 | Function, |
362 | Macro, | ||
363 | Module, | ||
364 | Static, | ||
360 | Struct, | 365 | Struct, |
361 | Enum, | ||
362 | Trait, | 366 | Trait, |
363 | Module, | ||
364 | TypeAlias, | 367 | TypeAlias, |
365 | Const, | 368 | Union, |
366 | Static, | ||
367 | Macro, | ||
368 | } | 369 | } |
369 | 370 | ||
370 | impl FileSymbolKind { | 371 | impl FileSymbolKind { |
@@ -375,6 +376,7 @@ impl FileSymbolKind { | |||
375 | | FileSymbolKind::Enum | 376 | | FileSymbolKind::Enum |
376 | | FileSymbolKind::Trait | 377 | | FileSymbolKind::Trait |
377 | | FileSymbolKind::TypeAlias | 378 | | FileSymbolKind::TypeAlias |
379 | | FileSymbolKind::Union | ||
378 | ) | 380 | ) |
379 | } | 381 | } |
380 | } | 382 | } |
@@ -409,7 +411,7 @@ fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> { | |||
409 | fn decl<N: NameOwner>(node: N) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> { | 411 | fn decl<N: NameOwner>(node: N) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> { |
410 | let name = node.name()?; | 412 | let name = node.name()?; |
411 | let name_range = name.syntax().text_range(); | 413 | let name_range = name.syntax().text_range(); |
412 | let name = name.text().clone(); | 414 | let name = name.text().into(); |
413 | let ptr = SyntaxNodePtr::new(node.syntax()); | 415 | let ptr = SyntaxNodePtr::new(node.syntax()); |
414 | 416 | ||
415 | Some((name, ptr, name_range)) | 417 | Some((name, ptr, name_range)) |
@@ -425,6 +427,7 @@ fn to_symbol(node: &SyntaxNode) -> Option<(SmolStr, SyntaxNodePtr, TextRange)> { | |||
425 | ast::Const(it) => decl(it), | 427 | ast::Const(it) => decl(it), |
426 | ast::Static(it) => decl(it), | 428 | ast::Static(it) => decl(it), |
427 | ast::MacroRules(it) => decl(it), | 429 | ast::MacroRules(it) => decl(it), |
430 | ast::Union(it) => decl(it), | ||
428 | _ => None, | 431 | _ => None, |
429 | } | 432 | } |
430 | } | 433 | } |
@@ -443,6 +446,7 @@ fn to_file_symbol(node: &SyntaxNode, file_id: FileId) -> Option<FileSymbol> { | |||
443 | CONST => FileSymbolKind::Const, | 446 | CONST => FileSymbolKind::Const, |
444 | STATIC => FileSymbolKind::Static, | 447 | STATIC => FileSymbolKind::Static, |
445 | MACRO_RULES => FileSymbolKind::Macro, | 448 | MACRO_RULES => FileSymbolKind::Macro, |
449 | UNION => FileSymbolKind::Union, | ||
446 | kind => unreachable!("{:?}", kind), | 450 | kind => unreachable!("{:?}", kind), |
447 | }, | 451 | }, |
448 | range: node.text_range(), | 452 | range: node.text_range(), |