Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
eclipse -application org.codehause.groovy.eclipse.staticCheck [-data /path/to/eclipse/workspace] \
    [--help] [-h] [--extra_dslds <FILES>] [--assertions_only] [--excludes <PATH>] \
    [--includes <PATH>] <PROJECT_NAME>

...

includes all files, but excludes all *Test.groovy files in test/java and test/groovy.

The results

Let's assume that there is a Groovy project in an Eclipse workspace with a single file:

Code Block
title/MyProj/src/MyScript.groovy

happiness  // TYPE:java.lang.Integer
happiness  // TYPE:java.lang.String
somethingUndefined

And this DSLD file exists outside of the workspace:

Code Block
title/tmp/myapp.dsld

currentType().accept { property name:"happiness", type:Integer }

Then executing this command:

Code Block

eclipse -application org.codehause.groovy.eclipse.staticCheck --extra_dslds /tmp/myapp.dsld MyProj

Will produce the following output:

Code Block


Adding file:/tmp/other.dsld

Checking: /MyProj/src/MyScript.groovy
	Line 2: Invalid inferred type.  happiness Expected: java.lang.String Actual: java.lang.Integer
	Line 3: unknown type: somethingUndefined

Removing file:/tmp/other.dsld

If you want to suppress all of the unknown type warnings, then include the --assertions_only parameter on the command line.

More to come

This is just a first pass at static checking. We are looking for feedback as to the best way to display failed assertions, or if there is anything else that can be improved. If there is significant interest, we can do the work to make it easy to create JUnit (or Spock!) tests for DSLDs, but we need to hear the feedback first.