public abstract class AST<A extends AST<A,L,N>,L extends LombokNode<A,L,N>,N> extends Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AST.FieldAccess
Represents a field that contains AST children.
|
static class |
AST.Kind
The kind of node represented by a given AST.Node object.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AST(String fileName,
String packageDeclaration,
ImportList imports) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract L |
buildTree(N item,
AST.Kind kind)
Build an AST.Node object for the stated internal (javac/Eclipse) AST Node object.
|
protected Collection<L> |
buildWithField(Class<L> nodeType,
N statement,
AST.FieldAccess fa)
buildTree implementation that uses reflection to find all child nodes by way of inspecting
the fields.
|
protected void |
clearChanged() |
protected void |
clearState()
Clears the registry that avoids endless loops, and empties the node map.
|
protected Collection<AST.FieldAccess> |
fieldsOf(Class<?> c)
Returns FieldAccess objects for the stated class.
|
L |
get(N node)
Maps a javac/Eclipse internal AST Node to the appropriate AST.Node object.
|
String |
getFileName() |
ImportList |
getImportList()
Return the contents of each non-static import statement on this AST's top (Compilation Unit) node.
|
int |
getLatestJavaSpecSupported()
Returns the latest version of the java language specification supported by the host compiler.
|
protected Map<N,L> |
getNodeMap()
Returns the node map, that can map javac/Eclipse internal AST objects to AST.Node objects.
|
String |
getPackageDeclaration()
Return the content of the package declaration on this AST's top (Compilation Unit) node.
|
int |
getSourceVersion()
Returns the JLS spec version that the compiler uses to parse and compile this AST.
|
protected abstract Collection<Class<? extends N>> |
getStatementTypes()
The supertypes which are considered AST Node children.
|
boolean |
isChanged() |
protected L |
putInMap(L node)
Puts the given node in the map so that javac/Eclipse's own internal AST object can be translated to
an AST.Node object.
|
protected boolean |
replaceStatementInNode(N statement,
N oldN,
N newN)
Uses reflection to find the given direct child on the given statement, and replace it with a new child.
|
protected boolean |
setAndGetAsHandled(N node)
Marks the stated node as handled (to avoid endless loops if 2 nodes refer to each other, or a node
refers to itself).
|
void |
setChanged() |
protected void |
setElementInASTCollection(Field field,
Object fieldRef,
List<Collection<?>> chain,
Collection<?> collection,
int idx,
N newN)
Override if your AST collection does not support the set method.
|
protected void |
setTop(L top)
Set the node object that wraps the internal Compilation Unit node.
|
protected boolean |
shouldDrill(Class<?> parentType,
Class<?> childType,
String fieldName) |
L |
top()
The AST.Node object representing the Compilation Unit.
|
protected AST(String fileName, String packageDeclaration, ImportList imports)
public void setChanged()
protected void clearChanged()
public boolean isChanged()
protected void setTop(L top)
public final String getPackageDeclaration()
public final ImportList getImportList()
protected L putInMap(L node)
protected Map<N,L> getNodeMap()
protected void clearState()
protected boolean setAndGetAsHandled(N node)
public String getFileName()
public L top()
public int getSourceVersion()
6.public int getLatestJavaSpecSupported()
7.
NB: Even if -source (lower than maximum) is specified, this method still returns the maximum supported number.protected abstract L buildTree(N item, AST.Kind kind)
protected Collection<AST.FieldAccess> fieldsOf(Class<?> c)
getStatementTypes(), either directly or inside of an array or java.util.collection (or array-of-arrays,
or collection-of-collections, etcetera), is returned.protected abstract Collection<Class<? extends N>> getStatementTypes()
protected boolean shouldDrill(Class<?> parentType, Class<?> childType, String fieldName)
protected Collection<L> buildWithField(Class<L> nodeType, N statement, AST.FieldAccess fa)
protected boolean replaceStatementInNode(N statement, N oldN, N newN)
protected void setElementInASTCollection(Field field, Object fieldRef, List<Collection<?>> chain, Collection<?> collection, int idx, N newN) throws IllegalAccessException
field - The field that contains the array or list of AST nodes.fieldRef - The object that you can supply to the field's get method.chain - If the collection is immutable, you need to update the pointer to the collection in each element in the chain.IllegalAccessException - This exception won't happen, but we allow you to throw it so you can avoid having to catch it.Copyright © 2009-2013 The Project Lombok Authors, licensed under the MIT licence.