Improve TS and JS symbol outline (#39797)
Added more granular symbols for ts and js in outline panel. This is a bit closer to what vscode offers. <details><summary>Screenshots of current vs new</summary> <p> New: <img width="1723" height="1221" alt="image" src="https://github.com/user-attachments/assets/796d3b59-fffa-4a66-9986-f7c75e618103" /> Current: <img width="1714" height="1347" alt="image" src="https://github.com/user-attachments/assets/f7cff463-de2a-4d86-b1a6-e19f4fd8dc6e" /> Current vscode (cursor): <img width="1710" height="1177" alt="image" src="https://github.com/user-attachments/assets/31902d52-becf-4d3f-960d-7e054e00e32d" /> </p> </details> I have never touched scheme before, and pair-programmed this with ai, so please let me know if there's any glaring issues with the implementation. I just miss the outline panel in vscode very much, and would love to see this land. Happy to help with tsx/jsx as well if this is the direction you guys were thinking of taking the outline impl. Doesn't fully close https://github.com/zed-industries/zed/issues/20964 as there is no support for chained class method callbacks or `Class.prototype.method = ...` as mentioned in https://github.com/zed-industries/zed/issues/21243, but this is a step forward. Release Notes: - Improved typescript and javascript symbol outline panel
This commit is contained in:
@@ -31,38 +31,103 @@
|
||||
(export_statement
|
||||
(lexical_declaration
|
||||
["let" "const"] @context
|
||||
; Multiple names may be exported - @item is on the declarator to keep
|
||||
; ranges distinct.
|
||||
(variable_declarator
|
||||
name: (_) @name) @item)))
|
||||
name: (identifier) @name) @item)))
|
||||
|
||||
; Exported array destructuring
|
||||
(program
|
||||
(export_statement
|
||||
(lexical_declaration
|
||||
["let" "const"] @context
|
||||
(variable_declarator
|
||||
name: (array_pattern
|
||||
[
|
||||
(identifier) @name @item
|
||||
(assignment_pattern left: (identifier) @name @item)
|
||||
(rest_pattern (identifier) @name @item)
|
||||
])))))
|
||||
|
||||
; Exported object destructuring
|
||||
(program
|
||||
(export_statement
|
||||
(lexical_declaration
|
||||
["let" "const"] @context
|
||||
(variable_declarator
|
||||
name: (object_pattern
|
||||
[(shorthand_property_identifier_pattern) @name @item
|
||||
(pair_pattern
|
||||
value: (identifier) @name @item)
|
||||
(pair_pattern
|
||||
value: (assignment_pattern left: (identifier) @name @item))
|
||||
(rest_pattern (identifier) @name @item)])))))
|
||||
|
||||
(program
|
||||
(lexical_declaration
|
||||
["let" "const"] @context
|
||||
; Multiple names may be defined - @item is on the declarator to keep
|
||||
; ranges distinct.
|
||||
(variable_declarator
|
||||
name: (_) @name) @item))
|
||||
name: (identifier) @name) @item))
|
||||
|
||||
; Top-level array destructuring
|
||||
(program
|
||||
(lexical_declaration
|
||||
["let" "const"] @context
|
||||
(variable_declarator
|
||||
name: (array_pattern
|
||||
[
|
||||
(identifier) @name @item
|
||||
(assignment_pattern left: (identifier) @name @item)
|
||||
(rest_pattern (identifier) @name @item)
|
||||
]))))
|
||||
|
||||
; Top-level object destructuring
|
||||
(program
|
||||
(lexical_declaration
|
||||
["let" "const"] @context
|
||||
(variable_declarator
|
||||
name: (object_pattern
|
||||
[(shorthand_property_identifier_pattern) @name @item
|
||||
(pair_pattern
|
||||
value: (identifier) @name @item)
|
||||
(pair_pattern
|
||||
value: (assignment_pattern left: (identifier) @name @item))
|
||||
(rest_pattern (identifier) @name @item)]))))
|
||||
|
||||
(class_declaration
|
||||
"class" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(method_definition
|
||||
[
|
||||
"get"
|
||||
"set"
|
||||
"async"
|
||||
"*"
|
||||
"readonly"
|
||||
"static"
|
||||
(override_modifier)
|
||||
(accessibility_modifier)
|
||||
]* @context
|
||||
name: (_) @name
|
||||
parameters: (formal_parameters
|
||||
"(" @context
|
||||
")" @context)) @item
|
||||
; Method definitions in classes (not in object literals)
|
||||
(class_body
|
||||
(method_definition
|
||||
[
|
||||
"get"
|
||||
"set"
|
||||
"async"
|
||||
"*"
|
||||
"readonly"
|
||||
"static"
|
||||
(override_modifier)
|
||||
(accessibility_modifier)
|
||||
]* @context
|
||||
name: (_) @name
|
||||
parameters: (formal_parameters
|
||||
"(" @context
|
||||
")" @context)) @item)
|
||||
|
||||
; Object literal methods
|
||||
(variable_declarator
|
||||
value: (object
|
||||
(method_definition
|
||||
[
|
||||
"get"
|
||||
"set"
|
||||
"async"
|
||||
"*"
|
||||
]* @context
|
||||
name: (_) @name
|
||||
parameters: (formal_parameters
|
||||
"(" @context
|
||||
")" @context)) @item))
|
||||
|
||||
(public_field_definition
|
||||
[
|
||||
@@ -116,4 +181,43 @@
|
||||
)
|
||||
) @item
|
||||
|
||||
; Object properties
|
||||
(pair
|
||||
key: [
|
||||
(property_identifier) @name
|
||||
(string (string_fragment) @name)
|
||||
(number) @name
|
||||
(computed_property_name) @name
|
||||
]) @item
|
||||
|
||||
; Nested variables in function bodies
|
||||
(statement_block
|
||||
(lexical_declaration
|
||||
["let" "const"] @context
|
||||
(variable_declarator
|
||||
name: (identifier) @name) @item))
|
||||
|
||||
; Nested array destructuring in functions
|
||||
(statement_block
|
||||
(lexical_declaration
|
||||
["let" "const"] @context
|
||||
(variable_declarator
|
||||
name: (array_pattern
|
||||
[
|
||||
(identifier) @name @item
|
||||
(assignment_pattern left: (identifier) @name @item)
|
||||
(rest_pattern (identifier) @name @item)
|
||||
]))))
|
||||
|
||||
; Nested object destructuring in functions
|
||||
(statement_block
|
||||
(lexical_declaration
|
||||
["let" "const"] @context
|
||||
(variable_declarator
|
||||
name: (object_pattern
|
||||
[(shorthand_property_identifier_pattern) @name @item
|
||||
(pair_pattern value: (identifier) @name @item)
|
||||
(pair_pattern value: (assignment_pattern left: (identifier) @name @item))
|
||||
(rest_pattern (identifier) @name @item)]))))
|
||||
|
||||
(comment) @annotation
|
||||
|
||||
Reference in New Issue
Block a user