Skip to content

Provide definitions for implicitly-defined script classes#117

Open
trustytrojan wants to merge 1 commit into
GroovyLanguageServer:masterfrom
trustytrojan:implicit-script-class-definitions
Open

Provide definitions for implicitly-defined script classes#117
trustytrojan wants to merge 1 commit into
GroovyLanguageServer:masterfrom
trustytrojan:implicit-script-class-definitions

Conversation

@trustytrojan
Copy link
Copy Markdown
Contributor

@trustytrojan trustytrojan commented May 26, 2026

Changes

  • Implement go-to-definition for ClassExpressions, ConstructorCallExpressions, and ImportNodes using implicit script classes, where otherwise scripts were required to return an expression (or have its last statement be an expression) and the definition pointed to that expression.
  • Fix NullPointerException when requesting references for a ClassExpression of an implicit script class within the same file. This was found when ctrl+clicking on the expression moduleA within the file moduleA.groovy while another file contained the statement import moduleA. See Fix NullPointerException in ReferenceProvider #118
  • Add test cases to GroovyServicesDefinitionTests for implicit script class definition requests

Visual testing

Create the file moduleA.groovy. Do not define an explicit script class like class moduleA {}. Instead write a static and an instance method at the top-level of the script:

static def staticFunc() {}
def instanceFunc() {}

In another Groovy script in the same directory as moduleA.groovy, write:

import moduleA
moduleA.staticFunc()
new moduleA().instanceFunc()

Then ctrl+click or use the "Go To Definition" feature of your editor on moduleA within each statement. Your cursor should be placed at the first character of moduleA.groovy.

…`s and `ImportNode`s where otherwise scripts were required to return an expression (last statement is an expression)

Fix `NullPointerException` when requesting references for a `ClassExpression` of an implicit script class within the same file

Add tests to `GroovyServicesDefinitionTests` for implicit script class definition requests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant