mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-04 02:39:32 +00:00
Include enum variants in world symbols
I opted to not include enum variant imports, only under the enum, and to not gate this behind a setting.
This commit is contained in:
parent
3816d0ae53
commit
b34e5b7fe4
2 changed files with 75 additions and 0 deletions
|
@ -125,6 +125,13 @@ impl<'a> SymbolCollector<'a> {
|
|||
}
|
||||
ModuleDefId::AdtId(AdtId::EnumId(id)) => {
|
||||
this.push_decl(id, name, false, None);
|
||||
let enum_name = this.db.enum_signature(id).name.as_str().to_smolstr();
|
||||
this.with_container_name(Some(enum_name), |this| {
|
||||
let variants = id.enum_variants(this.db);
|
||||
for (variant_id, variant_name, _) in &variants.variants {
|
||||
this.push_decl(*variant_id, variant_name, true, None);
|
||||
}
|
||||
});
|
||||
}
|
||||
ModuleDefId::AdtId(AdtId::UnionId(id)) => {
|
||||
this.push_decl(id, name, false, None);
|
||||
|
|
|
@ -10,6 +10,40 @@
|
|||
},
|
||||
},
|
||||
[
|
||||
FileSymbol {
|
||||
name: "A",
|
||||
def: Variant(
|
||||
Variant {
|
||||
id: EnumVariantId(
|
||||
7800,
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: VARIANT,
|
||||
range: 201..202,
|
||||
},
|
||||
name_ptr: AstPtr(
|
||||
SyntaxNodePtr {
|
||||
kind: NAME,
|
||||
range: 201..202,
|
||||
},
|
||||
),
|
||||
},
|
||||
container_name: Some(
|
||||
"Enum",
|
||||
),
|
||||
is_alias: false,
|
||||
is_assoc: true,
|
||||
is_import: false,
|
||||
do_not_complete: Yes,
|
||||
},
|
||||
FileSymbol {
|
||||
name: "Alias",
|
||||
def: TypeAlias(
|
||||
|
@ -42,6 +76,40 @@
|
|||
is_import: false,
|
||||
do_not_complete: Yes,
|
||||
},
|
||||
FileSymbol {
|
||||
name: "B",
|
||||
def: Variant(
|
||||
Variant {
|
||||
id: EnumVariantId(
|
||||
7801,
|
||||
),
|
||||
},
|
||||
),
|
||||
loc: DeclarationLocation {
|
||||
hir_file_id: FileId(
|
||||
EditionedFileId(
|
||||
Id(2000),
|
||||
),
|
||||
),
|
||||
ptr: SyntaxNodePtr {
|
||||
kind: VARIANT,
|
||||
range: 204..205,
|
||||
},
|
||||
name_ptr: AstPtr(
|
||||
SyntaxNodePtr {
|
||||
kind: NAME,
|
||||
range: 204..205,
|
||||
},
|
||||
),
|
||||
},
|
||||
container_name: Some(
|
||||
"Enum",
|
||||
),
|
||||
is_alias: false,
|
||||
is_assoc: true,
|
||||
is_import: false,
|
||||
do_not_complete: Yes,
|
||||
},
|
||||
FileSymbol {
|
||||
name: "CONST",
|
||||
def: Const(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue