Skip to content

Commit 25ae9b1

Browse files
OrdovizFrederik Vestre
authored andcommitted
Update tree-sitter-java and add Java textobjects (helix-editor#4886)
1 parent 24a643f commit 25ae9b1

File tree

5 files changed

+55
-5
lines changed

5 files changed

+55
-5
lines changed

book/src/generated/lang-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
| idris | | | | `idris2-lsp` |
5757
| iex || | | |
5858
| ini || | | |
59-
| java || | | `jdtls` |
59+
| java || | | `jdtls` |
6060
| javascript |||| `typescript-language-server` |
6161
| jsdoc || | | |
6262
| json || || `vscode-json-language-server` |

languages.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ indent = { tab-width = 4, unit = " " }
617617

618618
[[grammar]]
619619
name = "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" }
621621

622622
[[language]]
623623
name = "ledger"

runtime/queries/java/highlights.scm

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
name: (identifier) @type)
2222
(class_declaration
2323
name: (identifier) @type)
24+
(record_declaration
25+
name: (identifier) @type)
2426
(enum_declaration
2527
name: (identifier) @type)
2628

@@ -33,6 +35,8 @@
3335

3436
(constructor_declaration
3537
name: (identifier) @type)
38+
(compact_constructor_declaration
39+
name: (identifier) @type)
3640

3741
(type_identifier) @type
3842

@@ -59,6 +63,7 @@
5963
(hex_integer_literal)
6064
(decimal_integer_literal)
6165
(octal_integer_literal)
66+
(binary_integer_literal)
6267
] @constant.numeric.integer
6368

6469
[
@@ -67,15 +72,20 @@
6772
] @constant.numeric.float
6873

6974
(character_literal) @constant.character
70-
(string_literal) @string
75+
76+
[
77+
(string_literal)
78+
(text_block)
79+
] @string
7180

7281
[
7382
(true)
7483
(false)
7584
(null_literal)
7685
] @constant.builtin
7786

78-
(comment) @comment
87+
(line_comment) @comment
88+
(block_comment) @comment
7989

8090
; Keywords
8191

@@ -104,15 +114,19 @@
104114
"module"
105115
"native"
106116
"new"
117+
"non-sealed"
107118
"open"
108119
"opens"
109120
"package"
121+
"permits"
110122
"private"
111123
"protected"
112124
"provides"
113125
"public"
114126
"requires"
127+
"record"
115128
"return"
129+
"sealed"
116130
"static"
117131
"strictfp"
118132
"switch"
@@ -127,4 +141,5 @@
127141
"volatile"
128142
"while"
129143
"with"
144+
"yield"
130145
] @keyword

runtime/queries/java/injections.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
((comment) @injection.content
1+
([(line_comment) (block_comment)] @injection.content
22
(#set! injection.language "comment"))

runtime/queries/java/textobjects.scm

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)