Question

I'm using Groovy for a calculation engine DSL and really like the support we now have in Eclipse with STS and the Groovy-Eclipse plug-in (I'm on STS 2.8.0M2 with latest milestone of Groovy-Eclipse 2.5.2).

One issue I have is I don't know how to get the Groovy editor to 'know' the automatic imports I've added to my script runner, meaning Eclipse gives me a whole bunch of false errors. If you use the Groovy class loader, you can add additional import for 'free', so you avoid needing to do imports in your script.

I've had a play with the DSLD support in Groovy-Eclipse (which can be used to add auto-completion support) but it's not obvious to me that this is something I could do with it - I don't find the DSLD documentation the simplest to follow.

The inferencing settings for Groovy in Eclipse didn't look like the right thing either.

For example:

def result = new CalculationResult()

gives me an error on the CalculationResult class as it's not imported, but the script will execute correctly in my environment because of the customized imports on the Groovy class loader. I'm using the standard import customization provided by Groovy, for example:

import org.codehaus.groovy.control.customizers.ImportCustomizer
import org.codehaus.groovy.control.CompilerConfiguration

def importCustomizer = new ImportCustomizer()
importCustomizer.addImport 'CalculationResult', 'ch.hedgesphere.core.type.CalculationResult'

def configuration = new CompilerConfiguration()

configuration.addCompilationCustomizers(importCustomizer)
...

Any pointers appreciated.

Was it helpful?

Solution

This seems to be in their bugtracker as coming in the 2.6 release of the plugin.

But the comment from Andrew Eisenberg doesn't bode well:

Unfortunately, this is not something that DSLDs can do. Since a missing import could mean compile errors, we would need a way to augment the compiler lookup for this. There might be a way to specify this information inside of a DSLD, but that would mean hooking into DSLDs in a very different way. More likely, this will have to be specified through an Eclipse plugin (like the gradle tooling).

Another possibility is that we can ensure that certain kinds of AST Transforms are applied during a reconcile and so the editor would just "magically" know about these extra imports. We will have to look into the feasibility of this, however.

Still, maybe a vote on that issue wouldn't go amiss?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top