Interface IJavaElement
- All Known Subinterfaces:
IJavaAnnotation,IJavaAnnotationElement,IJavaArrayElt,IJavaAssignment,IJavaBlock,IJavaBreak,IJavaCall,IJavaClass,IJavaCompound,IJavaConditionalExpression,IJavaConstant,IJavaContinue,IJavaDecompilableElement,IJavaDefinition,IJavaDoWhile,IJavaExpression,IJavaField,IJavaFor,IJavaForEach,IJavaGoto,IJavaIdentifier,IJavaIf,IJavaInstanceField,IJavaLabel,IJavaLeftExpression,IJavaMethod,IJavaMonitor,IJavaNew,IJavaNewArray,IJavaOperation,IJavaPredicate,IJavaPredicate_LEGACY,IJavaReturn,IJavaStatement,IJavaStaticField,IJavaSwitch,IJavaSynchronizedBlock,IJavaTerminalStatement,IJavaThrow,IJavaTry,IJavaTypeReference,IJavaWhile
Top-level interface for all elements of a Java
Abstract Syntax Tree.
Each AST element implements this interface or one of the sub-interfaces.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFlags(int f) Add flags to the current list of flags on this element.Add a tag.booleanThis non-recursive method indicates whether or not this element may be the cause of an exception.voidcollectAllPhysicalOffsets(Collection<Integer> physicalOffsets) Collect physical offsets for this element and all its constituents.Duplicate this element.voidgenerate(JavaOutputSink out) Generate this AST element recursively into a sink.Retrieve a piece of data attached to this AST element.This method returns the type of Java AST element held by this object.intgetFlags()Retrieve the flags set on this element.intRetrieve the explicit low-level dex method index of this AST element.intRetrieve the low-level offset that map to this AST element.Get the list of AST elements that constitute this AST element.getTags()Get a read-only collection of the current tag map.booleanhasFlags(int f) Determine whether any flags have been set on this element.booleanDetermine whether an explicit physical method index is attached to this element.booleanDetermine whether a physical offset is attached to this element.booleanvoidremoveFlags(int f) Remove some flags from this element.Remove a tag.booleanreplaceSubElement(IJavaElement target, IJavaElement repl) Replace one element by another one.voidAttach a piece of arbitrary data to this AST element.voidsetFlags(int f) Set flags on this element.voidsetLambdaRecon(JavaReconLambda recon) voidvoidsetPhysicalMethodIndex(int midx) Set an explicit low-level dex method index of this AST element.voidsetPhysicalOffset(int offset) Set a low-level physical offset to this AST element.voidsetReconAnon(JavaReconAnon recon) voidsetReconEnum(JavaReconEnum recon) voidsetReconEnummap(JavaReconEnummap recon) Generate a short-string version of this element.booleanvisitDepthPost(IJVisitor visitor) Depth-first search, post-order visit of an expression tree or sub-tree.booleanvisitDepthPost(IJVisitor visitor, IJavaElement parent) Depth-first search, post-order visit of an expression tree or sub-tree.booleanvisitDepthPost(IJVisitor visitor, IJavaElement parent, JVisitResults results) Depth-first search, post-order visit of an expression tree or sub-tree.booleanvisitDepthPost(IJVisitor visitor, IJavaElement parent, JVisitResults results, boolean doNotVisitBlocksInsideCompounds) Depth-first search, post-order visit of an expression tree or sub-tree.booleanvisitDepthPre(IJVisitor visitor) Visit this AST tree.booleanvisitDepthPre(IJVisitor visitor, IJavaElement parent) Visit this AST tree.booleanvisitDepthPre(IJVisitor visitor, IJavaElement parent, JVisitResults results) Visit this AST tree.
-
Field Details
-
FLAG_BUILT
static final int FLAG_BUILT- See Also:
-
FLAG_SECOND_PARAMETER_IS_OUTER_REF
static final int FLAG_SECOND_PARAMETER_IS_OUTER_REF- See Also:
-
FLAG_OPTIONAL_RENDERING
static final int FLAG_OPTIONAL_RENDERING- See Also:
-
FLAG_LAMBDA_IMPL
static final int FLAG_LAMBDA_IMPL- See Also:
-
FLAG_LAMBDA_CLASS
static final int FLAG_LAMBDA_CLASS- See Also:
-
FLAG_FIELD_REFERENCES_OUTERCLASS
static final int FLAG_FIELD_REFERENCES_OUTERCLASS- See Also:
-
FLAG_STICKY
static final int FLAG_STICKY- See Also:
-
-
Method Details
-
hasPhysicalMethodIndex
boolean hasPhysicalMethodIndex()Determine whether an explicit physical method index is attached to this element.For code located in a method, the default method attached to an AST element is the method containing the element.
- Returns:
-
setPhysicalMethodIndex
void setPhysicalMethodIndex(int midx) Set an explicit low-level dex method index of this AST element. This method is useful to override the default (owner method), such as when a method contains inlined code from another method.For code located in a method, the default method attached to an AST element is the method containing the element.
- Parameters:
midx- a lower-level dex method index, or -1 to signify none or the default
-
getPhysicalMethodIndex
int getPhysicalMethodIndex()Retrieve the explicit low-level dex method index of this AST element.For code located in a method, the default method attached to an AST element is the method containing the element.
- Returns:
- a lower-level dex method index, or -1 to signify none or the default
-
hasPhysicalOffset
boolean hasPhysicalOffset()Determine whether a physical offset is attached to this element.- Returns:
-
getPhysicalOffset
int getPhysicalOffset()Retrieve the low-level offset that map to this AST element.- Returns:
- a physical method offset, -1 if none is available
-
setPhysicalOffset
void setPhysicalOffset(int offset) Set a low-level physical offset to this AST element.- Parameters:
offset-
-
collectAllPhysicalOffsets
Collect physical offsets for this element and all its constituents. The first elementaddedis for this one, followed by thesub-elements's.- Parameters:
physicalOffsets- output collection
-
getSubElements
List<IJavaElement> getSubElements()Get the list of AST elements that constitute this AST element. Typically, for simple statements, it may be expression. For complex expressions, it may be simpler expressions. For compound statements, it may more statements and expressions.Note that
typeandannotationelements are not returned by this method.- Returns:
- the list of constituting elements, may be empty but never null
-
replaceSubElement
Replace one element by another one. Only the references are compared, no equals/deep compare. At most one element is replaced.Note that
typeandannotationelements cannot be replaced using this method.- Parameters:
target- the element to be replacedrepl- the new element- Returns:
-
canCauseException
boolean canCauseException()This non-recursive method indicates whether or not this element may be the cause of an exception. In order to recursively check if the element throws (e.g., for a statement), useJUtil.canThrow(IStatement).- Returns:
-
generate
Generate this AST element recursively into a sink.- Parameters:
out-
-
getTags
Get a read-only collection of the current tag map. Tags are special key-value pairs that can be attached to AST elements and rendered during AST generation.- Returns:
-
addTag
Add a tag. SeegetTags().- Parameters:
key-value-- Returns:
-
removeTag
Remove a tag. SeegetTags().- Parameters:
key-- Returns:
-
setData
Attach a piece of arbitrary data to this AST element.- Parameters:
key-value-
-
getData
Retrieve a piece of data attached to this AST element.- Parameters:
key-- Returns:
-
setFlags
void setFlags(int f) Set flags on this element. SeeFLAG_xxxfor a list of legal flags.- Parameters:
f-
-
getFlags
int getFlags()Retrieve the flags set on this element. SeeFLAG_xxxfor a list of legal flags.- Returns:
-
addFlags
void addFlags(int f) Add flags to the current list of flags on this element. SeeFLAG_xxxfor a list of legal flags.- Parameters:
f-
-
removeFlags
void removeFlags(int f) Remove some flags from this element. SeeFLAG_xxxfor a list of legal flags.- Parameters:
f-
-
hasFlags
boolean hasFlags(int f) Determine whether any flags have been set on this element. SeeFLAG_xxxfor a list of legal flags.- Parameters:
f-- Returns:
-
getElementType
JavaElementType getElementType()This method returns the type of Java AST element held by this object.- Returns:
-
toShortString
String toShortString()Generate a short-string version of this element.- Returns:
-
duplicate
IJavaElement duplicate()Duplicate this element.- Returns:
- a (possibly) duplicated object of the same type
-
visitDepthPre
Visit this AST tree. Processing of a node is done before visiting the children.- Parameters:
visitor-- Returns:
-
visitDepthPre
Visit this AST tree. Processing of a node is done before visiting the children.- Parameters:
visitor-parent-- Returns:
-
visitDepthPre
Visit this AST tree. Processing of a node is done before visiting the children.- Parameters:
visitor-parent-results-- Returns:
-
visitDepthPost
Depth-first search, post-order visit of an expression tree or sub-tree. The node being visited may be replaced without notifying the visitor.- Parameters:
visitor- the visitor object- Returns:
- true if the visit was successful
-
visitDepthPost
Depth-first search, post-order visit of an expression tree or sub-tree. The node being visited may be replaced without notifying the visitor.- Parameters:
visitor- the visitor objectparent-- Returns:
- true if the visit was successful
-
visitDepthPost
Depth-first search, post-order visit of an expression tree or sub-tree. The node being visited may be replaced without notifying the visitor.- Parameters:
visitor- the visitor objectparent-results-- Returns:
- true if the visit was successful
-
visitDepthPost
boolean visitDepthPost(IJVisitor visitor, IJavaElement parent, JVisitResults results, boolean doNotVisitBlocksInsideCompounds) Depth-first search, post-order visit of an expression tree or sub-tree. The node being visited may be replaced without notifying the visitor.- Parameters:
visitor- the visitor objectparent-results-doNotVisitBlocksInsideCompounds- true to avoid exploring the sub-blocks ofcompoundstatements (e.g., if true, when visiting an if-statements, the predicate expressions will be visited, but the if-blocks will not)- Returns:
- true if the visit was successful
-
isReconArtifact
boolean isReconArtifact() -
setLambdaRecon
-
getReconLambda
JavaReconLambda getReconLambda() -
setReconEnum
-
getReconEnum
JavaReconEnum getReconEnum() -
setReconEnummap
-
getReconEnummap
JavaReconEnummap getReconEnummap() -
setReconAnon
-
getReconAnon
JavaReconAnon getReconAnon() -
setOrigin
-
getOrigin
String getOrigin()
-