diff options
Diffstat (limited to 'crates/ide_db')
-rw-r--r-- | crates/ide_db/src/lib.rs | 24 | ||||
-rw-r--r-- | crates/ide_db/src/symbol_index.rs | 14 | ||||
-rw-r--r-- | crates/ide_db/src/ty_filter.rs | 15 |
3 files changed, 48 insertions, 5 deletions
diff --git a/crates/ide_db/src/lib.rs b/crates/ide_db/src/lib.rs index 118c090d7..6eb34b06b 100644 --- a/crates/ide_db/src/lib.rs +++ b/crates/ide_db/src/lib.rs | |||
@@ -134,3 +134,27 @@ fn line_index(db: &dyn LineIndexDatabase, file_id: FileId) -> Arc<LineIndex> { | |||
134 | let text = db.file_text(file_id); | 134 | let text = db.file_text(file_id); |
135 | Arc::new(LineIndex::new(&*text)) | 135 | Arc::new(LineIndex::new(&*text)) |
136 | } | 136 | } |
137 | |||
138 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] | ||
139 | pub enum SymbolKind { | ||
140 | Const, | ||
141 | ConstParam, | ||
142 | Enum, | ||
143 | Field, | ||
144 | Function, | ||
145 | Impl, | ||
146 | Label, | ||
147 | LifetimeParam, | ||
148 | Local, | ||
149 | Macro, | ||
150 | Module, | ||
151 | SelfParam, | ||
152 | Static, | ||
153 | Struct, | ||
154 | Trait, | ||
155 | TypeAlias, | ||
156 | TypeParam, | ||
157 | Union, | ||
158 | ValueParam, | ||
159 | Variant, | ||
160 | } | ||
diff --git a/crates/ide_db/src/symbol_index.rs b/crates/ide_db/src/symbol_index.rs index e954bd72e..9ed9568ce 100644 --- a/crates/ide_db/src/symbol_index.rs +++ b/crates/ide_db/src/symbol_index.rs | |||
@@ -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 | } |
@@ -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(), |
diff --git a/crates/ide_db/src/ty_filter.rs b/crates/ide_db/src/ty_filter.rs index 63a945282..f8406851b 100644 --- a/crates/ide_db/src/ty_filter.rs +++ b/crates/ide_db/src/ty_filter.rs | |||
@@ -49,6 +49,21 @@ impl TryEnum { | |||
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | pub fn happy_pattern(self) -> ast::Pat { | ||
53 | match self { | ||
54 | TryEnum::Result => make::tuple_struct_pat( | ||
55 | make::path_unqualified(make::path_segment(make::name_ref("Ok"))), | ||
56 | iter::once(make::wildcard_pat().into()), | ||
57 | ) | ||
58 | .into(), | ||
59 | TryEnum::Option => make::tuple_struct_pat( | ||
60 | make::path_unqualified(make::path_segment(make::name_ref("Some"))), | ||
61 | iter::once(make::wildcard_pat().into()), | ||
62 | ) | ||
63 | .into(), | ||
64 | } | ||
65 | } | ||
66 | |||
52 | fn type_name(self) -> &'static str { | 67 | fn type_name(self) -> &'static str { |
53 | match self { | 68 | match self { |
54 | TryEnum::Result => "Result", | 69 | TryEnum::Result => "Result", |