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

Update tree-sitter-java and add Java textobjects #4886

Merged
merged 1 commit into from
Nov 26, 2022
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
2 changes: 1 addition & 1 deletion book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
| idris | | | | `idris2-lsp` |
| iex | ✓ | | | |
| ini | ✓ | | | |
| java | ✓ | | | `jdtls` |
| java | ✓ | | | `jdtls` |
| javascript | ✓ | ✓ | ✓ | `typescript-language-server` |
| jsdoc | ✓ | | | |
| json | ✓ | | ✓ | `vscode-json-language-server` |
Expand Down
2 changes: 1 addition & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ indent = { tab-width = 4, unit = " " }

[[grammar]]
name = "java"
source = { git = "https://github.com/tree-sitter/tree-sitter-java", rev = "bd6186c24d5eb13b4623efac9d944dcc095c0dad" }
source = { git = "https://github.com/tree-sitter/tree-sitter-java", rev = "09d650def6cdf7f479f4b78f595e9ef5b58ce31e" }

[[language]]
name = "ledger"
Expand Down
19 changes: 17 additions & 2 deletions runtime/queries/java/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
name: (identifier) @type)
(class_declaration
name: (identifier) @type)
(record_declaration
name: (identifier) @type)
(enum_declaration
name: (identifier) @type)

Expand All @@ -33,6 +35,8 @@

(constructor_declaration
name: (identifier) @type)
(compact_constructor_declaration
name: (identifier) @type)

(type_identifier) @type

Expand All @@ -59,6 +63,7 @@
(hex_integer_literal)
(decimal_integer_literal)
(octal_integer_literal)
(binary_integer_literal)
] @constant.numeric.integer

[
Expand All @@ -67,15 +72,20 @@
] @constant.numeric.float

(character_literal) @constant.character
(string_literal) @string

[
(string_literal)
(text_block)
] @string

[
(true)
(false)
(null_literal)
] @constant.builtin

(comment) @comment
(line_comment) @comment
(block_comment) @comment

; Keywords

Expand Down Expand Up @@ -104,15 +114,19 @@
"module"
"native"
"new"
"non-sealed"
"open"
"opens"
"package"
"permits"
"private"
"protected"
"provides"
"public"
"requires"
"record"
"return"
"sealed"
"static"
"strictfp"
"switch"
Expand All @@ -127,4 +141,5 @@
"volatile"
"while"
"with"
"yield"
] @keyword
2 changes: 1 addition & 1 deletion runtime/queries/java/injections.scm
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
((comment) @injection.content
([(line_comment) (block_comment)] @injection.content
(#set! injection.language "comment"))
35 changes: 35 additions & 0 deletions runtime/queries/java/textobjects.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(method_declaration
body: (_) @function.inside) @function.around

(interface_declaration
body: (_) @class.inside) @class.around

(class_declaration
body: (_) @class.inside) @class.around

(record_declaration
body: (_) @class.inside) @class.around

(enum_declaration
body: (_) @class.inside) @class.around

(formal_parameters
((_) @parameter.inside . ","? @parameter.around) @parameter.around)

(type_parameters
((_) @parameter.inside . ","? @parameter.around) @parameter.around)

(type_arguments
((_) @parameter.inside . ","? @parameter.around) @parameter.around)

(argument_list
((_) @parameter.inside . ","? @parameter.around) @parameter.around)

[
(line_comment)
(block_comment)
] @comment.inside

(line_comment)+ @comment.around

(block_comment) @comment.around