mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-10-26 11:08:40 +03:00
Rename syntaxQuery
to highlightsQuery
The `syntaxQuery` key in a grammar definition file is the only query whose name differs from its canonical filename, and there's no reason why that should be the case. Might as well change it now before we ship instead of going through the pain of changing it later.
This commit is contained in:
parent
c06b851e07
commit
2cd20067b5
@ -7,7 +7,7 @@ injectionRegex: '^(c|C)$'
|
||||
|
||||
treeSitter:
|
||||
grammar: 'tree-sitter-c/tree-sitter-c.wasm'
|
||||
syntaxQuery: 'tree-sitter-c/highlights.scm'
|
||||
highlightsQuery: 'tree-sitter-c/highlights.scm'
|
||||
localsQuery: 'tree-sitter-c/locals.scm'
|
||||
foldsQuery: 'tree-sitter-c/folds.scm'
|
||||
indentsQuery: 'tree-sitter-c/indents.scm'
|
||||
|
@ -7,7 +7,7 @@ injectionRegex: '^(cpp|CPP|cc|CC)$'
|
||||
|
||||
treeSitter:
|
||||
grammar: 'tree-sitter-cpp/tree-sitter-cpp.wasm'
|
||||
syntaxQuery: 'tree-sitter-cpp/highlights.scm'
|
||||
highlightsQuery: 'tree-sitter-cpp/highlights.scm'
|
||||
localsQuery: 'tree-sitter-cpp/locals.scm'
|
||||
foldsQuery: 'tree-sitter-cpp/folds.scm'
|
||||
indentsQuery: 'tree-sitter-cpp/indents.scm'
|
||||
|
@ -37,7 +37,7 @@
|
||||
'''
|
||||
treeSitter:
|
||||
grammar: 'ts/grammar.wasm'
|
||||
syntaxQuery: 'ts/highlights.scm'
|
||||
highlightsQuery: 'ts/highlights.scm'
|
||||
# localsQuery: 'ts/locals.scm'
|
||||
foldsQuery: 'ts/folds.scm'
|
||||
indentsQuery: 'ts/indents.scm'
|
||||
|
@ -9,7 +9,7 @@ fileTypes: [
|
||||
|
||||
treeSitter:
|
||||
grammar: 'tree-sitter/tree-sitter-css.wasm'
|
||||
syntaxQuery: 'tree-sitter/queries/highlights.scm'
|
||||
highlightsQuery: 'tree-sitter/queries/highlights.scm'
|
||||
foldsQuery: 'tree-sitter/queries/folds.scm'
|
||||
indentsQuery: 'tree-sitter/queries/indents.scm'
|
||||
|
||||
|
@ -12,6 +12,6 @@ comments:
|
||||
|
||||
treeSitter:
|
||||
grammar: 'tree-sitter-go/tree-sitter-go.wasm'
|
||||
syntaxQuery: 'tree-sitter-go/highlights.scm'
|
||||
highlightsQuery: 'tree-sitter-go/highlights.scm'
|
||||
foldsQuery: 'tree-sitter-go/folds.scm'
|
||||
indentsQuery: 'tree-sitter-go/indents.scm'
|
||||
|
@ -12,6 +12,6 @@ injectionRegex: '^(ejs|EJS)$'
|
||||
|
||||
treeSitter:
|
||||
grammar: 'tree-sitter-embedded-template/tree-sitter-embedded-template.wasm'
|
||||
syntaxQuery: 'tree-sitter-embedded-template/ejs/highlights.scm'
|
||||
highlightsQuery: 'tree-sitter-embedded-template/ejs/highlights.scm'
|
||||
foldsQuery: 'tree-sitter-embedded-template/ejs/folds.scm'
|
||||
indentsQuery: 'tree-sitter-embedded-template/ejs/indents.scm'
|
||||
|
@ -12,6 +12,6 @@ injectionRegex: '^(erb|ERB)$'
|
||||
|
||||
treeSitter:
|
||||
grammar: 'tree-sitter-embedded-template/tree-sitter-embedded-template.wasm'
|
||||
syntaxQuery: 'tree-sitter-embedded-template/erb/highlights.scm'
|
||||
highlightsQuery: 'tree-sitter-embedded-template/erb/highlights.scm'
|
||||
foldsQuery: 'tree-sitter-embedded-template/erb/folds.scm'
|
||||
indentsQuery: 'tree-sitter-embedded-template/erb/indents.scm'
|
||||
|
@ -6,11 +6,8 @@ parser: 'tree-sitter-html'
|
||||
injectionRegex: '(HTML|html|Html)$'
|
||||
|
||||
treeSitter:
|
||||
# Built from
|
||||
# https://github.com/savetheclocktower/tree-sitter-html/tree/add-entities-with-tests
|
||||
# which adds support for HTML entities. When tree-sitter-html#50 lands, we can go back to the official builds.
|
||||
grammar: 'tree-sitter-html/tree-sitter-html.wasm'
|
||||
syntaxQuery: 'tree-sitter-html/highlights.scm'
|
||||
highlightsQuery: 'tree-sitter-html/highlights.scm'
|
||||
foldsQuery: 'tree-sitter-html/folds.scm'
|
||||
indentsQuery: 'tree-sitter-html/indents.scm'
|
||||
|
||||
|
@ -6,4 +6,4 @@ parser: 'tree-sitter-hyperlink'
|
||||
injectionRegex: 'hyperlink'
|
||||
treeSitter:
|
||||
grammar: 'ts/tree-sitter-hyperlink.wasm'
|
||||
syntaxQuery: 'ts/highlights.scm'
|
||||
highlightsQuery: 'ts/highlights.scm'
|
||||
|
@ -12,6 +12,6 @@ comments:
|
||||
|
||||
treeSitter:
|
||||
grammar: 'tree-sitter-java/tree-sitter-java.wasm'
|
||||
syntaxQuery: 'tree-sitter-java/highlights.scm'
|
||||
highlightsQuery: 'tree-sitter-java/highlights.scm'
|
||||
indentsQuery: 'tree-sitter-java/indents.scm'
|
||||
foldsQuery: 'tree-sitter-java/folds.scm'
|
||||
|
@ -6,10 +6,11 @@ parser: 'tree-sitter-javascript'
|
||||
injectionRegex: '^(js|javascript)$'
|
||||
treeSitter:
|
||||
grammar: 'ts/grammar.wasm'
|
||||
syntaxQuery: 'ts/highlights.scm'
|
||||
highlightsQuery: 'ts/highlights.scm'
|
||||
localsQuery: 'ts/locals.scm'
|
||||
foldsQuery: 'ts/folds.scm'
|
||||
indentsQuery: 'ts/indents.scm'
|
||||
tagsQuery: 'ts/tags.scm'
|
||||
|
||||
firstLineRegex: [
|
||||
# shebang line
|
||||
|
@ -7,6 +7,6 @@ injectionRegex: '^jsdoc$'
|
||||
|
||||
treeSitter:
|
||||
grammar: 'ts/jsdoc/tree-sitter-jsdoc.wasm'
|
||||
syntaxQuery: 'ts/jsdoc/highlights.scm'
|
||||
highlightsQuery: 'ts/jsdoc/highlights.scm'
|
||||
foldsQuery: 'ts/jsdoc/folds.scm'
|
||||
indentsQuery: 'ts/jsdoc/indents.scm'
|
||||
|
@ -6,4 +6,4 @@ parser: 'tree-sitter-regex'
|
||||
injectionRegex: '^(js-regex)$'
|
||||
treeSitter:
|
||||
grammar: 'ts/regex/tree-sitter-regex.wasm'
|
||||
syntaxQuery: 'ts/regex/highlights.scm'
|
||||
highlightsQuery: 'ts/regex/highlights.scm'
|
||||
|
@ -7,7 +7,7 @@ injectionRegex: "^(json|JSON)$"
|
||||
|
||||
treeSitter:
|
||||
grammar: 'tree-sitter/tree-sitter-json.wasm'
|
||||
syntaxQuery: 'tree-sitter/queries/highlights.scm'
|
||||
highlightsQuery: 'tree-sitter/queries/highlights.scm'
|
||||
indentsQuery: 'tree-sitter/queries/indents.scm'
|
||||
foldsQuery: 'tree-sitter/queries/folds.scm'
|
||||
|
||||
@ -16,6 +16,7 @@ fileTypes: [
|
||||
'babelrc'
|
||||
'bowerrc'
|
||||
'composer.lock'
|
||||
'eslintrc'
|
||||
'geojson'
|
||||
'gltf'
|
||||
'htmlhintrc'
|
||||
|
@ -30,7 +30,7 @@ treeSitter:
|
||||
# Built from tree-sitter-python 62827156d01c74dc1538266344e788da74536b8a
|
||||
# to add support for `match` statements.
|
||||
grammar: 'ts/tree-sitter-python.wasm'
|
||||
syntaxQuery: 'ts/highlights.scm'
|
||||
highlightsQuery: 'ts/highlights.scm'
|
||||
localsQuery: 'ts/locals.scm'
|
||||
foldsQuery: 'ts/folds.scm'
|
||||
indentsQuery: 'ts/indents.scm'
|
||||
|
@ -10,4 +10,4 @@ injectionRegex: '^(rb-regex)$'
|
||||
|
||||
treeSitter:
|
||||
grammar: 'ts/regex/tree-sitter-regex.wasm'
|
||||
syntaxQuery: 'ts/regex/highlights.scm'
|
||||
highlightsQuery: 'ts/regex/highlights.scm'
|
||||
|
@ -7,7 +7,7 @@ injectionRegex: 'rb|ruby|RB|RUBY'
|
||||
|
||||
treeSitter:
|
||||
grammar: 'ts/grammar.wasm'
|
||||
syntaxQuery: 'ts/highlights.scm'
|
||||
highlightsQuery: 'ts/highlights.scm'
|
||||
localsQuery: 'ts/locals.scm'
|
||||
foldsQuery: 'ts/folds.scm'
|
||||
indentsQuery: 'ts/indents.scm'
|
||||
|
@ -14,6 +14,6 @@ comments:
|
||||
|
||||
treeSitter:
|
||||
grammar: 'tree-sitter-rust/tree-sitter-rust.wasm'
|
||||
syntaxQuery: 'tree-sitter-rust/queries/highlights.scm'
|
||||
highlightsQuery: 'tree-sitter-rust/queries/highlights.scm'
|
||||
foldsQuery: 'tree-sitter-rust/queries/folds.scm'
|
||||
indentsQuery: 'tree-sitter-rust/queries/indents.scm'
|
||||
|
@ -22,7 +22,7 @@ injectionRegex: '(^(bash|BASH)$|sh^|SH^)'
|
||||
|
||||
treeSitter:
|
||||
grammar: 'tree-sitter/tree-sitter-bash.wasm'
|
||||
syntaxQuery: 'tree-sitter/highlights.scm'
|
||||
highlightsQuery: 'tree-sitter/highlights.scm'
|
||||
foldsQuery: 'tree-sitter/folds.scm'
|
||||
indentsQuery: 'tree-sitter/indents.scm'
|
||||
|
||||
|
@ -6,4 +6,4 @@ parser: 'tree-sitter-todo'
|
||||
injectionRegex: '^(todo|TODO)$'
|
||||
treeSitter:
|
||||
grammar: 'ts/tree-sitter-todo.wasm'
|
||||
syntaxQuery: 'ts/highlights.scm'
|
||||
highlightsQuery: 'ts/highlights.scm'
|
||||
|
@ -12,6 +12,7 @@ comments:
|
||||
|
||||
treeSitter:
|
||||
grammar: 'tree-sitter-tsx/tree-sitter-tsx.wasm'
|
||||
syntaxQuery: 'tree-sitter-tsx/highlights.scm'
|
||||
highlightsQuery: 'tree-sitter-tsx/highlights.scm'
|
||||
indentsQuery: 'tree-sitter-tsx/indents.scm'
|
||||
foldsQuery: 'tree-sitter-tsx/folds.scm'
|
||||
tagsQuery: 'tree-sitter-tsx/tags.scm'
|
||||
|
@ -12,6 +12,7 @@ comments:
|
||||
|
||||
treeSitter:
|
||||
grammar: 'tree-sitter-typescript/tree-sitter-typescript.wasm'
|
||||
syntaxQuery: 'tree-sitter-typescript/highlights.scm'
|
||||
highlightsQuery: 'tree-sitter-typescript/highlights.scm'
|
||||
indentsQuery: 'tree-sitter-typescript/indents.scm'
|
||||
foldsQuery: 'tree-sitter-typescript/folds.scm'
|
||||
tagsQuery: 'tree-sitter-typescript/tags.scm'
|
||||
|
@ -160,33 +160,177 @@
|
||||
; FUNCTIONS
|
||||
; =========
|
||||
|
||||
(method_definition
|
||||
name: (property_identifier) @entity.name.function.method.ts.tsx)
|
||||
; Named function expressions:
|
||||
; the "foo" in `let bar = function foo () {`
|
||||
(function
|
||||
name: (identifier) @entity.name.function.definition.ts.tsx)
|
||||
|
||||
; Function definitions:
|
||||
; the "foo" in `function foo () {`
|
||||
(function_declaration
|
||||
name: (identifier) @entity.name.function.definition.ts.tsx)
|
||||
|
||||
; Named generator function expressions:
|
||||
; the "foo" in `let bar = function* foo () {`
|
||||
(generator_function
|
||||
name: (identifier) @entity.name.function.generator.definition.ts.tsx)
|
||||
|
||||
; Generator function definitions:
|
||||
; the "foo" in `function* foo () {`
|
||||
(generator_function_declaration
|
||||
name: (identifier) @entity.name.function.generator.definition.ts.tsx)
|
||||
|
||||
; Method definitions:
|
||||
; the "foo" in `foo () {` (inside a class body)
|
||||
(method_definition
|
||||
name: (property_identifier) @entity.name.function.method.definition.ts.tsx)
|
||||
|
||||
; Function property assignment:
|
||||
; The "foo" in `thing.foo = (arg) => {}`
|
||||
(assignment_expression
|
||||
left: (member_expression
|
||||
property: (property_identifier) @entity.name.function.definition.ts.tsx
|
||||
(#set! final true))
|
||||
right: [(arrow_function) (function)])
|
||||
|
||||
; Function variable assignment:
|
||||
; The "foo" in `let foo = function () {`
|
||||
(variable_declarator
|
||||
name: (identifier) @entity.name.function.definition.ts.tsx
|
||||
value: [(function) (arrow_function)])
|
||||
|
||||
; Function variable reassignment:
|
||||
; The "foo" in `foo = function () {`
|
||||
(assignment_expression
|
||||
left: (identifier) @function
|
||||
right: [(function) (arrow_function)])
|
||||
|
||||
; Object key-value pair function:
|
||||
; The "foo" in `{ foo: function () {} }`
|
||||
(pair
|
||||
key: (property_identifier) @entity.name.function.method.definition.ts.tsx
|
||||
value: [(function) (arrow_function)])
|
||||
|
||||
(function "function" @storage.type.function.ts.tsx)
|
||||
(function_declaration "function" @storage.type.function.ts.tsx)
|
||||
|
||||
(generator_function "function" @storage.type.function.ts.tsx)
|
||||
(generator_function_declaration "function" @storage.type.function.ts.tsx)
|
||||
|
||||
(generator_function "*" @storage.modifier.generator.ts.tsx)
|
||||
(generator_function_declaration "*" @storage.modifier.generator.ts.tsx)
|
||||
(method_definition "*" @storage.modifier.generator.ts.tsx)
|
||||
|
||||
(call_expression
|
||||
function: (member_expression
|
||||
property: (property_identifier) @support.other.function.method.ts.tsx))
|
||||
|
||||
; VARIABLES
|
||||
; =========
|
||||
|
||||
(this) @variable.language.this.ts.tsx
|
||||
|
||||
(required_parameter
|
||||
pattern: (_) @variable.parameter.ts)
|
||||
|
||||
(required_parameter
|
||||
pattern: (object_pattern
|
||||
(shorthand_property_identifier_pattern) @variable.parameter.destructuring.ts)
|
||||
(#set! final true))
|
||||
|
||||
(update_expression
|
||||
argument: (identifier) @variable.other.assignment.js)
|
||||
|
||||
["var" "const" "let"] @storage.type._TYPE_.ts.tsx
|
||||
|
||||
; A simple variable declaration:
|
||||
; The "foo" in `let foo = true`
|
||||
(variable_declarator
|
||||
name: (identifier) @variable.other.assignment.ts.tsx)
|
||||
|
||||
(required_parameter
|
||||
pattern: (_) @variable.parameter.ts.tsx)
|
||||
; A reassignment of a variable declared earlier:
|
||||
; The "foo" in `foo = true`
|
||||
(assignment_expression
|
||||
left: (identifier) @variable.other.assignment.ts.tsx)
|
||||
|
||||
(arrow_function
|
||||
parameter: (identifier) @variable.parameter.arrow.ts.tsx)
|
||||
; A variable object destructuring:
|
||||
; The "foo" in `let { foo } = something`
|
||||
(assignment_expression
|
||||
left: (member_expression
|
||||
property: (property_identifier)) @variable.other.assignment.property.ts.tsx)
|
||||
|
||||
; The "foo" in `foo += 1`.
|
||||
(augmented_assignment_expression
|
||||
left: (identifier) @variable.other.assignment.ts.tsx)
|
||||
|
||||
; The "foo" in `foo++`.
|
||||
(update_expression
|
||||
argument: (identifier) @variable.other.assignment.ts.tsx)
|
||||
|
||||
; `object_pattern` appears to only be encountered in assignment expressions, so
|
||||
; this won't match other uses of object/prop shorthand.
|
||||
((object_pattern
|
||||
(shorthand_property_identifier_pattern) @variable.other.assignment.destructuring.ts.tsx))
|
||||
|
||||
; A variable object destructuring with default value:
|
||||
; The "foo" in `let { foo = true } = something`
|
||||
(object_assignment_pattern
|
||||
(shorthand_property_identifier_pattern) @variable.other.assignment.destructuring.ts.tsx)
|
||||
|
||||
; A variable object alias destructuring:
|
||||
; The "bar" and "foo" in `let { bar: foo } = something`
|
||||
(object_pattern
|
||||
(pair_pattern
|
||||
; TODO: This arguably isn't an object key.
|
||||
key: (_) @entity.other.attribute-name.ts.tsx
|
||||
value: (identifier) @variable.other.assignment.destructuring.ts.tsx))
|
||||
|
||||
; A variable object alias destructuring with default value:
|
||||
; The "bar" and "foo" in `let { bar: foo = true } = something`
|
||||
(object_pattern
|
||||
(pair_pattern
|
||||
; TODO: This arguably isn't an object key.
|
||||
key: (_) @entity.other.attribute-name.ts.tsx
|
||||
value: (assignment_pattern
|
||||
left: (identifier) @variable.other.assignment.destructuring.ts.tsx)))
|
||||
|
||||
; A variable array destructuring:
|
||||
; The "foo" and "bar" in `let [foo, bar] = something`
|
||||
(variable_declarator
|
||||
(array_pattern
|
||||
(identifier) @variable.other.assignment.destructuring.ts.tsx))
|
||||
|
||||
; A variable declaration in a for…(in|of) loop:
|
||||
; The "foo" in `for (let foo of bar) {`
|
||||
(for_in_statement
|
||||
left: (identifier) @variable.other.assignment.loop.ts.tsx)
|
||||
|
||||
; A variable array destructuring in a for…(in|of) loop:
|
||||
; The "foo" and "bar" in `for (let [foo, bar] of baz)`
|
||||
(for_in_statement
|
||||
left: (array_pattern
|
||||
(identifier) @variable.other.assignment.loop.ts.tsx))
|
||||
|
||||
; A variable object destructuring in a for…(in|of) loop:
|
||||
; The "foo" and "bar" in `for (let { foo, bar } of baz)`
|
||||
(for_in_statement
|
||||
left: (identifier) @variable.other.assignment.loop.ts.tsx)
|
||||
left: (object_pattern
|
||||
(shorthand_property_identifier_pattern) @variable.other.assignment.loop.ts.tsx))
|
||||
|
||||
; A variable object destructuring in a for…(in|of) loop:
|
||||
; The "foo" in `for (let { bar: foo } of baz)`
|
||||
(for_in_statement
|
||||
left: (object_pattern
|
||||
(pair_pattern
|
||||
key: (_) @entity.other.attribute-name.ts.tsx
|
||||
value: (identifier) @variable.other.assignment.loop.ts.tsx)
|
||||
(#set! final true)))
|
||||
|
||||
; The "error" in `} catch (error) {`
|
||||
(catch_clause
|
||||
parameter: (identifier) @variable.other.assignment.catch.ts.tsx)
|
||||
|
||||
; Single parameter of an arrow function:
|
||||
; The "foo" in `(foo => …)`
|
||||
(arrow_function parameter: (identifier) @variable.parameter.ts.tsx)
|
||||
|
||||
|
||||
; NUMBERS
|
||||
; =======
|
||||
@ -313,6 +457,8 @@
|
||||
"<"
|
||||
] @keyword.operator.comparison.ts.tsx
|
||||
|
||||
["++" "--"] @keyword.operator.increment.ts.tsx
|
||||
|
||||
[
|
||||
"&&"
|
||||
"||"
|
||||
|
@ -0,0 +1,20 @@
|
||||
(function_declaration
|
||||
name: (identifier) @name) @definition.function
|
||||
|
||||
(function
|
||||
name: (identifier) @name) @definition.function
|
||||
|
||||
(method_definition
|
||||
name: (property_identifier) @name) @definition.method
|
||||
|
||||
(abstract_method_signature
|
||||
name: (property_identifier) @name) @definition.method
|
||||
|
||||
(class_declaration
|
||||
name: (type_identifier) @name) @definition.class
|
||||
|
||||
(module
|
||||
name: (identifier) @name) @definition.module
|
||||
|
||||
(interface_declaration
|
||||
name: (type_identifier) @name) @definition.interface
|
@ -167,26 +167,168 @@
|
||||
function: (member_expression
|
||||
property: (property_identifier) @support.other.function.method.ts))
|
||||
|
||||
; Named function expressions:
|
||||
; the "foo" in `let bar = function foo () {`
|
||||
(function
|
||||
name: (identifier) @entity.name.function.definition.ts)
|
||||
|
||||
; Function definitions:
|
||||
; the "foo" in `function foo () {`
|
||||
(function_declaration
|
||||
name: (identifier) @entity.name.function.definition.ts)
|
||||
|
||||
; Named generator function expressions:
|
||||
; the "foo" in `let bar = function* foo () {`
|
||||
(generator_function
|
||||
name: (identifier) @entity.name.function.generator.definition.ts)
|
||||
|
||||
; Generator function definitions:
|
||||
; the "foo" in `function* foo () {`
|
||||
(generator_function_declaration
|
||||
name: (identifier) @entity.name.function.generator.definition.ts)
|
||||
|
||||
; Method definitions:
|
||||
; the "foo" in `foo () {` (inside a class body)
|
||||
(method_definition
|
||||
name: (property_identifier) @entity.name.function.method.definition.ts)
|
||||
|
||||
; Function property assignment:
|
||||
; The "foo" in `thing.foo = (arg) => {}`
|
||||
(assignment_expression
|
||||
left: (member_expression
|
||||
property: (property_identifier) @entity.name.function.definition.ts
|
||||
(#set! final true))
|
||||
right: [(arrow_function) (function)])
|
||||
|
||||
; Function variable assignment:
|
||||
; The "foo" in `let foo = function () {`
|
||||
(variable_declarator
|
||||
name: (identifier) @entity.name.function.definition.ts
|
||||
value: [(function) (arrow_function)])
|
||||
|
||||
; Function variable reassignment:
|
||||
; The "foo" in `foo = function () {`
|
||||
(assignment_expression
|
||||
left: (identifier) @function
|
||||
right: [(function) (arrow_function)])
|
||||
|
||||
; Object key-value pair function:
|
||||
; The "foo" in `{ foo: function () {} }`
|
||||
(pair
|
||||
key: (property_identifier) @entity.name.function.method.definition.ts
|
||||
value: [(function) (arrow_function)])
|
||||
|
||||
(function "function" @storage.type.function.ts)
|
||||
(function_declaration "function" @storage.type.function.ts)
|
||||
|
||||
(generator_function "function" @storage.type.function.ts)
|
||||
(generator_function_declaration "function" @storage.type.function.ts)
|
||||
|
||||
(generator_function "*" @storage.modifier.generator.ts)
|
||||
(generator_function_declaration "*" @storage.modifier.generator.ts)
|
||||
(method_definition "*" @storage.modifier.generator.ts)
|
||||
|
||||
|
||||
; VARIABLES
|
||||
; =========
|
||||
|
||||
(this) @variable.language.this.ts
|
||||
|
||||
(required_parameter
|
||||
pattern: (identifier) @variable.parameter.ts)
|
||||
|
||||
(required_parameter
|
||||
pattern: (object_pattern
|
||||
(shorthand_property_identifier_pattern) @variable.parameter.destructuring.ts)
|
||||
(#set! final true))
|
||||
|
||||
["var" "const" "let"] @storage.type._TYPE_.ts
|
||||
|
||||
; A simple variable declaration:
|
||||
; The "foo" in `let foo = true`
|
||||
(variable_declarator
|
||||
name: (identifier) @variable.other.assignment.ts)
|
||||
|
||||
(required_parameter
|
||||
pattern: (_) @variable.parameter.ts)
|
||||
; A reassignment of a variable declared earlier:
|
||||
; The "foo" in `foo = true`
|
||||
(assignment_expression
|
||||
left: (identifier) @variable.other.assignment.ts)
|
||||
|
||||
(arrow_function
|
||||
parameter: (identifier) @variable.parameter.arrow.ts)
|
||||
; The "foo" in `foo += 1`.
|
||||
(augmented_assignment_expression
|
||||
left: (identifier) @variable.other.assignment.ts)
|
||||
|
||||
; The "foo" in `foo++`.
|
||||
(update_expression
|
||||
argument: (identifier) @variable.other.assignment.ts)
|
||||
|
||||
; `object_pattern` appears to only be encountered in assignment expressions, so
|
||||
; this won't match other uses of object/prop shorthand.
|
||||
((object_pattern
|
||||
(shorthand_property_identifier_pattern) @variable.other.assignment.destructuring.ts))
|
||||
|
||||
; A variable object destructuring with default value:
|
||||
; The "foo" in `let { foo = true } = something`
|
||||
(object_assignment_pattern
|
||||
(shorthand_property_identifier_pattern) @variable.other.assignment.destructuring.ts)
|
||||
|
||||
; A variable object alias destructuring:
|
||||
; The "bar" and "foo" in `let { bar: foo } = something`
|
||||
(object_pattern
|
||||
(pair_pattern
|
||||
; TODO: This arguably isn't an object key.
|
||||
key: (_) @entity.other.attribute-name.ts
|
||||
value: (identifier) @variable.other.assignment.destructuring.ts))
|
||||
|
||||
; A variable object alias destructuring with default value:
|
||||
; The "bar" and "foo" in `let { bar: foo = true } = something`
|
||||
(object_pattern
|
||||
(pair_pattern
|
||||
; TODO: This arguably isn't an object key.
|
||||
key: (_) @entity.other.attribute-name.ts
|
||||
value: (assignment_pattern
|
||||
left: (identifier) @variable.other.assignment.destructuring.ts)))
|
||||
|
||||
; A variable array destructuring:
|
||||
; The "foo" and "bar" in `let [foo, bar] = something`
|
||||
(variable_declarator
|
||||
(array_pattern
|
||||
(identifier) @variable.other.assignment.destructuring.ts))
|
||||
|
||||
; A variable declaration in a for…(in|of) loop:
|
||||
; The "foo" in `for (let foo of bar) {`
|
||||
(for_in_statement
|
||||
left: (identifier) @variable.other.assignment.loop.ts)
|
||||
|
||||
; A variable array destructuring in a for…(in|of) loop:
|
||||
; The "foo" and "bar" in `for (let [foo, bar] of baz)`
|
||||
(for_in_statement
|
||||
left: (array_pattern
|
||||
(identifier) @variable.other.assignment.loop.ts))
|
||||
|
||||
; A variable object destructuring in a for…(in|of) loop:
|
||||
; The "foo" and "bar" in `for (let { foo, bar } of baz)`
|
||||
(for_in_statement
|
||||
left: (identifier) @variable.other.assignment.loop.ts)
|
||||
left: (object_pattern
|
||||
(shorthand_property_identifier_pattern) @variable.other.assignment.loop.ts))
|
||||
|
||||
; A variable object destructuring in a for…(in|of) loop:
|
||||
; The "foo" in `for (let { bar: foo } of baz)`
|
||||
(for_in_statement
|
||||
left: (object_pattern
|
||||
(pair_pattern
|
||||
key: (_) @entity.other.attribute-name.ts
|
||||
value: (identifier) @variable.other.assignment.loop.ts)
|
||||
(#set! final true)))
|
||||
|
||||
; The "error" in `} catch (error) {`
|
||||
(catch_clause
|
||||
parameter: (identifier) @variable.other.assignment.catch.ts)
|
||||
|
||||
; Single parameter of an arrow function:
|
||||
; The "foo" in `(foo => …)`
|
||||
(arrow_function parameter: (identifier) @variable.parameter.ts)
|
||||
|
||||
|
||||
; NUMBERS
|
||||
; =======
|
||||
@ -313,6 +455,8 @@
|
||||
"<"
|
||||
] @keyword.operator.comparison.ts
|
||||
|
||||
["++" "--"] @keyword.operator.increment.ts
|
||||
|
||||
[
|
||||
"&&"
|
||||
"||"
|
||||
@ -332,7 +476,7 @@
|
||||
; TODO: Ternary doesn't highlight properly; presumably fixed in
|
||||
; https://github.com/tree-sitter/tree-sitter-typescript/pull/215, but needs
|
||||
; update to v0.20.2.
|
||||
((ternary_expression) @keyword.operator.ternary.js
|
||||
((ternary_expression) @keyword.operator.ternary.ts
|
||||
(#set! startAndEndAroundFirstMatchOf "\\?"))
|
||||
|
||||
(public_field_definition "?" @keyword.operator.optional-type.ts)
|
||||
|
@ -0,0 +1,20 @@
|
||||
(function_declaration
|
||||
name: (identifier) @name) @definition.function
|
||||
|
||||
(function
|
||||
name: (identifier) @name) @definition.function
|
||||
|
||||
(method_definition
|
||||
name: (property_identifier) @name) @definition.method
|
||||
|
||||
(abstract_method_signature
|
||||
name: (property_identifier) @name) @definition.method
|
||||
|
||||
(class_declaration
|
||||
name: (type_identifier) @name) @definition.class
|
||||
|
||||
(module
|
||||
name: (identifier) @name) @definition.module
|
||||
|
||||
(interface_declaration
|
||||
name: (type_identifier) @name) @definition.interface
|
@ -33,7 +33,7 @@ const jsRegexGrammarPath = resolve(
|
||||
let jsRegexConfig = CSON.readFileSync(jsRegexGrammarPath);
|
||||
|
||||
async function getAllCaptures(grammar, languageMode, layer = null) {
|
||||
let query = await grammar.getQuery('syntaxQuery');
|
||||
let query = await grammar.getQuery('highlightsQuery');
|
||||
layer = layer ?? languageMode.rootLanguageLayer;
|
||||
let scopeResolver = new ScopeResolver(
|
||||
layer,
|
||||
@ -82,7 +82,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('resolves all scopes in absence of any tests or adjustments', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(comment) @comment
|
||||
(string) @string
|
||||
"=" @operator
|
||||
@ -107,7 +107,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('interpolates magic tokens in scope names', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(lexical_declaration kind: _ @declaration._TYPE_)
|
||||
`);
|
||||
|
||||
@ -135,7 +135,7 @@ describe('ScopeResolver', () => {
|
||||
|
||||
describe('adjustments', () => {
|
||||
it('adjusts ranges with (#set! startAt)', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((try_statement) @try.plus.brace
|
||||
(#set! endAt
|
||||
firstChild.nextSibling.firstChild.endPosition))
|
||||
@ -158,7 +158,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('adjusts ranges with (#set! endAt)', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((object) @object.interior
|
||||
(#set! startAt firstChild.endPosition)
|
||||
(#set! endAt lastChild.startPosition))
|
||||
@ -184,7 +184,7 @@ describe('ScopeResolver', () => {
|
||||
|
||||
it('adjusts ranges with (#set! offset(Start|End))', async () => {
|
||||
// Same result as the previous test, but with a different technique.
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((object) @object.interior
|
||||
(#set! offsetStart 1)
|
||||
(#set! offsetEnd -1))
|
||||
@ -208,7 +208,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('prevents adjustments outside the original capture', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((comment) @too-early
|
||||
(#set! startAt previousSibling.startPosition))
|
||||
((comment) @too-late
|
||||
@ -241,7 +241,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it("adjusts a range around a regex match with `startAndEndAroundFirstMatchOf`", async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((comment) @todo
|
||||
(#set! startAndEndAroundFirstMatchOf "\\\\sTODO(?=:)"))
|
||||
`);
|
||||
@ -276,7 +276,7 @@ describe('ScopeResolver', () => {
|
||||
describe('tests', () => {
|
||||
|
||||
it('rejects scopes for ranges that have already been claimed by another capture with (#set! final true)', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(comment) @comment
|
||||
(string) @string0
|
||||
((string) @string1
|
||||
@ -312,7 +312,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('rejects scopes for ranges that have already been claimed if set with (#set! shy true)', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(comment) @comment
|
||||
(string "\\"") @string.double
|
||||
((string) @string.other (#set! shy true))
|
||||
@ -344,7 +344,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('rejects scopes for ranges that fail onlyIfFirst or onlyIfLast', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((string_fragment) @impossible.first
|
||||
(#set! onlyIfFirst true))
|
||||
((string_fragment) @impossible.last
|
||||
@ -383,7 +383,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfFirstOfType and onlyIfLastOfType', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(formal_parameters (identifier) @first-param
|
||||
(#set! onlyIfFirstOfType identifier))
|
||||
(formal_parameters (identifier) @last-param
|
||||
@ -418,7 +418,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfLastTextOnRow', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
("||" @hanging-logical-operator
|
||||
(#set! onlyIfLastTextOnRow true))
|
||||
`);
|
||||
@ -449,7 +449,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfDescendantOfType', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
("," @comma-inside-function
|
||||
(#set! onlyIfDescendantOfType function_declaration))
|
||||
`);
|
||||
@ -471,7 +471,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfAncestorOfType', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((function_declaration) @function-with-semicolons
|
||||
(#set! onlyIfAncestorOfType ";"))
|
||||
`);
|
||||
@ -493,7 +493,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfDescendantOfNodeWithData (without value)', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((function_declaration) @_IGNORE_
|
||||
(#match? @_IGNORE_ "foo")
|
||||
(#set! isSpecialFunction true))
|
||||
@ -520,7 +520,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfDescendantOfNodeWithData (with right value)', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((function_declaration) @_IGNORE_
|
||||
(#match? @_IGNORE_ "foo" )
|
||||
(#set! isSpecialFunction "troz"))
|
||||
@ -547,7 +547,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfDescendantOfNodeWithData (with wrong value)', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((function_declaration) @_IGNORE_
|
||||
(#match? @_IGNORE_ "foo")
|
||||
(#set! isSpecialFunction "troz"))
|
||||
@ -571,7 +571,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfType', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(formal_parameters _ @function-comma
|
||||
(#set! onlyIfType ","))
|
||||
`);
|
||||
@ -592,7 +592,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfHasError', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((statement_block) @messed-up-statement-block
|
||||
(#set! onlyIfHasError true))
|
||||
`);
|
||||
@ -615,7 +615,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfRoot', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((_) @is-root
|
||||
(#set! onlyIfRoot true))
|
||||
`);
|
||||
@ -639,7 +639,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfLastTextOnRow', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
("||" @orphaned-operator
|
||||
(#set! onlyIfLastTextOnRow true))
|
||||
`);
|
||||
@ -665,7 +665,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfRangeWithData (without value)', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((true) @_IGNORE_ (#set! isTrue true))
|
||||
([ (true) (false) ] @optimistic-boolean
|
||||
(#set! onlyIfRangeWithData isTrue))
|
||||
@ -691,7 +691,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfRangeWithData (with right value)', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((true) @_IGNORE_ (#set! isTrue "exactly"))
|
||||
([ (true) (false) ] @optimistic-boolean
|
||||
(#set! onlyIfRangeWithData "isTrue exactly"))
|
||||
@ -717,7 +717,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfRangeWithData (with wrong value)', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((true) @_IGNORE_ (#set! isTrue "perhaps"))
|
||||
([ (true) (false) ] @optimistic-boolean
|
||||
(#set! onlyIfRangeWithData "isTrue exactly"))
|
||||
@ -740,7 +740,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfStartsOnSameRowAs', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((false) @non-hanging-false
|
||||
(#set! onlyIfStartsOnSameRowAs parent.startPosition))
|
||||
`);
|
||||
@ -767,7 +767,7 @@ describe('ScopeResolver', () => {
|
||||
});
|
||||
|
||||
it('supports onlyIfEndsOnSameRowAs', async () => {
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((true) @non-hanging-true
|
||||
(#set! onlyIfEndsOnSameRowAs parent.endPosition))
|
||||
`);
|
||||
@ -796,7 +796,7 @@ describe('ScopeResolver', () => {
|
||||
it('supports onlyIfConfig (with no arguments)', async () => {
|
||||
atom.config.set('core.careAboutBooleans', true);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
([(true) (false)] @boolean
|
||||
(#set! onlyIfConfig core.careAboutBooleans))
|
||||
`);
|
||||
@ -823,7 +823,7 @@ describe('ScopeResolver', () => {
|
||||
it('supports onlyIfConfig (with boolean arguments)', async () => {
|
||||
atom.config.set('core.careAboutBooleans', true);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
([(true) (false)] @boolean
|
||||
(#set! onlyIfConfig "core.careAboutBooleans true"))
|
||||
`);
|
||||
@ -850,7 +850,7 @@ describe('ScopeResolver', () => {
|
||||
it('supports onlyIfConfig (with number arguments)', async () => {
|
||||
atom.config.set('core.careAboutBooleans', 0);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
([(true) (false)] @boolean
|
||||
(#set! onlyIfConfig "core.careAboutBooleans 0"))
|
||||
`);
|
||||
@ -877,7 +877,7 @@ describe('ScopeResolver', () => {
|
||||
it('supports onlyIfConfig (with string arguments)', async () => {
|
||||
atom.config.set('core.careAboutBooleans', "something");
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
([(true) (false)] @boolean
|
||||
(#set! onlyIfConfig "core.careAboutBooleans something"))
|
||||
`);
|
||||
@ -903,13 +903,13 @@ describe('ScopeResolver', () => {
|
||||
|
||||
it('supports onlyIfInjection', async () => {
|
||||
jasmine.useRealClock();
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((escape_sequence) @regex-escape
|
||||
(#set! onlyIfInjection true))
|
||||
`);
|
||||
|
||||
let regexGrammar = new WASMTreeSitterGrammar(atom.grammars, jsRegexGrammarPath, jsRegexConfig);
|
||||
await regexGrammar.setQueryForTest('syntaxQuery', `
|
||||
await regexGrammar.setQueryForTest('highlightsQuery', `
|
||||
((control_escape) @regex-escape
|
||||
(#set! onlyIfInjection true))
|
||||
`);
|
||||
|
@ -77,7 +77,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
jasmine.useRealClock();
|
||||
grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(member_expression object: (identifier) @support)
|
||||
|
||||
(call_expression
|
||||
@ -125,7 +125,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
jasmine.useRealClock();
|
||||
grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(member_expression object: (identifier) @support)
|
||||
|
||||
(call_expression
|
||||
@ -174,7 +174,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
jasmine.useRealClock();
|
||||
grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(member_expression object: (_) @variable)
|
||||
|
||||
(call_expression
|
||||
@ -203,7 +203,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
jasmine.useRealClock();
|
||||
grammar = new WASMTreeSitterGrammar(atom.grammars, cGrammarPath, cConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(primitive_type) @storage
|
||||
(declaration declarator: (identifier) @variable)
|
||||
(function_declarator declarator: (identifier) @entity)
|
||||
@ -255,7 +255,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
jasmine.useRealClock();
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(call_expression (identifier) @function)
|
||||
(property_identifier) @member
|
||||
`);
|
||||
@ -295,7 +295,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
jasmine.useRealClock();
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((template_string) @lorem
|
||||
(#match? @lorem "lorem"))
|
||||
((template_string) @ipsum
|
||||
@ -371,7 +371,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(comment) @comment
|
||||
(string) @string
|
||||
(property_identifier) @property
|
||||
@ -416,7 +416,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
jasmine.useRealClock();
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(template_string) @string
|
||||
["\${" "}"] @interpolation
|
||||
`);
|
||||
@ -450,7 +450,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
jasmine.useRealClock();
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(comment) @comment
|
||||
(call_expression (identifier) @function)
|
||||
`);
|
||||
@ -488,7 +488,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
jasmine.useRealClock();
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
((identifier) @global
|
||||
(#match? @global "^(exports|document|window|global)$"))
|
||||
|
||||
@ -527,7 +527,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
jasmine.useRealClock();
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, rubyGrammarPath, rubyConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(bare_string) @string
|
||||
(interpolation) @embedded
|
||||
["#{" "}"] @punctuation
|
||||
@ -562,7 +562,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
jasmine.useRealClock();
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(identifier) @variable
|
||||
`);
|
||||
|
||||
@ -642,7 +642,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
jasmine.useRealClock();
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(call_expression
|
||||
(member_expression
|
||||
(property_identifier) @method)
|
||||
@ -702,7 +702,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
let tempJsConfig = { ...jsConfig };
|
||||
jsGrammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, tempJsConfig);
|
||||
|
||||
await jsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await jsGrammar.setQueryForTest('highlightsQuery', `
|
||||
(comment) @comment
|
||||
(property_identifier) @property
|
||||
(call_expression (identifier) @function)
|
||||
@ -717,7 +717,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
let tempHtmlConfig = { ...htmlConfig };
|
||||
htmlGrammar = new WASMTreeSitterGrammar(atom.grammars, htmlGrammarPath, tempHtmlConfig);
|
||||
|
||||
await htmlGrammar.setQueryForTest('syntaxQuery', `
|
||||
await htmlGrammar.setQueryForTest('highlightsQuery', `
|
||||
(fragment) @html
|
||||
(tag_name) @tag
|
||||
(attribute_name) @attr
|
||||
@ -905,7 +905,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
CSON.readFileSync(ejsGrammarPath)
|
||||
);
|
||||
|
||||
await ejsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await ejsGrammar.setQueryForTest('highlightsQuery', `
|
||||
["<%=" "%>"] @directive
|
||||
`);
|
||||
|
||||
@ -1038,7 +1038,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
CSON.readFileSync(ejsGrammarPath)
|
||||
);
|
||||
|
||||
await ejsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await ejsGrammar.setQueryForTest('highlightsQuery', `
|
||||
["<%" "%>"] @directive
|
||||
`);
|
||||
|
||||
@ -1094,7 +1094,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
CSON.readFileSync(jsdocGrammarPath)
|
||||
);
|
||||
|
||||
jsdocGrammar.setQueryForTest('syntaxQuery', '');
|
||||
jsdocGrammar.setQueryForTest('highlightsQuery', '');
|
||||
|
||||
atom.grammars.addGrammar(jsGrammar);
|
||||
atom.grammars.addGrammar(jsdocGrammar);
|
||||
@ -1124,7 +1124,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
await atom.packages.activatePackage('language-javascript');
|
||||
|
||||
let jsdocGrammar = atom.grammars.grammarForScopeName('source.jsdoc');
|
||||
await jsdocGrammar.setQueryForTest('syntaxQuery', `
|
||||
await jsdocGrammar.setQueryForTest('highlightsQuery', `
|
||||
((ERROR) @comment.block.js
|
||||
(#set! onlyIfRoot true))
|
||||
(document) @comment.block.js
|
||||
@ -1133,7 +1133,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
`);
|
||||
|
||||
let jsGrammar = atom.grammars.grammarForScopeName('source.js');
|
||||
await jsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await jsGrammar.setQueryForTest('highlightsQuery', `
|
||||
["{" "}"] @punctuation.brace
|
||||
`);
|
||||
|
||||
@ -1197,7 +1197,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
});
|
||||
}
|
||||
|
||||
await rustGrammar.setQueryForTest('syntaxQuery', `
|
||||
await rustGrammar.setQueryForTest('highlightsQuery', `
|
||||
(macro_invocation
|
||||
macro: (identifier) @macro
|
||||
(#set! final true))
|
||||
@ -1259,7 +1259,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
let customJsConfig = { ...jsConfig };
|
||||
let customJsGrammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, customJsConfig);
|
||||
|
||||
await jsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await jsGrammar.setQueryForTest('highlightsQuery', `
|
||||
(comment) @comment
|
||||
(property_identifier) @property
|
||||
(call_expression (identifier) @function)
|
||||
@ -1271,7 +1271,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
let customHtmlConfig = { ...htmlConfig };
|
||||
let customHtmlGrammar = new WASMTreeSitterGrammar(atom.grammars, htmlGrammarPath, customHtmlConfig);
|
||||
|
||||
await htmlGrammar.setQueryForTest('syntaxQuery', `
|
||||
await htmlGrammar.setQueryForTest('highlightsQuery', `
|
||||
(fragment) @html
|
||||
(tag_name) @tag
|
||||
(attribute_name) @attr
|
||||
@ -1307,7 +1307,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
let customJsConfig = { ...jsConfig };
|
||||
let customJsGrammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, customJsConfig);
|
||||
|
||||
await jsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await jsGrammar.setQueryForTest('highlightsQuery', `
|
||||
(comment) @comment
|
||||
(property_identifier) @property
|
||||
(call_expression (identifier) @function)
|
||||
@ -1319,7 +1319,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
let customHtmlConfig = { ...htmlConfig };
|
||||
let customHtmlGrammar = new WASMTreeSitterGrammar(atom.grammars, htmlGrammarPath, customHtmlConfig);
|
||||
|
||||
await htmlGrammar.setQueryForTest('syntaxQuery', `
|
||||
await htmlGrammar.setQueryForTest('highlightsQuery', `
|
||||
(fragment) @html
|
||||
(tag_name) @tag
|
||||
(attribute_name) @attr
|
||||
@ -1358,7 +1358,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
let customJsConfig = { ...jsConfig };
|
||||
let customJsGrammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, customJsConfig);
|
||||
|
||||
await jsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await jsGrammar.setQueryForTest('highlightsQuery', `
|
||||
(comment) @comment
|
||||
(property_identifier) @property
|
||||
(call_expression (identifier) @function)
|
||||
@ -1370,7 +1370,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
let customHtmlConfig = { ...htmlConfig };
|
||||
let customHtmlGrammar = new WASMTreeSitterGrammar(atom.grammars, htmlGrammarPath, customHtmlConfig);
|
||||
|
||||
await htmlGrammar.setQueryForTest('syntaxQuery', `
|
||||
await htmlGrammar.setQueryForTest('highlightsQuery', `
|
||||
(fragment) @html
|
||||
(tag_name) @tag
|
||||
(attribute_name) @attr
|
||||
@ -2228,7 +2228,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
it('returns a scope descriptor representing the given position in the syntax tree', async () => {
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(property_identifier) @property.name
|
||||
(comment) @comment.block
|
||||
`);
|
||||
@ -2273,7 +2273,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
it('includes nodes in injected syntax trees', async () => {
|
||||
const jsGrammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await jsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await jsGrammar.setQueryForTest('highlightsQuery', `
|
||||
(template_string) @string.quoted
|
||||
(property_identifier) @property.name
|
||||
`);
|
||||
@ -2286,7 +2286,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
htmlConfig
|
||||
);
|
||||
|
||||
await htmlGrammar.setQueryForTest('syntaxQuery', `
|
||||
await htmlGrammar.setQueryForTest('highlightsQuery', `
|
||||
(script_element) @script.tag
|
||||
`);
|
||||
htmlGrammar.addInjectionPoint(SCRIPT_TAG_INJECTION_POINT);
|
||||
@ -2330,7 +2330,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
it('includes the root scope name even when the given position is in trailing whitespace at EOF', async () => {
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(property_identifier) @property.name
|
||||
`);
|
||||
|
||||
@ -2348,7 +2348,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
it('works when the given position is between tokens', async () => {
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(comment) @comment.block
|
||||
`);
|
||||
|
||||
@ -2369,7 +2369,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
it('works when a scope range has been adjusted', async () => {
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(comment) @comment.block
|
||||
((comment) @punctuation.definition.comment.begin
|
||||
(#set! startAndEndAroundFirstMatchOf "^/\\\\*"))
|
||||
@ -2403,7 +2403,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
|
||||
const regexGrammar = new WASMTreeSitterGrammar(atom.grammars, jsRegexGrammarPath, tempJsRegexConfig);
|
||||
|
||||
await regexGrammar.setQueryForTest('syntaxQuery', `
|
||||
await regexGrammar.setQueryForTest('highlightsQuery', `
|
||||
(pattern) @string.regexp
|
||||
(optional "?" @keyword.operator.optional)
|
||||
`);
|
||||
@ -2421,7 +2421,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
coverShallowerScopes: true
|
||||
});
|
||||
|
||||
await jsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await jsGrammar.setQueryForTest('highlightsQuery', `
|
||||
((regex) @gadfly
|
||||
(#set! startAndEndAroundFirstMatchOf "lor\\\\?em"))
|
||||
(regex) @regex-outer
|
||||
@ -2467,7 +2467,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
|
||||
const regexGrammar = new WASMTreeSitterGrammar(atom.grammars, jsRegexGrammarPath, tempJsRegexConfig);
|
||||
|
||||
await regexGrammar.setQueryForTest('syntaxQuery', `
|
||||
await regexGrammar.setQueryForTest('highlightsQuery', `
|
||||
(pattern) @string.regexp
|
||||
`);
|
||||
|
||||
@ -2483,7 +2483,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
languageScope: null
|
||||
});
|
||||
|
||||
await jsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await jsGrammar.setQueryForTest('highlightsQuery', `
|
||||
((regex_pattern) @gadfly
|
||||
(#set! startAndEndAroundFirstMatchOf "lor\\\\?em"))
|
||||
(regex) @regex-outer
|
||||
@ -2648,7 +2648,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
|
||||
jsGrammar.addInjectionPoint(HTML_TEMPLATE_LITERAL_INJECTION_POINT);
|
||||
|
||||
await jsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await jsGrammar.setQueryForTest('highlightsQuery', `
|
||||
(property_identifier) @property
|
||||
`);
|
||||
|
||||
@ -2698,7 +2698,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
it('returns the range of the smallest matching node at position', async () => {
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(property_identifier) @variable.other.object.property
|
||||
(template_string) @string.quoted.template
|
||||
`);
|
||||
@ -2720,7 +2720,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
it('includes nodes in injected syntax trees', async () => {
|
||||
const jsGrammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
jsGrammar.addInjectionPoint(HTML_TEMPLATE_LITERAL_INJECTION_POINT);
|
||||
await jsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await jsGrammar.setQueryForTest('highlightsQuery', `
|
||||
(property_identifier) @variable.other.object.property
|
||||
`);
|
||||
|
||||
@ -2731,7 +2731,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
);
|
||||
|
||||
htmlGrammar.addInjectionPoint(SCRIPT_TAG_INJECTION_POINT);
|
||||
await htmlGrammar.setQueryForTest('syntaxQuery', `
|
||||
await htmlGrammar.setQueryForTest('highlightsQuery', `
|
||||
(element) @meta.element.html
|
||||
`);
|
||||
|
||||
@ -2778,7 +2778,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
jasmine.useRealClock();
|
||||
const jsGrammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await jsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await jsGrammar.setQueryForTest('highlightsQuery', `
|
||||
((regex) @keyword.operator.optional
|
||||
(#set! startAndEndAroundFirstMatchOf "\\\\?"))
|
||||
(regex) @string.regexp.js
|
||||
@ -2826,7 +2826,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
|
||||
const regexGrammar = new WASMTreeSitterGrammar(atom.grammars, jsRegexGrammarPath, tempJsRegexConfig);
|
||||
|
||||
await regexGrammar.setQueryForTest('syntaxQuery', `
|
||||
await regexGrammar.setQueryForTest('highlightsQuery', `
|
||||
(pattern) @string.regexp
|
||||
`);
|
||||
|
||||
@ -2842,7 +2842,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
coverShallowerScopes: true
|
||||
});
|
||||
|
||||
await jsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await jsGrammar.setQueryForTest('highlightsQuery', `
|
||||
((regex) @keyword.operator.optional
|
||||
(#set! startAndEndAroundFirstMatchOf "\\\\?"))
|
||||
((regex_pattern) @string.regexp.js)
|
||||
@ -2876,7 +2876,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
|
||||
jsGrammar.addInjectionPoint(HTML_TEMPLATE_LITERAL_INJECTION_POINT);
|
||||
|
||||
await jsGrammar.setQueryForTest('syntaxQuery', ';');
|
||||
await jsGrammar.setQueryForTest('highlightsQuery', ';');
|
||||
|
||||
const htmlGrammar = new WASMTreeSitterGrammar(
|
||||
atom.grammars,
|
||||
@ -2885,7 +2885,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
);
|
||||
|
||||
htmlGrammar.addInjectionPoint(SCRIPT_TAG_INJECTION_POINT);
|
||||
await htmlGrammar.setQueryForTest('syntaxQuery', ';');
|
||||
await htmlGrammar.setQueryForTest('highlightsQuery', ';');
|
||||
|
||||
atom.grammars.addGrammar(jsGrammar);
|
||||
atom.grammars.addGrammar(htmlGrammar);
|
||||
@ -3030,7 +3030,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
it('expands and contracts the selection based on the syntax tree', async () => {
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(program) @source
|
||||
`);
|
||||
|
||||
@ -3079,7 +3079,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
it('handles injected languages', async () => {
|
||||
const jsGrammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await jsGrammar.setQueryForTest('syntaxQuery', `
|
||||
await jsGrammar.setQueryForTest('highlightsQuery', `
|
||||
(property_identifier) @property
|
||||
(call_expression (identifier) @function)
|
||||
(template_string) @string
|
||||
@ -3094,7 +3094,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
htmlGrammarPath,
|
||||
htmlConfig
|
||||
);
|
||||
await htmlGrammar.setQueryForTest('syntaxQuery', `
|
||||
await htmlGrammar.setQueryForTest('highlightsQuery', `
|
||||
(fragment) @html
|
||||
(tag_name) @tag
|
||||
(attribute_name) @attr
|
||||
@ -3139,7 +3139,7 @@ describe('WASMTreeSitterLanguageMode', () => {
|
||||
it('returns a shimmed TokenizedLine with tokens', async () => {
|
||||
const grammar = new WASMTreeSitterGrammar(atom.grammars, jsGrammarPath, jsConfig);
|
||||
|
||||
await grammar.setQueryForTest('syntaxQuery', `
|
||||
await grammar.setQueryForTest('highlightsQuery', `
|
||||
(program) @source
|
||||
|
||||
(call_expression
|
||||
|
@ -99,8 +99,8 @@ module.exports = class WASMTreeSitterGrammar {
|
||||
}
|
||||
|
||||
async loadQueryFiles(grammarPath, queryPaths) {
|
||||
if (!('syntaxQuery' in queryPaths)) {
|
||||
throw new Error(`Syntax query must be present`);
|
||||
if (!('highlightsQuery' in queryPaths)) {
|
||||
throw new Error(`Highlights query must be present`);
|
||||
}
|
||||
|
||||
if (this._loadQueryFilesPromise) {
|
||||
@ -260,7 +260,7 @@ module.exports = class WASMTreeSitterGrammar {
|
||||
//
|
||||
// - `filePath`: The path to the query file on disk.
|
||||
// - `queryType`: The type of query file, as denoted by its configuration key
|
||||
// in the grammar file. One of `syntaxQuery`, `indentsQuery`,
|
||||
// in the grammar file. One of `highlightsQuery`, `indentsQuery`,
|
||||
// `foldsQuery`, or `localsQuery`.
|
||||
onDidChangeQueryFile(callback) {
|
||||
return this.emitter.on('did-change-query-file', callback);
|
||||
@ -339,7 +339,7 @@ module.exports = class WASMTreeSitterGrammar {
|
||||
// modern-tree-sitter. But modern-tree-sitter grammars cannot be injected
|
||||
// into by legacy-tree-sitter-grammars, and vice versa.
|
||||
//
|
||||
addInjectionPoint (injectionPoint) {
|
||||
addInjectionPoint(injectionPoint) {
|
||||
let { type } = injectionPoint;
|
||||
let injectionPoints = this.injectionPointsByType[type];
|
||||
if (!injectionPoints) {
|
||||
|
@ -2759,14 +2759,14 @@ class LanguageLayer {
|
||||
// off this promise. We can `await this.languageLoaded` later on.
|
||||
this.languageLoaded = this.grammar.getLanguage().then(language => {
|
||||
this.language = language;
|
||||
// TODO: Currently, we require a syntax query, but we might want to
|
||||
// TODO: Currently, we require a highlights query, but we might want to
|
||||
// rethink this. There are use cases for treating the root layer merely
|
||||
// as a way to delegate to injections, in which case syntax highlighting
|
||||
// wouldn't be needed.
|
||||
return this.grammar.getQuery('syntaxQuery').then(syntaxQuery => {
|
||||
this.syntaxQuery = syntaxQuery;
|
||||
return this.grammar.getQuery('highlightsQuery').then(highlightsQuery => {
|
||||
this.highlightsQuery = highlightsQuery;
|
||||
}).catch(() => {
|
||||
throw new GrammarLoadError(grammar, 'syntaxQuery');
|
||||
throw new GrammarLoadError(grammar, 'highlightsQuery');
|
||||
});
|
||||
}).then(() => {
|
||||
// All other queries are optional. Regular expression language layers,
|
||||
@ -2907,7 +2907,7 @@ class LanguageLayer {
|
||||
// through a `ScopeResolver`.
|
||||
getSyntaxBoundaries(from, to) {
|
||||
let { buffer } = this.languageMode;
|
||||
if (!(this.language && this.tree && this.syntaxQuery)) {
|
||||
if (!(this.language && this.tree && this.highlightsQuery)) {
|
||||
return [[], new OpenScopeMap()];
|
||||
}
|
||||
|
||||
@ -2917,7 +2917,7 @@ class LanguageLayer {
|
||||
let boundaries = createTree(comparePoints);
|
||||
let extent = this.getExtent();
|
||||
|
||||
const captures = this.syntaxQuery.captures(this.tree.rootNode, from, to);
|
||||
const captures = this.highlightsQuery.captures(this.tree.rootNode, from, to);
|
||||
this.scopeResolver.reset();
|
||||
|
||||
for (let capture of captures) {
|
||||
@ -3592,7 +3592,7 @@ class LanguageLayer {
|
||||
|
||||
// If the cursor is resting before column X, we want all scopes that cover
|
||||
// the character in column X.
|
||||
let captures = this.syntaxQuery.captures(
|
||||
let captures = this.highlightsQuery.captures(
|
||||
this.tree.rootNode,
|
||||
point,
|
||||
{ row: point.row, column: point.column + 1 }
|
||||
|
Loading…
Reference in New Issue
Block a user