chore: query formatting

This commit is contained in:
Pham Huy Hoang 2024-01-06 15:05:50 +09:00 committed by Christian Clason
parent 79975d6557
commit 57a8acf0c4
674 changed files with 18466 additions and 12648 deletions

View file

@ -2,13 +2,10 @@
(class_definition)
(enum_declaration)
(extension_declaration)
(arguments)
(function_body)
(block)
(switch_block)
(list_literal)
(set_or_map_literal)
(string_literal)

View file

@ -1,18 +1,21 @@
(dotted_identifier_list) @string
; Methods
; --------------------
(super) @function
; TODO: add method/call_expression to grammar and
; distinguish method call from variable access
(function_expression_body (identifier) @function)
; ((identifier)(selector (argument_part)) @function)
(function_expression_body
(identifier) @function)
; ((identifier)(selector (argument_part)) @function)
; NOTE: This query is a bit of a work around for the fact that the dart grammar doesn't
; specifically identify a node as a function call
(((identifier) @function (#lua-match? @function "^_?[%l]"))
. (selector . (argument_part))) @function
(((identifier) @function
(#lua-match? @function "^_?[%l]")).
(selector
.
(argument_part))) @function
; Annotations
; --------------------
@ -24,38 +27,36 @@
(template_substitution
"$" @punctuation.special
"{" @punctuation.special
"}" @punctuation.special
) @none
"}" @punctuation.special) @none
(template_substitution
"$" @punctuation.special
(identifier_dollar_escaped) @variable
) @none
(identifier_dollar_escaped) @variable) @none
(escape_sequence) @string.escape
[
"@"
"=>"
".."
"??"
"=="
"?"
":"
"&&"
"%"
"<"
">"
"="
">="
"<="
"||"
(multiplicative_operator)
(increment_operator)
(is_operator)
(prefix_operator)
(equality_operator)
(additive_operator)
"@"
"=>"
".."
"??"
"=="
"?"
":"
"&&"
"%"
"<"
">"
"="
">="
"<="
"||"
(multiplicative_operator)
(increment_operator)
(is_operator)
(prefix_operator)
(equality_operator)
(additive_operator)
] @operator
[
@ -65,7 +66,7 @@
"]"
"{"
"}"
] @punctuation.bracket
] @punctuation.bracket
; Delimiters
; --------------------
@ -79,26 +80,34 @@
; --------------------
(class_definition
name: (identifier) @type)
(constructor_signature
name: (identifier) @type)
(scoped_identifier
scope: (identifier) @type)
(function_signature
name: (identifier) @function.method)
(getter_signature
(identifier) @function.method)
(setter_signature
name: (identifier) @function.method)
(enum_declaration
name: (identifier) @type)
(enum_constant
name: (identifier) @type)
(void_type) @type
((scoped_identifier
scope: (identifier) @type
name: (identifier) @type)
(#lua-match? @type "^[%u%l]"))
(#lua-match? @type "^[%u%l]"))
(type_identifier) @type
@ -111,7 +120,7 @@
(inferred_type) @keyword
((identifier) @type
(#lua-match? @type "^_?[%u].*[%l]")) ; catch Classes or IClasses not CLASSES
(#lua-match? @type "^_?[%u].*[%l]")) ; catch Classes or IClasses not CLASSES
("Function" @type)
@ -131,29 +140,35 @@
; Parameters
; --------------------
(formal_parameter
name: (identifier) @variable.parameter)
name: (identifier) @variable.parameter)
(named_argument
(label (identifier) @variable.parameter))
(label
(identifier) @variable.parameter))
; Literals
; --------------------
[
(hex_integer_literal)
(decimal_integer_literal)
(decimal_floating_point_literal)
; TODO: inaccessible nodes
; (octal_integer_literal)
; (hex_floating_point_literal)
(hex_integer_literal)
(decimal_integer_literal)
(decimal_floating_point_literal)
; TODO: inaccessible nodes
; (octal_integer_literal)
; (hex_floating_point_literal)
] @number
(symbol_literal) @string.special.symbol
(string_literal) @string
(true) @boolean
(false) @boolean
(null_literal) @constant.builtin
(comment) @comment @spell
(documentation_comment) @comment.documentation @spell
; Keywords
@ -169,47 +184,44 @@
; Reserved words (cannot be used as identifiers)
[
; TODO:
; "rethrow" cannot be targeted at all and seems to be an invisible node
; TODO:
; the assert keyword cannot be specifically targeted
; because the grammar selects the whole node or the content
; of the assertion not just the keyword
; assert
(case_builtin)
"late"
"required"
"extension"
"on"
"class"
"enum"
"extends"
"in"
"is"
"new"
"super"
"with"
; TODO:
; "rethrow" cannot be targeted at all and seems to be an invisible node
; TODO:
; the assert keyword cannot be specifically targeted
; because the grammar selects the whole node or the content
; of the assertion not just the keyword
; assert
(case_builtin)
"late"
"required"
"extension"
"on"
"class"
"enum"
"extends"
"in"
"is"
"new"
"super"
"with"
] @keyword
[
"return"
] @keyword.return
"return" @keyword.return
; Built in identifiers:
; alone these are marked as keywords
[
"deferred"
"factory"
"get"
"implements"
"interface"
"library"
"operator"
"mixin"
"part"
"set"
"typedef"
"deferred"
"factory"
"get"
"implements"
"interface"
"library"
"operator"
"mixin"
"part"
"set"
"typedef"
] @keyword
[
@ -221,43 +233,28 @@
] @keyword.coroutine
[
(const_builtin)
(final_builtin)
"abstract"
"covariant"
"dynamic"
"external"
"static"
"final"
"base"
"sealed"
(const_builtin)
(final_builtin)
"abstract"
"covariant"
"dynamic"
"external"
"static"
"final"
"base"
"sealed"
] @type.qualifier
; when used as an identifier:
((identifier) @variable.builtin
(#any-of? @variable.builtin
"abstract"
"as"
"covariant"
"deferred"
"dynamic"
"export"
"external"
"factory"
"Function"
"get"
"implements"
"import"
"interface"
"library"
"operator"
"mixin"
"part"
"set"
"static"
"typedef"))
(#any-of? @variable.builtin "abstract" "as" "covariant" "deferred" "dynamic" "export" "external" "factory" "Function" "get" "implements" "import" "interface" "library" "operator" "mixin" "part" "set" "static" "typedef"))
["if" "else" "switch" "default"] @keyword.conditional
[
"if"
"else"
"switch"
"default"
] @keyword.conditional
[
"try"
@ -267,4 +264,9 @@
(break_statement)
] @keyword.exception
["do" "while" "continue" "for"] @keyword.repeat
[
"do"
"while"
"continue"
"for"
] @keyword.repeat

View file

@ -2,7 +2,8 @@
(class_body)
(function_body)
(function_expression_body)
(declaration (initializers))
(declaration
(initializers))
(switch_block)
(if_statement)
(formal_parameter_list)
@ -32,14 +33,16 @@
"]"
] @indent.branch
[
"}"
] @indent.end
"}" @indent.end
(return_statement ";" @indent.end)
(break_statement ";" @indent.end)
(return_statement
";" @indent.end)
(break_statement
";" @indent.end)
; this one is for dedenting the else block
(if_statement (block) @indent.branch)
(if_statement
(block) @indent.branch)
(comment) @indent.ignore

View file

@ -1,2 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))
((comment) @injection.content
(#set! injection.language "comment"))

View file

@ -1,5 +1,4 @@
;; Definitions
; Definitions
(function_signature
name: (identifier) @local.definition.function)
@ -15,20 +14,19 @@
(static_final_declaration
(identifier) @local.definition.var)
;; References
; References
(identifier) @local.reference
;; Scopes
; Scopes
(class_definition
body: (_) @local.scope)
[
(block)
(if_statement)
(for_statement)
(while_statement)
(try_statement)
(catch_clause)
(finally_clause)
(block)
(if_statement)
(for_statement)
(while_statement)
(try_statement)
(catch_clause)
(finally_clause)
] @local.scope