Renny Barrett Renny Barrett - 1 year ago 88
Groovy Question

groovyc won't report multiple errors

I'm playing around with Groovy and in particular compiling and running Groovy classes from within a Java application.

The Groovy can, of course, have compilation problems, and I'm seeing different behaviour regarding reporting of compilation problems from
- running groovyc on the command line or loading a class using GroovyClassLoader vs.
- using an IDE such as Intellij.

Here's my test Groovy:

package test;

class MyTestGroovyClass2 {


In groovyc and using GroovyClassLoader, only the first error is reported:

groovyc "src\test\MyTestGroovyClass2.groovy"

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
C:\Users\barrettr\IdeaProjects\TestGroovy\src\test\MyTestGroovyClass2.groovy: 5: unexpected token: causesACompileError @ line 5, column 2.

1 error

...but in IntelliJ I see both errors:
enter image description here

I debugged briefly through the
and saw it stopping after finding the first error.

Is there any support in Groovy for reporting multiple errors, a la IntelliJ?

Answer Source

IntelliJ utilizes its own parser trying to parse as much as it can. After the first parsing error the parser state is recovered and the parser then tries to process the next statement.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download