Java highlights: Capture parameters in declaration (#93)

* Capture parameters in declaration

* Refactor (new syntax)

* Fix spaces

* Fix capture (java method parameters)

* Improve java parameter capture

* Fix bracket and whitespace

* Fix java query

* Fix java query

Co-authored-by: Thomas Vigouroux <39092278+vigoux@users.noreply.github.com>

* Add capture for lambda parameters, remove redundant captures, add -> operator

* Previous commit wasn't saved properly

* Fix formatting

* Changes suggested in PR

https://github.com/nvim-treesitter/nvim-treesitter/pull/93#pullrequestreview-435630553

* Add bitwise operators

* Re-add builtin operators

* remove left shift, add ^=

* Add &= and |=

* remove @variable

* Remove duplicate

Co-authored-by: Thomas Vigouroux <39092278+vigoux@users.noreply.github.com>
This commit is contained in:
Chinmay Dalal 2020-06-29 14:18:13 +05:30 committed by GitHub
parent 54438439e6
commit b184f1cafb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,20 +2,32 @@
; Methods ; Methods
(method_declaration (method_declaration
name: (identifier) @method) name: (identifier) @method)
(method_invocation (method_invocation
name: (identifier) @method) name: (identifier) @method)
(super) @function.builtin (super) @function.builtin
; Parameters
(formal_parameter
name: (identifier) @parameter)
(inferred_parameters (identifier) @parameter)
; Annotations ; Annotations
(annotation (annotation
name: (identifier) @attribute) name: (identifier) @attribute)
(marker_annotation (marker_annotation
name: (identifier) @attribute) name: (identifier) @attribute)
; Operators ; Operators
[ [
"@" "@"
"+" "+"
@ -41,6 +53,15 @@
"*=" "*="
"/=" "/="
"%=" "%="
"->"
"^"
"^="
"&="
"|="
"~"
">>"
">>>"
"<<"
] @operator ] @operator
; Types ; Types
@ -51,40 +72,46 @@
name: (identifier) @type) name: (identifier) @type)
(enum_declaration (enum_declaration
name: (identifier) @type) name: (identifier) @type)
(constructor_declaration
name: (identifier) @type)
(type_identifier) @type
((field_access ((field_access
object: (identifier) @type) object: (identifier) @type)
(#match? @type "^[A-Z]")) (#match? @type "^[A-Z]"))
((scoped_identifier ((scoped_identifier
scope: (identifier) @type) scope: (identifier) @type)
(#match? @type "^[A-Z]")) (#match? @type "^[A-Z]"))
(constructor_declaration [
name: (identifier) @type) (boolean_type)
(integral_type)
(type_identifier) @type (floating_point_type)
(boolean_type) @type.builtin (void_type)
(integral_type) @type.builtin ] @type.builtin
(floating_point_type) @type.builtin
(floating_point_type) @type.builtin
(void_type) @type.builtin
; Variables ; Variables
((identifier) @constant ((identifier) @constant
(#match? @constant "^_*[A-Z][A-Z\d_]+")) (#match? @constant "^_*[A-Z][A-Z\d_]+"))
(identifier) @variable
(this) @variable.builtin
; Literals ; Literals
(hex_integer_literal) @number [
(decimal_integer_literal) @number (hex_integer_literal)
(octal_integer_literal) @number (decimal_integer_literal)
(decimal_floating_point_literal) @float (octal_integer_literal)
(hex_floating_point_literal) @float ] @number
[
(decimal_floating_point_literal)
(hex_floating_point_literal)
] @float
(character_literal) @character (character_literal) @character
(string_literal) @string (string_literal) @string
(null_literal) @constant.builtin (null_literal) @constant.builtin
@ -106,7 +133,6 @@
"class" "class"
"continue" "continue"
"default" "default"
"do"
"enum" "enum"
"exports" "exports"
"extends" "extends"
@ -150,25 +176,32 @@
"case" "case"
] @conditional ] @conditional
; ;
[ [
"for" "for"
"while" "while"
"do"
] @repeat ] @repeat
; ; Includes
"import" @include "import" @include
"package" @include
; Punctuation ; Punctuation
";" @punctuation.delimiter [
"." @punctuation.delimiter ";"
"," @punctuation.delimiter "."
"[" @punctuation.bracket ","
"]" @punctuation.bracket ] @punctuation.delimiter
"{" @punctuation.bracket
"}" @punctuation.bracket [
"(" @punctuation.bracket "["
")" @punctuation.bracket "]"
"{"
"}"
"("
")"
] @punctuation.bracket