Extend groovy support (#9677)

* Extend groovy support

Use more complete parser introduced in nvm-treesitter in
d4dac523d2

* Update runtime/queries/groovy/locals.scm

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

* Drop indent.scm for groovy

It was copied from the tree-sitter repository but is not
compatiblw with the way indent queries are implemented
in Helix.

* Adapt groovy highlights to helix syntax

* Update documentation

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
pull/8727/head^2
Benedikt Ritter 3 months ago committed by GitHub
parent 8457652da1
commit f7913c1a3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -3247,7 +3247,7 @@ indent = { tab-width = 2, unit = " " }
[[grammar]] [[grammar]]
name = "groovy" name = "groovy"
source = { git = "https://github.com/Decodetalkers/tree-sitter-groovy", rev = "7e023227f46fee428b16a0288eeb0f65ee2523ec" } source = { git = "https://github.com/murtaza64/tree-sitter-groovy", rev = "235009aad0f580211fc12014bb0846c3910130c1" }
[[language]] [[language]]
name = "fidl" name = "fidl"

@ -0,0 +1,6 @@
[
(argument_list)
(closure)
(list)
(map)
] @fold

@ -1,96 +1,268 @@
(unit [
(identifier) @variable) "!instanceof"
"assert"
"class"
"extends"
"instanceof"
"package"
] @keyword
(string [
(identifier) @variable) "!in"
"as"
"in"
] @keyword.operator
[
"case"
"default"
"else"
"if"
"switch"
] @keyword.control.conditional
(escape_sequence) @constant.character.escape [
"catch"
"finally"
"try"
] @keyword.control.exception
(block "def" @keyword.function
(unit
(identifier) @namespace))
(func "import" @keyword.control.import
(identifier) @function)
(number) @constant.numeric [
"for"
"while"
(break)
(continue)
] @keyword.control.repeat
((identifier) @constant.builtin.boolean "return" @keyword.control.return
(#any-of? @constant.builtin.boolean "true" "false"))
((identifier) @constant [
(#match? @constant "^[A-Z][A-Z\\d_]*$")) "true"
"false"
((identifier) @constant.builtin ] @constant.builtin.boolean
(#eq? @constant.builtin "null"))
(null) @constant.builtin
((identifier) @type
(#any-of? @type "this" @variable.builtin
"String"
"Map" [
"Object" "int"
"Boolean" "char"
"Integer" "short"
"List")) "long"
"boolean"
((identifier) @function.builtin "float"
(#any-of? @function.builtin "double"
"void" "void"
"id" ] @type.builtin
"version"
"apply" [
"implementation" "final"
"testImplementation" "private"
"androidTestImplementation" "protected"
"debugImplementation")) "public"
"static"
((identifier) @keyword.storage.modifier "synchronized"
(#eq? @keyword.storage.modifier "static")) ] @keyword.storage.modifier
((identifier) @keyword.storage.type (comment) @comment
(#any-of? @keyword.storage.type "class" "def" "interface"))
(shebang) @keyword.directive
((identifier) @keyword
(#any-of? @keyword
"assert"
"new"
"extends"
"implements"
"instanceof"))
((identifier) @keyword.control.import
(#any-of? @keyword.control.import "import" "package"))
((identifier) @keyword.storage.modifier
(#any-of? @keyword.storage.modifier
"abstract"
"protected"
"private"
"public"))
((identifier) @keyword.control.exception
(#any-of? @keyword.control.exception
"throw"
"finally"
"try"
"catch"))
(string) @string (string) @string
(string
(escape_sequence) @constant.character.escape)
(string
(interpolation
"$" @punctuation.special))
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
[ [
(line_comment) ":"
(block_comment) ","
] @comment "."
] @punctuation.delimiter
(number_literal) @constant.numeric
((block_comment) @comment.block.documentation (identifier) @variable
(#match? @comment.block.documentation "^/[*][*][^*](?s:.)*[*]/$"))
((line_comment) @comment.block.documentation ((identifier) @constant
(#match? @comment.block.documentation "^///[^/]*.*$")) (#match? @constant "^[A-Z][A-Z_]+"))
[ [
(operators) "%"
(leading_key) "*"
"/"
"+"
"-"
"<<"
">>"
">>>"
".."
"..<"
"<..<"
"<.."
"<"
"<="
">"
">="
"=="
"!="
"<=>"
"==="
"!=="
"=~"
"==~"
"&"
"^"
"|"
"&&"
"||"
"?:"
"+"
"*"
".&"
".@"
"?."
"*."
"*"
"*:"
"++"
"--"
"!"
] @operator ] @operator
["(" ")" "[" "]" "{" "}"] @punctuation.bracket (string
"/" @string)
(ternary_op
([
"?"
":"
]) @keyword.operator)
(map
(map_item
key: (identifier) @variable.parameter))
(parameter
type: (identifier) @type
name: (identifier) @variable.parameter)
(generic_param
name: (identifier) @variable.parameter)
(declaration
type: (identifier) @type)
(function_definition
type: (identifier) @type)
(function_declaration
type: (identifier) @type)
(class_definition
name: (identifier) @type)
(class_definition
superclass: (identifier) @type)
(generic_param
superclass: (identifier) @type)
(type_with_generics
(identifier) @type)
(type_with_generics
(generics
(identifier) @type))
(generics
[
"<"
">"
] @punctuation.bracket)
(generic_parameters
[
"<"
">"
] @punctuation.bracket)
; TODO: Class literals with PascalCase
(declaration
"=" @operator)
(assignment
"=" @operator)
(function_call
function: (identifier) @function)
(function_call
function:
(dotted_identifier
(identifier) @function .))
(function_call
(argument_list
(map_item
key: (identifier) @variable.parameter)))
(juxt_function_call
function: (identifier) @function)
(juxt_function_call
function:
(dotted_identifier
(identifier) @function .))
(juxt_function_call
(argument_list
(map_item
key: (identifier) @variable.parameter)))
(function_definition
function: (identifier) @function)
(function_declaration
function: (identifier) @function)
(annotation) @function.macro
(annotation
(identifier) @function.macro)
"@interface" @function.macro
(groovy_doc) @comment.block.documentation
(groovy_doc
[
(groovy_doc_param)
(groovy_doc_throws)
(groovy_doc_tag)
] @string.special)
(groovy_doc
(groovy_doc_param
(identifier) @variable.parameter))
(groovy_doc
(groovy_doc_throws
(identifier) @type))

@ -1,2 +1,5 @@
([(line_comment) (block_comment)] @injection.content ((comment) @injection.content
(#set! injection.language "comment")) (#set! injection.language "comment"))
((groovy_doc) @injection.content
(#set! injection.language "comment"))

@ -0,0 +1,6 @@
(function_definition) @local.scope
(parameter
name: (identifier) @local.definition)
(identifier) @local.reference
Loading…
Cancel
Save