[Groovy] Class AstNodeToScriptAdapter
- groovy.inspect.swingui.AstNodeToScriptAdapter
@CompileStatic @Deprecated class AstNodeToScriptAdapter extends Object
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.
Constructor Summary
Constructor and description |
---|
AstNodeToScriptAdapter
() |
Methods Summary
Type Params | Return Type | Name and description |
---|---|---|
String |
compileToScript(String script, int compilePhase, ClassLoader classLoader, boolean showScriptFreeForm, boolean showScriptClass, CompilerConfiguration config) This method takes source code, compiles it, then reverses it back to source. | |
static void |
main(String[] args) Run this class as a script to compile a groovy file and print out the resulting source. |
Inherited Methods Summary
Methods inherited from class | Name |
---|---|
class Object | wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Constructor Detail
AstNodeToScriptAdapter()
Method Detail
String compileToScript(String script, int compilePhase, ClassLoader classLoader, boolean showScriptFreeForm, boolean showScriptClass, CompilerConfiguration config)
This method takes source code, compiles it, then reverses it back to source.
- 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 CompilePhase -
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 -
config
- optional compiler configuration
static void main(String[] 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
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/3.0.7/html/gapi/groovy/inspect/swingui/AstNodeToScriptAdapter.html