Groovy Documentation

## groovy.inspect.swingui
[Groovy] Class AstNodeToScriptAdapter

    java.lang.Object
      groovy.inspect.swingui.AstNodeToScriptAdapter

    class AstNodeToScriptAdapter

This class takes Groovy source code, compiles it to a specific compile phase, and then decompiles it back to the groovy source. It is used by GroovyConsole's AST Browser, but can also be invoked from the command line.

Authors:
  Hamlet D'Arcy

Method Summary
`java.lang.String` | `compileToScript(java.lang.String script, int compilePhase, java.lang.ClassLoader classLoader = null, boolean showScriptFreeForm = true, boolean showScriptClass = true)` This method takes source code, compiles it, then reverses it back to source.
`static void` | `main(java.lang.Object args)` Run this class as a script to compile a groovy file and print out the resulting source.

Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Method Detail

### compileToScript

    java.lang.String compileToScript(java.lang.String script, int compilePhase, java.lang.ClassLoader classLoader = null, boolean showScriptFreeForm = true, boolean showScriptClass = true)

  This method takes source code, compiles it, then reverses it back to source. @{link CompilePhase}
  returns:
    the source code from the AST state
  Parameters:
    `script` - the source code to be compiled. If invalid, a compile error occurs
    `compilePhase` - the CompilePhase. Must be an int mapped in
    `classLoader` - (optional) the classloader to use. If missing/null then the current is used. This parameter enables things like ASTBrowser to invoke this with the correct classpath
    `showScriptFreeForm` - Whether or not to show the script portion of the source code
    `showScriptClass` - Whether or not to show the Script class from the source code

### main

    static void main(java.lang.Object args)

  Run this class as a script to compile a groovy file and print out the resulting source.
  Parameters:
    `args` - a filename to compile and a CompilePhase to run to

Groovy Documentation