public class SourceUnit extends ProcessingUnit
| Modifier and Type | Field and Description |
|---|---|
protected ModuleNode |
ast
The root of the Abstract Syntax Tree for the source
|
protected Reduction |
cst
A Concrete Syntax Tree of the source
|
protected java.lang.String |
name
A descriptive name of the source unit.
|
protected ReaderSource |
source
Where we can get Readers for our source unit
|
classLoader, configuration, errorCollector, phase, phaseComplete| Constructor and Description |
|---|
SourceUnit(java.io.File source,
CompilerConfiguration configuration,
GroovyClassLoader loader,
ErrorCollector er)
Initializes the SourceUnit from the specified file.
|
SourceUnit(java.lang.String name,
ReaderSource source,
CompilerConfiguration flags,
GroovyClassLoader loader,
ErrorCollector er)
Initializes the SourceUnit from existing machinery.
|
SourceUnit(java.lang.String name,
java.lang.String source,
CompilerConfiguration configuration,
GroovyClassLoader loader,
ErrorCollector er)
Initializes the SourceUnit for a string of source.
|
SourceUnit(java.net.URL source,
CompilerConfiguration configuration,
GroovyClassLoader loader,
ErrorCollector er)
Initializes the SourceUnit from the specified URL.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addError(SyntaxException se)
This method adds a SyntaxException to the error collector.
|
void |
addException(java.lang.Exception e)
This method adds an exception to the error collector.
|
void |
convert()
Generates an AST from the CST.
|
static SourceUnit |
create(java.lang.String name,
java.lang.String source)
A convenience routine to create a standalone SourceUnit on a String
with defaults for almost everything that is configurable.
|
static SourceUnit |
create(java.lang.String name,
java.lang.String source,
int tolerance)
A convenience routine to create a standalone SourceUnit on a String
with defaults for almost everything that is configurable.
|
boolean |
failedWithUnexpectedEOF()
Convenience routine, primarily for use by the InteractiveShell,
that returns true if parse() failed with an unexpected EOF.
|
ModuleNode |
getAST()
Returns the Abstract Syntax Tree produced during convert()ing
and expanded during later phases.
|
Reduction |
getCST()
Returns the Concrete Syntax Tree produced during parse()ing.
|
java.lang.String |
getName()
Returns the name for the SourceUnit.
|
java.lang.String |
getSample(int line,
int column,
Janitor janitor)
Returns a sampling of the source at the specified line and column,
or null if it is unavailable.
|
ReaderSource |
getSource() |
protected boolean |
isEofToken(Token token) |
void |
parse()
Parses the source to a CST.
|
completePhase, configure, getClassLoader, getConfiguration, getErrorCollector, getPhase, getPhaseDescription, gotoPhase, nextPhase, setClassLoader, setConfigurationprotected ReaderSource source
protected java.lang.String name
protected Reduction cst
protected ModuleNode ast
public SourceUnit(java.lang.String name,
ReaderSource source,
CompilerConfiguration flags,
GroovyClassLoader loader,
ErrorCollector er)
public SourceUnit(java.io.File source,
CompilerConfiguration configuration,
GroovyClassLoader loader,
ErrorCollector er)
public SourceUnit(java.net.URL source,
CompilerConfiguration configuration,
GroovyClassLoader loader,
ErrorCollector er)
public SourceUnit(java.lang.String name,
java.lang.String source,
CompilerConfiguration configuration,
GroovyClassLoader loader,
ErrorCollector er)
public java.lang.String getName()
public Reduction getCST()
public ModuleNode getAST()
public boolean failedWithUnexpectedEOF()
protected boolean isEofToken(Token token)
public static SourceUnit create(java.lang.String name, java.lang.String source)
public static SourceUnit create(java.lang.String name, java.lang.String source, int tolerance)
public void parse()
throws CompilationFailedException
CompilationFailedExceptionpublic void convert()
throws CompilationFailedException
CompilationFailedExceptionpublic java.lang.String getSample(int line,
int column,
Janitor janitor)
public void addException(java.lang.Exception e)
throws CompilationFailedException
ErrorCollector directly by retrieving it with getErrorCollector().e - the exception that occurredCompilationFailedException - on errorpublic void addError(SyntaxException se) throws CompilationFailedException
se - the exception, which should have line and column informationCompilationFailedException - on errorpublic ReaderSource getSource()