Skip to content

Commit

Permalink
feat(treesitter): groovy support (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanueltouzery committed Mar 11, 2024
1 parent 31fbd36 commit c8a40b1
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ In addition, you will need to have either Treesitter or a working LSP client. Yo
- dart
- elixir
- go
- groovy
- help
- html
- java
Expand Down
22 changes: 22 additions & 0 deletions queries/groovy/aerial.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(juxt_function_call
function: (identifier) @name (#not-any-of? @name "else" "try" "exec")
(argument_list (closure))
(#set! "kind" "Module")
) @symbol

(declaration
name: (identifier) @name
(closure)
(#set! "kind" "Function")
) @symbol

(juxt_function_call
function: (identifier) @keyword (#eq? @keyword "task")
(argument_list ((function_call function: (identifier) @name)))
(#set! "kind" "Function")
) @symbol

(declaration
name: (identifier) @name
(#set! "kind" "Constant")
) @symbol
124 changes: 124 additions & 0 deletions tests/symbols/groovy_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
[
{
"col": 0,
"end_col": 41,
"end_lnum": 4,
"kind": "Constant",
"level": 0,
"lnum": 4,
"name": "enableProguardInReleaseBuilds",
"selection_range": {
"col": 4,
"end_col": 33,
"end_lnum": 4,
"lnum": 4
}
},
{
"col": 0,
"end_col": 1,
"end_lnum": 8,
"kind": "Module",
"level": 0,
"lnum": 6,
"name": "plugins",
"selection_range": {
"col": 0,
"end_col": 7,
"end_lnum": 6,
"lnum": 6
}
},
{
"col": 0,
"end_col": 27,
"end_lnum": 10,
"kind": "Constant",
"level": 0,
"lnum": 10,
"name": "magicNumber",
"selection_range": {
"col": 4,
"end_col": 15,
"end_lnum": 10,
"lnum": 10
}
},
{
"children": [
{
"col": 4,
"end_col": 5,
"end_lnum": 19,
"kind": "Module",
"level": 1,
"lnum": 16,
"name": "compileOptions",
"selection_range": {
"col": 4,
"end_col": 18,
"end_lnum": 16,
"lnum": 16
}
}
],
"col": 0,
"end_col": 1,
"end_lnum": 20,
"kind": "Module",
"level": 0,
"lnum": 12,
"name": "android",
"selection_range": {
"col": 0,
"end_col": 7,
"end_lnum": 12,
"lnum": 12
}
},
{
"col": 0,
"end_col": 1,
"end_lnum": 26,
"kind": "Module",
"level": 0,
"lnum": 22,
"name": "dependencies",
"selection_range": {
"col": 0,
"end_col": 12,
"end_lnum": 22,
"lnum": 22
}
},
{
"col": 0,
"end_col": 12,
"end_lnum": 28,
"kind": "Constant",
"level": 0,
"lnum": 28,
"name": "welcome",
"selection_range": {
"col": 5,
"end_col": 12,
"end_lnum": 28,
"lnum": 28
}
},
{
"col": 4,
"end_col": 5,
"end_lnum": 31,
"kind": "Module",
"level": 0,
"lnum": 29,
"name": "doLast",
"selection_range": {
"col": 4,
"end_col": 10,
"end_lnum": 29,
"lnum": 29
}
}
]
32 changes: 32 additions & 0 deletions tests/treesitter/groovy_test.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false

plugins {
id 'com.android.application'
}

def magicNumber = { -> 42 }

android {

compileSdkVersion rootProject.ext.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation project(":lib")
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation fileTree(dir: 'libs', include: ['*.jar'])
}

task welcome {
doLast {
println 'Welcome'
}
}

0 comments on commit c8a40b1

Please sign in to comment.