Skip to content

Resolve #2677 : add Groovy language analyzer - #4956

Open
urunsiyabend wants to merge 1 commit into
oracle:masterfrom
urunsiyabend:2677-groovy-analyzer
Open

urunsiyabend wants to merge 1 commit into
oracle:masterfrom
urunsiyabend:2677-groovy-analyzer

Conversation

@urunsiyabend

Copy link
Copy Markdown
Contributor

resolves #2677

this change adds syntax recognition for .groovy, .gradle, .gvy, .gy, and .gsh files. Since universal-ctags (as of v5.9.0) doesn’t yet have a native Groovy parser, this implementation follows the same approach as Scala, using patterns plugged via Ctags.java. Once a native parser is available, it can be swapped in easily by uppercasing a single letter.

i was highly inspired by official ANTLR groovy lexer (https://github.com/apache/groovy/blob/GROOVY_3_0_X/src/antlr/GroovyLexer.g4)

lexer highlights:

  • Handles all four string types: double-quoted, single-quoted, triple-double-quoted, and triple-single-quoted.
  • Supports gstring interpolation: $id, ${expr}, and property chains (like $a.b.c via a dedicated GSTRING_PATH state)
  • Slashy regex (/.../) and dollar-slashy regex ($/.../$) are supported. Disambiguation between regex and division is handled with a regexAllowed flag, mirroring Apache Groovy ANTLR’s REGEX_CHECK_ARRAY
  • Numeric literals follow Groovy spec verbatim (hex, octal, binary, decimal, suffixes, underscores).

ctags kinds supported:
class, interface, trait, enum, annotation, method (def name(...)), field, package, import.

performance & correctness:

  • tested on 2,600+ groovy and gradle files from Apache Groovy github repo (https://github.com/apache/groovy)
  • Full indexing: ~5m37s
  • REST search, cross-reference, and file-defs return correct symbols and highlighting.

known limitations:

  • identifier rule is ASCII-only; unicode identifiers are not supported (same as other opengrok analyzers)
  • non-sealed keyword in groovy 4+ splits into three tokens (non, -, sealed) because the identifier macro doesn’t span hyphens

@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label May 21, 2026
@urunsiyabend
urunsiyabend force-pushed the 2677-groovy-analyzer branch from 0ec01fc to 604600a Compare May 24, 2026 22:54
@vladak
vladak force-pushed the 2677-groovy-analyzer branch from 604600a to d23035e Compare June 3, 2026 07:13
@urunsiyabend
urunsiyabend force-pushed the 2677-groovy-analyzer branch from d23035e to 8add316 Compare June 3, 2026 16:02
@urunsiyabend
urunsiyabend force-pushed the 2677-groovy-analyzer branch from a4538b0 to fc44f87 Compare June 17, 2026 19:48
Signed-off-by: Siyabend Urun <urunsiyabend@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Groovy support

1 participant