diff options
| author | William Mathewson <neanias@users.noreply.github.com> | 2022-09-22 12:57:55 +0100 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2022-11-25 18:24:11 +0100 |
| commit | e7808349a578d5a8c027b1d390242c06d6542cba (patch) | |
| tree | 8e1bcc0fe207bf4d9b22f8d8f44d504033d5da3f /queries/javascript | |
| parent | improve php variables and $this highlights (diff) | |
| download | nvim-treesitter-e7808349a578d5a8c027b1d390242c06d6542cba.tar nvim-treesitter-e7808349a578d5a8c027b1d390242c06d6542cba.tar.gz nvim-treesitter-e7808349a578d5a8c027b1d390242c06d6542cba.tar.bz2 nvim-treesitter-e7808349a578d5a8c027b1d390242c06d6542cba.tar.lz nvim-treesitter-e7808349a578d5a8c027b1d390242c06d6542cba.tar.xz nvim-treesitter-e7808349a578d5a8c027b1d390242c06d6542cba.tar.zst nvim-treesitter-e7808349a578d5a8c027b1d390242c06d6542cba.zip | |
Expand locals to include properties and methods
The previous locals were lacking a few locals related to JS classes.
This expands the locals to include properties defined on classes (e.g.
`this.foo = "bar"` or `static #targets`) as both vars & references, as
well as private methods on classes (e.g. `#bar(x) { x }` and `#bar(y)`).
Diffstat (limited to 'queries/javascript')
| -rw-r--r-- | queries/javascript/locals.scm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/queries/javascript/locals.scm b/queries/javascript/locals.scm index f4f0e92de..098f18af6 100644 --- a/queries/javascript/locals.scm +++ b/queries/javascript/locals.scm @@ -1,5 +1,20 @@ ; inherits: ecma,jsx +; Both properties are matched here. +; +; class Foo { +; this.#bar = "baz"; +; this.quuz = "qux"; +; } +(field_definition + property: [(property_identifier) (private_property_identifier)] @definition.var) + +; this.foo = "bar" +(assignment_expression + left: (member_expression + object: (this) + property: (property_identifier) @definition.var)) + (formal_parameters (identifier) @definition.parameter) @@ -31,3 +46,18 @@ (formal_parameters (rest_pattern (identifier) @definition.parameter)) + +; Both methods are matched here. +; +; class Foo { +; #bar(x) { x } +; baz(y) { y } +; } +(method_definition + ([(property_identifier) (private_property_identifier)] @definition.function) + (#set! definition.var.scope parent)) + +; this.foo() +(member_expression + object: (this) + property: (property_identifier) @reference) |
