on master help sign in
Update tree-sitter-java and add Java textobjects (#4886)
fc81172Lennard Hofmann
book/src/generated/lang-support.md+1−1
@@ -56,7 +56,7 @@
56| idris | | | | `idris2-lsp` |
56| idris | | | | `idris2-lsp` |
57| iex | ✓ | | | |
57| iex | ✓ | | | |
58| ini | ✓ | | | |
58| ini | ✓ | | | |
59−| java | ✓ | | | `jdtls` |
59+| java | ✓ | ✓ | | `jdtls` |
60| javascript | ✓ | ✓ | ✓ | `typescript-language-server` |
60| javascript | ✓ | ✓ | ✓ | `typescript-language-server` |
61| jsdoc | ✓ | | | |
61| jsdoc | ✓ | | | |
62| json | ✓ | | ✓ | `vscode-json-language-server` |
62| json | ✓ | | ✓ | `vscode-json-language-server` |
languages.toml+1−1
@@ -617,7 +617,7 @@ indent = { tab-width = 4, unit = " " }
617
617
618[[grammar]]
618[[grammar]]
619name = "java"
619name = "java"
620−source = { git = "https://github.com/tree-sitter/tree-sitter-java", rev = "bd6186c24d5eb13b4623efac9d944dcc095c0dad" }
620+source = { git = "https://github.com/tree-sitter/tree-sitter-java", rev = "09d650def6cdf7f479f4b78f595e9ef5b58ce31e" }
621
621
622[[language]]
622[[language]]
623name = "ledger"
623name = "ledger"
runtime/queries/java/highlights.scm+17−2
@@ -21,6 +21,8 @@
21 name: (identifier) @type)
21 name: (identifier) @type)
22(class_declaration
22(class_declaration
23 name: (identifier) @type)
23 name: (identifier) @type)
24+(record_declaration
25+ name: (identifier) @type)
24(enum_declaration
26(enum_declaration
25 name: (identifier) @type)
27 name: (identifier) @type)
26
28
@@ -33,6 +35,8 @@
33
35
34(constructor_declaration
36(constructor_declaration
35 name: (identifier) @type)
37 name: (identifier) @type)
38+(compact_constructor_declaration
39+ name: (identifier) @type)
36
40
37(type_identifier) @type
41(type_identifier) @type
38
42
@@ -59,6 +63,7 @@
59 (hex_integer_literal)
63 (hex_integer_literal)
60 (decimal_integer_literal)
64 (decimal_integer_literal)
61 (octal_integer_literal)
65 (octal_integer_literal)
66+ (binary_integer_literal)
62] @constant.numeric.integer
67] @constant.numeric.integer
63
68
64[
69[
@@ -67,7 +72,11 @@
67] @constant.numeric.float
72] @constant.numeric.float
68
73
69(character_literal) @constant.character
74(character_literal) @constant.character
75+
76+[
70−(string_literal) @string
77+ (string_literal)
78+ (text_block)
79+] @string
71
80
72[
81[
73 (true)
82 (true)
@@ -75,7 +84,8 @@
75 (null_literal)
84 (null_literal)
76] @constant.builtin
85] @constant.builtin
77
86
78−(comment) @comment
87+(line_comment) @comment
88+(block_comment) @comment
79
89
80; Keywords
90; Keywords
81
91
@@ -104,15 +114,19 @@
104 "module"
114 "module"
105 "native"
115 "native"
106 "new"
116 "new"
117+ "non-sealed"
107 "open"
118 "open"
108 "opens"
119 "opens"
109 "package"
120 "package"
121+ "permits"
110 "private"
122 "private"
111 "protected"
123 "protected"
112 "provides"
124 "provides"
113 "public"
125 "public"
114 "requires"
126 "requires"
127+ "record"
115 "return"
128 "return"
129+ "sealed"
116 "static"
130 "static"
117 "strictfp"
131 "strictfp"
118 "switch"
132 "switch"
@@ -127,4 +141,5 @@
127 "volatile"
141 "volatile"
128 "while"
142 "while"
129 "with"
143 "with"
144+ "yield"
130] @keyword
145] @keyword
runtime/queries/java/injections.scm+1−1
@@ -1,2 +1,2 @@
1−((comment) @injection.content
1+([(line_comment) (block_comment)] @injection.content
2 (#set! injection.language "comment"))
2 (#set! injection.language "comment"))
runtime/queries/java/textobjects.scmnew file+35
@@ -0,0 +1,35 @@
1+(method_declaration
2+ body: (_) @function.inside) @function.around
3+
4+(interface_declaration
5+ body: (_) @class.inside) @class.around
6+
7+(class_declaration
8+ body: (_) @class.inside) @class.around
9+
10+(record_declaration
11+ body: (_) @class.inside) @class.around
12+
13+(enum_declaration
14+ body: (_) @class.inside) @class.around
15+
16+(formal_parameters
17+ ((_) @parameter.inside . ","? @parameter.around) @parameter.around)
18+
19+(type_parameters
20+ ((_) @parameter.inside . ","? @parameter.around) @parameter.around)
21+
22+(type_arguments
23+ ((_) @parameter.inside . ","? @parameter.around) @parameter.around)
24+
25+(argument_list
26+ ((_) @parameter.inside . ","? @parameter.around) @parameter.around)
27+
28+[
29+ (line_comment)
30+ (block_comment)
31+] @comment.inside
32+
33+(line_comment)+ @comment.around
34+
35+(block_comment) @comment.around