diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | crates/libeditor/src/symbols.rs | 3 | ||||
-rw-r--r-- | crates/libeditor/tests/test.rs | 8 | ||||
-rw-r--r-- | crates/libsyntax2/src/ast/generated.rs | 19 | ||||
-rw-r--r-- | crates/libsyntax2/src/grammar.ron | 29 | ||||
-rw-r--r-- | crates/server/src/handlers.rs | 3 | ||||
-rw-r--r-- | crates/tools/src/main.rs | 1 |
7 files changed, 42 insertions, 22 deletions
diff --git a/.gitignore b/.gitignore index bf22c2afd..f7723af00 100644 --- a/.gitignore +++ b/.gitignore | |||
@@ -2,3 +2,4 @@ | |||
2 | **/*.rs.bk | 2 | **/*.rs.bk |
3 | Cargo.lock | 3 | Cargo.lock |
4 | .vscode/* | 4 | .vscode/* |
5 | *.log | ||
diff --git a/crates/libeditor/src/symbols.rs b/crates/libeditor/src/symbols.rs index 3faf96868..5cd781c80 100644 --- a/crates/libeditor/src/symbols.rs +++ b/crates/libeditor/src/symbols.rs | |||
@@ -63,5 +63,8 @@ fn to_symbol(node: SyntaxNodeRef) -> Option<FileSymbol> { | |||
63 | .visit(decl::<ast::Enum<_>>) | 63 | .visit(decl::<ast::Enum<_>>) |
64 | .visit(decl::<ast::Trait<_>>) | 64 | .visit(decl::<ast::Trait<_>>) |
65 | .visit(decl::<ast::Module<_>>) | 65 | .visit(decl::<ast::Module<_>>) |
66 | .visit(decl::<ast::TypeItem<_>>) | ||
67 | .visit(decl::<ast::ConstItem<_>>) | ||
68 | .visit(decl::<ast::StaticItem<_>>) | ||
66 | .accept(node)? | 69 | .accept(node)? |
67 | } | 70 | } |
diff --git a/crates/libeditor/tests/test.rs b/crates/libeditor/tests/test.rs index ba7181ab8..dedca49a4 100644 --- a/crates/libeditor/tests/test.rs +++ b/crates/libeditor/tests/test.rs | |||
@@ -70,6 +70,9 @@ mod m { | |||
70 | } | 70 | } |
71 | 71 | ||
72 | enum E { X, Y(i32) } | 72 | enum E { X, Y(i32) } |
73 | type T = (); | ||
74 | static S: i32 = 92; | ||
75 | const C: i32 = 92; | ||
73 | "#); | 76 | "#); |
74 | let symbols = file_symbols(&file); | 77 | let symbols = file_symbols(&file); |
75 | dbg_eq( | 78 | dbg_eq( |
@@ -77,7 +80,10 @@ enum E { X, Y(i32) } | |||
77 | r#"[FileSymbol { parent: None, name: "Foo", name_range: [8; 11), node_range: [1; 26), kind: STRUCT }, | 80 | r#"[FileSymbol { parent: None, name: "Foo", name_range: [8; 11), node_range: [1; 26), kind: STRUCT }, |
78 | FileSymbol { parent: None, name: "m", name_range: [32; 33), node_range: [28; 53), kind: MODULE }, | 81 | FileSymbol { parent: None, name: "m", name_range: [32; 33), node_range: [28; 53), kind: MODULE }, |
79 | FileSymbol { parent: Some(1), name: "bar", name_range: [43; 46), node_range: [40; 51), kind: FUNCTION }, | 82 | FileSymbol { parent: Some(1), name: "bar", name_range: [43; 46), node_range: [40; 51), kind: FUNCTION }, |
80 | FileSymbol { parent: None, name: "E", name_range: [60; 61), node_range: [55; 75), kind: ENUM }]"#, | 83 | FileSymbol { parent: None, name: "E", name_range: [60; 61), node_range: [55; 75), kind: ENUM }, |
84 | FileSymbol { parent: None, name: "T", name_range: [81; 82), node_range: [76; 88), kind: TYPE_ITEM }, | ||
85 | FileSymbol { parent: None, name: "S", name_range: [96; 97), node_range: [89; 108), kind: STATIC_ITEM }, | ||
86 | FileSymbol { parent: None, name: "C", name_range: [115; 116), node_range: [109; 127), kind: CONST_ITEM }]"#, | ||
81 | ) | 87 | ) |
82 | } | 88 | } |
83 | 89 | ||
diff --git a/crates/libsyntax2/src/ast/generated.rs b/crates/libsyntax2/src/ast/generated.rs index a4b116941..31f5ecc44 100644 --- a/crates/libsyntax2/src/ast/generated.rs +++ b/crates/libsyntax2/src/ast/generated.rs | |||
@@ -180,3 +180,22 @@ impl<R: TreeRoot> AstNode<R> for Trait<R> { | |||
180 | impl<R: TreeRoot> ast::NameOwner<R> for Trait<R> {} | 180 | impl<R: TreeRoot> ast::NameOwner<R> for Trait<R> {} |
181 | impl<R: TreeRoot> Trait<R> {} | 181 | impl<R: TreeRoot> Trait<R> {} |
182 | 182 | ||
183 | // TypeItem | ||
184 | #[derive(Debug, Clone, Copy)] | ||
185 | pub struct TypeItem<R: TreeRoot = Arc<SyntaxRoot>> { | ||
186 | syntax: SyntaxNode<R>, | ||
187 | } | ||
188 | |||
189 | impl<R: TreeRoot> AstNode<R> for TypeItem<R> { | ||
190 | fn cast(syntax: SyntaxNode<R>) -> Option<Self> { | ||
191 | match syntax.kind() { | ||
192 | TYPE_ITEM => Some(TypeItem { syntax }), | ||
193 | _ => None, | ||
194 | } | ||
195 | } | ||
196 | fn syntax(&self) -> &SyntaxNode<R> { &self.syntax } | ||
197 | } | ||
198 | |||
199 | impl<R: TreeRoot> ast::NameOwner<R> for TypeItem<R> {} | ||
200 | impl<R: TreeRoot> TypeItem<R> {} | ||
201 | |||
diff --git a/crates/libsyntax2/src/grammar.ron b/crates/libsyntax2/src/grammar.ron index 3fe8fdf0b..d4e8c53d3 100644 --- a/crates/libsyntax2/src/grammar.ron +++ b/crates/libsyntax2/src/grammar.ron | |||
@@ -219,27 +219,14 @@ Grammar( | |||
219 | ["functions", "Function"] | 219 | ["functions", "Function"] |
220 | ] | 220 | ] |
221 | ), | 221 | ), |
222 | "Function": ( | 222 | "Function": ( traits: ["NameOwner"] ), |
223 | traits: ["NameOwner"] | 223 | "Struct": ( traits: ["NameOwner"] ), |
224 | ), | 224 | "Enum": ( traits: ["NameOwner"] ), |
225 | "Struct": ( | 225 | "Trait": ( traits: ["NameOwner"] ), |
226 | traits: ["NameOwner"] | 226 | "Module": ( traits: ["NameOwner"] ), |
227 | ), | 227 | "ConstItem": ( traits: ["NameOwner"] ), |
228 | "Enum": ( | 228 | "StaticItem": ( traits: ["NameOwner"] ), |
229 | traits: ["NameOwner"] | 229 | "TypeItem": ( traits: ["NameOwner"] ), |
230 | ), | ||
231 | "Trait": ( | ||
232 | traits: ["NameOwner"] | ||
233 | ), | ||
234 | "Module": ( | ||
235 | traits: ["NameOwner"] | ||
236 | ), | ||
237 | "ConstItem": ( | ||
238 | traits: ["NameOwner"] | ||
239 | ), | ||
240 | "StaticItem": ( | ||
241 | traits: ["NameOwner"] | ||
242 | ), | ||
243 | "Name": (), | 230 | "Name": (), |
244 | }, | 231 | }, |
245 | ) | 232 | ) |
diff --git a/crates/server/src/handlers.rs b/crates/server/src/handlers.rs index 51e940ef7..f6f960d22 100644 --- a/crates/server/src/handlers.rs +++ b/crates/server/src/handlers.rs | |||
@@ -74,6 +74,9 @@ fn to_symbol_kind(kind: SyntaxKind) -> SymbolKind { | |||
74 | SyntaxKind::ENUM => SymbolKind::Enum, | 74 | SyntaxKind::ENUM => SymbolKind::Enum, |
75 | SyntaxKind::TRAIT => SymbolKind::Interface, | 75 | SyntaxKind::TRAIT => SymbolKind::Interface, |
76 | SyntaxKind::MODULE => SymbolKind::Module, | 76 | SyntaxKind::MODULE => SymbolKind::Module, |
77 | SyntaxKind::TYPE_ITEM => SymbolKind::TypeParameter, | ||
78 | SyntaxKind::STATIC_ITEM => SymbolKind::Constant, | ||
79 | SyntaxKind::CONST_ITEM => SymbolKind::Constant, | ||
77 | _ => SymbolKind::Variable, | 80 | _ => SymbolKind::Variable, |
78 | } | 81 | } |
79 | } | 82 | } |
diff --git a/crates/tools/src/main.rs b/crates/tools/src/main.rs index b56be141a..289ad6e3c 100644 --- a/crates/tools/src/main.rs +++ b/crates/tools/src/main.rs | |||
@@ -188,6 +188,7 @@ fn existing_tests(dir: &Path) -> Result<HashMap<String, (PathBuf, Test)>> { | |||
188 | } | 188 | } |
189 | 189 | ||
190 | fn install_code_extension() -> Result<()> { | 190 | fn install_code_extension() -> Result<()> { |
191 | execute!(r"cargo install --path crates/server --force")?; | ||
191 | execute!( | 192 | execute!( |
192 | r" | 193 | r" |
193 | cd code | 194 | cd code |