public abstract class AST<A extends AST<A,L,N>,L extends LombokNode<A,L,N>,N>
extends java.lang.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(java.lang.String fileName,
java.lang.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 java.util.Collection<L> |
buildWithField(java.lang.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 java.util.Collection<AST.FieldAccess> |
fieldsOf(java.lang.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.
|
abstract java.net.URI |
getAbsoluteFileLocation()
Attempts to find the absolute path (in URI form) to the source file represented by this AST.
|
java.lang.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 java.util.Map<N,L> |
getNodeMap()
Returns the node map, that can map javac/Eclipse internal AST objects to AST.Node objects.
|
java.lang.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 java.util.Collection<java.lang.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.
|
<T> T |
readConfiguration(ConfigurationKey<T> key) |
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(java.lang.reflect.Field field,
java.lang.Object fieldRef,
java.util.List<java.util.Collection<?>> chain,
java.util.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(java.lang.Class<?> parentType,
java.lang.Class<?> childType,
java.lang.String fieldName) |
L |
top()
The AST.Node object representing the Compilation Unit.
|
protected AST(java.lang.String fileName, java.lang.String packageDeclaration, ImportList imports)
public abstract java.net.URI getAbsoluteFileLocation()
null
if this cannot be done. We don't yet know under which conditions this will happen.public void setChanged()
protected void clearChanged()
public boolean isChanged()
protected void setTop(L top)
public final java.lang.String getPackageDeclaration()
public final ImportList getImportList()
protected L putInMap(L node)
protected java.util.Map<N,L> getNodeMap()
protected void clearState()
protected boolean setAndGetAsHandled(N node)
public java.lang.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 java.util.Collection<AST.FieldAccess> fieldsOf(java.lang.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 java.util.Collection<java.lang.Class<? extends N>> getStatementTypes()
protected boolean shouldDrill(java.lang.Class<?> parentType, java.lang.Class<?> childType, java.lang.String fieldName)
protected java.util.Collection<L> buildWithField(java.lang.Class<L> nodeType, N statement, AST.FieldAccess fa)
protected boolean replaceStatementInNode(N statement, N oldN, N newN)
protected void setElementInASTCollection(java.lang.reflect.Field field, java.lang.Object fieldRef, java.util.List<java.util.Collection<?>> chain, java.util.Collection<?> collection, int idx, N newN) throws java.lang.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.java.lang.IllegalAccessException
- This exception won't happen, but we allow you to throw it so you can avoid having to catch it.public final <T> T readConfiguration(ConfigurationKey<T> key)
Copyright © 2009-2015 The Project Lombok Authors, licensed under the MIT licence.