fix(dart): more highlight coverage, import folds

This commit is contained in:
Riley Bruins 2024-10-07 10:42:58 -07:00 committed by Christian Clason
parent 45e0d66246
commit 18adcafad0
2 changed files with 39 additions and 13 deletions

View file

@ -9,4 +9,5 @@
(list_literal) (list_literal)
(set_or_map_literal) (set_or_map_literal)
(string_literal) (string_literal)
(import_or_export)+
] @fold ] @fold

View file

@ -1,27 +1,28 @@
(identifier) @variable
(dotted_identifier_list) @string (dotted_identifier_list) @string
; Methods ; Methods
; -------------------- ; --------------------
(super) @function
; TODO: add method/call_expression to grammar and ; TODO: add method/call_expression to grammar and
; distinguish method call from variable access ; distinguish method call from variable access
(function_expression_body (function_expression_body
(identifier) @function) (identifier) @function.call)
; ((identifier)(selector (argument_part)) @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 ; 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 ; specifically identify a node as a function call
(((identifier) @function (((identifier) @function.call
(#lua-match? @function "^_?[%l]")) (#lua-match? @function.call "^_?[%l]"))
. .
(selector (selector
. .
(argument_part))) @function (argument_part))) @function.call
; Annotations ; Annotations
; -------------------- ; --------------------
(annotation (annotation
"@" @attribute
name: (identifier) @attribute) name: (identifier) @attribute)
; Operators and Tokens ; Operators and Tokens
@ -38,13 +39,12 @@
(escape_sequence) @string.escape (escape_sequence) @string.escape
[ [
"@"
"=>" "=>"
".." ".."
"??" "??"
"==" "=="
"!"
"?" "?"
":"
"&&" "&&"
"%" "%"
"<" "<"
@ -53,6 +53,20 @@
">=" ">="
"<=" "<="
"||" "||"
">>>="
">>="
"<<="
"&="
"|="
"??="
"%="
"+="
"-="
"*="
"/="
"^="
"~/="
(shift_operator)
(multiplicative_operator) (multiplicative_operator)
(increment_operator) (increment_operator)
(is_operator) (is_operator)
@ -76,6 +90,9 @@
";" ";"
"." "."
"," ","
":"
"?."
"?"
] @punctuation.delimiter ] @punctuation.delimiter
; Types ; Types
@ -116,6 +133,12 @@
(type_alias (type_alias
(type_identifier) @type.definition) (type_identifier) @type.definition)
(type_arguments
[
"<"
">"
] @punctuation.bracket)
; Variables ; Variables
; -------------------- ; --------------------
; var keyword ; var keyword
@ -133,16 +156,12 @@
(conditional_assignable_selector (conditional_assignable_selector
(identifier) @property) (identifier) @property)
; assignments
(assignment_expression
left: (assignable_expression) @variable)
(this) @variable.builtin (this) @variable.builtin
; Parameters ; Parameters
; -------------------- ; --------------------
(formal_parameter (formal_parameter
name: (identifier) @variable.parameter) (identifier) @variable.parameter)
(named_argument (named_argument
(label (label
@ -263,6 +282,12 @@
"default" "default"
] @keyword.conditional ] @keyword.conditional
(conditional_expression
[
"?"
":"
] @keyword.conditional.ternary)
[ [
"try" "try"
"throw" "throw"