Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional highlight fixes #70

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 16 additions & 32 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
(dotted_identifier_list) @string

; Methods
; --------------------
(super) @function

(function_expression_body
(identifier) @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
Expand Down Expand Up @@ -65,6 +59,7 @@
">="
"<="
"||"
"~/"
(increment_operator)
(is_operator)
(prefix_operator)
Expand All @@ -82,13 +77,13 @@

; Types
; --------------------
((type_identifier) @type.builtin
(#match? @type.builtin "^(int|double|String|bool|List|Set|Map|Runes|Symbol)$"))
(type_identifier) @type
(class_definition
name: (identifier) @type)
(constructor_signature
name: (identifier) @type)
;; TODO: does not work
;(type_identifier
;(identifier) @type)
(scoped_identifier
scope: (identifier) @type)
(function_signature
Expand All @@ -104,8 +99,6 @@
name: (identifier) @type)
(#match? @type "^[a-zA-Z]"))

(type_identifier) @type

; Enums
; -------------------
(enum_declaration
Expand All @@ -126,17 +119,14 @@
(this) @variable.builtin

; properties
(expression_statement
(selector
(unconditional_assignable_selector
(identifier) @function))
((selector
(unconditional_assignable_selector (identifier) @function))
(selector (argument_part (arguments)))
)
(expression_statement
(cascade_section
(cascade_selector (identifier) @function)
(argument_part (arguments))
)

(cascade_section
(cascade_selector (identifier) @function)
(argument_part (arguments))
)

(unconditional_assignable_selector
Expand All @@ -158,10 +148,10 @@
; Parameters
; --------------------
(formal_parameter
name: (identifier) @parameter)
name: (identifier) @identifier.parameter)

(named_argument
(label (identifier) @parameter))
(label (identifier) @identifier.parameter))

; Literals
; --------------------
Expand All @@ -174,11 +164,11 @@
; (hex_floating_point_literal)
] @number

(symbol_literal) @symbol
(string_literal) @string
(symbol_literal (identifier) @constant) @constant
(true) @boolean
(false) @boolean
(null_literal) @constant.builtin
(null_literal) @constant.null

(documentation_comment) @comment
(comment) @comment
Expand All @@ -187,7 +177,7 @@
; --------------------
[
(assert_builtin)
(break_statement)
(break_builtin)
(const_builtin)
(part_of_builtin)
(rethrow_builtin)
Expand All @@ -214,7 +204,6 @@
"extension"
"external"
"factory"
"false"
"final"
"finally"
"for"
Expand All @@ -231,7 +220,6 @@
"library"
"mixin"
"new"
"null"
"on"
"operator"
"part"
Expand All @@ -245,7 +233,6 @@
"switch"
"sync*"
"throw"
"true"
"try"
"typedef"
"var"
Expand All @@ -256,7 +243,4 @@
] @keyword

; Variable
(identifier) @variable

; Error
(ERROR) @error
(identifier) @variable
5 changes: 2 additions & 3 deletions test/corpus/errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ final a = StateProvider<T12345678> // Complete expression is: final a = StateP

---


(ERROR
(final_builtin)
(identifier)
(type_identifier)
(type_arguments
(type_identifier))
(comment)
(comment))
(comment)
(comment))
4 changes: 2 additions & 2 deletions test/highlight/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Person {

Person(String name) {
// <- type
// ^ type
// ^ type.builtin
this.name = name;
this.pants = new Pants<Pocket>();
// ^ type
Expand All @@ -22,7 +22,7 @@ class Person {
// ^ variable.builtin

String getName() {
// <- type
// <- type.builtin
// ^ function
return this.name;

Expand Down