1; Methods
2
3(method_declaration
4  name: (identifier) @function.method)
5(method_invocation
6  name: (identifier) @function.method)
7(super) @function.builtin
8
9; Annotations
10
11(annotation
12  name: (identifier) @attribute)
13(marker_annotation
14  name: (identifier) @attribute)
15
16"@" @operator
17
18; Types
19
20(interface_declaration
21  name: (identifier) @type)
22(class_declaration
23  name: (identifier) @type)
24(enum_declaration
25  name: (identifier) @type)
26
27((field_access
28  object: (identifier) @type)
29 (#match? @type "^[A-Z]"))
30((scoped_identifier
31  scope: (identifier) @type)
32 (#match? @type "^[A-Z]"))
33
34(constructor_declaration
35  name: (identifier) @type)
36
37(type_identifier) @type
38
39[
40  (boolean_type)
41  (integral_type)
42  (floating_point_type)
43  (floating_point_type)
44  (void_type)
45] @type.builtin
46
47; Variables
48
49((identifier) @constant
50 (#match? @constant "^_*[A-Z][A-Z\d_]+"))
51
52(identifier) @variable
53
54(this) @variable.builtin
55
56; Literals
57
58[
59  (hex_integer_literal)
60  (decimal_integer_literal)
61  (octal_integer_literal)
62  (decimal_floating_point_literal)
63  (hex_floating_point_literal)
64] @number
65
66[
67  (character_literal)
68  (string_literal)
69] @string
70
71[
72  (true)
73  (false)
74  (null_literal)
75] @constant.builtin
76
77(comment) @comment
78
79; Keywords
80
81[
82  "abstract"
83  "assert"
84  "break"
85  "case"
86  "catch"
87  "class"
88  "continue"
89  "default"
90  "do"
91  "else"
92  "enum"
93  "exports"
94  "extends"
95  "final"
96  "finally"
97  "for"
98  "if"
99  "implements"
100  "import"
101  "instanceof"
102  "interface"
103  "module"
104  "native"
105  "new"
106  "open"
107  "opens"
108  "package"
109  "private"
110  "protected"
111  "provides"
112  "public"
113  "requires"
114  "return"
115  "static"
116  "strictfp"
117  "switch"
118  "synchronized"
119  "throw"
120  "throws"
121  "to"
122  "transient"
123  "transitive"
124  "try"
125  "uses"
126  "volatile"
127  "while"
128  "with"
129] @keyword
130