diff --git a/.gitignore b/.gitignore index bf22c2afde..f7723af004 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ **/*.rs.bk Cargo.lock .vscode/* +*.log diff --git a/crates/libeditor/src/symbols.rs b/crates/libeditor/src/symbols.rs index 3faf96868f..5cd781c801 100644 --- a/crates/libeditor/src/symbols.rs +++ b/crates/libeditor/src/symbols.rs @@ -63,5 +63,8 @@ fn to_symbol(node: SyntaxNodeRef) -> Option { .visit(decl::>) .visit(decl::>) .visit(decl::>) + .visit(decl::>) + .visit(decl::>) + .visit(decl::>) .accept(node)? } diff --git a/crates/libeditor/tests/test.rs b/crates/libeditor/tests/test.rs index ba7181ab88..dedca49a4f 100644 --- a/crates/libeditor/tests/test.rs +++ b/crates/libeditor/tests/test.rs @@ -70,6 +70,9 @@ mod m { } enum E { X, Y(i32) } +type T = (); +static S: i32 = 92; +const C: i32 = 92; "#); let symbols = file_symbols(&file); dbg_eq( @@ -77,7 +80,10 @@ enum E { X, Y(i32) } r#"[FileSymbol { parent: None, name: "Foo", name_range: [8; 11), node_range: [1; 26), kind: STRUCT }, FileSymbol { parent: None, name: "m", name_range: [32; 33), node_range: [28; 53), kind: MODULE }, FileSymbol { parent: Some(1), name: "bar", name_range: [43; 46), node_range: [40; 51), kind: FUNCTION }, - FileSymbol { parent: None, name: "E", name_range: [60; 61), node_range: [55; 75), kind: ENUM }]"#, + FileSymbol { parent: None, name: "E", name_range: [60; 61), node_range: [55; 75), kind: ENUM }, + FileSymbol { parent: None, name: "T", name_range: [81; 82), node_range: [76; 88), kind: TYPE_ITEM }, + FileSymbol { parent: None, name: "S", name_range: [96; 97), node_range: [89; 108), kind: STATIC_ITEM }, + FileSymbol { parent: None, name: "C", name_range: [115; 116), node_range: [109; 127), kind: CONST_ITEM }]"#, ) } diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index a4b1169414..31f5ecc442 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs @@ -180,3 +180,22 @@ impl AstNode for Trait { impl ast::NameOwner for Trait {} impl Trait {} +// TypeItem +#[derive(Debug, Clone, Copy)] +pub struct TypeItem> { + syntax: SyntaxNode, +} + +impl AstNode for TypeItem { + fn cast(syntax: SyntaxNode) -> Option { + match syntax.kind() { + TYPE_ITEM => Some(TypeItem { syntax }), + _ => None, + } + } + fn syntax(&self) -> &SyntaxNode { &self.syntax } +} + +impl ast::NameOwner for TypeItem {} +impl TypeItem {} + diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron index 3fe8fdf0bf..d4e8c53d3f 100644 --- a/crates/libsyntax2/src/grammar.ron +++ b/crates/libsyntax2/src/grammar.ron @@ -219,27 +219,14 @@ Grammar( ["functions", "Function"] ] ), - "Function": ( - traits: ["NameOwner"] - ), - "Struct": ( - traits: ["NameOwner"] - ), - "Enum": ( - traits: ["NameOwner"] - ), - "Trait": ( - traits: ["NameOwner"] - ), - "Module": ( - traits: ["NameOwner"] - ), - "ConstItem": ( - traits: ["NameOwner"] - ), - "StaticItem": ( - traits: ["NameOwner"] - ), + "Function": ( traits: ["NameOwner"] ), + "Struct": ( traits: ["NameOwner"] ), + "Enum": ( traits: ["NameOwner"] ), + "Trait": ( traits: ["NameOwner"] ), + "Module": ( traits: ["NameOwner"] ), + "ConstItem": ( traits: ["NameOwner"] ), + "StaticItem": ( traits: ["NameOwner"] ), + "TypeItem": ( traits: ["NameOwner"] ), "Name": (), }, ) diff --git a/crates/server/src/handlers.rs b/crates/server/src/handlers.rs index 51e940ef7c..f6f960d224 100644 --- a/crates/server/src/handlers.rs +++ b/crates/server/src/handlers.rs @@ -74,6 +74,9 @@ fn to_symbol_kind(kind: SyntaxKind) -> SymbolKind { SyntaxKind::ENUM => SymbolKind::Enum, SyntaxKind::TRAIT => SymbolKind::Interface, SyntaxKind::MODULE => SymbolKind::Module, + SyntaxKind::TYPE_ITEM => SymbolKind::TypeParameter, + SyntaxKind::STATIC_ITEM => SymbolKind::Constant, + SyntaxKind::CONST_ITEM => SymbolKind::Constant, _ => SymbolKind::Variable, } } diff --git a/crates/tools/src/main.rs b/crates/tools/src/main.rs index b56be141ab..289ad6e3ce 100644 --- a/crates/tools/src/main.rs +++ b/crates/tools/src/main.rs @@ -188,6 +188,7 @@ fn existing_tests(dir: &Path) -> Result> { } fn install_code_extension() -> Result<()> { + execute!(r"cargo install --path crates/server --force")?; execute!( r" cd code