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 int
static final int
static final int
static final int
static final int
static final int
static final int
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFlags
(int f) Add flags to the current list of flags on this element.Add a tag.boolean
This non-recursive method indicates whether or not this element may be the cause of an exception.void
collectAllPhysicalOffsets
(Collection<Integer> physicalOffsets) Collect physical offsets for this element and all its constituents.Duplicate this element.void
generate
(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.int
getFlags()
Retrieve the flags set on this element.int
Retrieve the explicit low-level dex method index of this AST element.int
Retrieve 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.boolean
hasFlags
(int f) Determine whether any flags have been set on this element.boolean
Determine whether an explicit physical method index is attached to this element.boolean
Determine whether a physical offset is attached to this element.boolean
void
removeFlags
(int f) Remove some flags from this element.Remove a tag.boolean
replaceSubElement
(IJavaElement oldElement, IJavaElement newElement) Replace one element by another one.void
Attach a piece of arbitrary data to this AST element.void
setFlags
(int f) Set flags on this element.void
setLambdaRecon
(JavaReconLambda recon) void
void
setPhysicalMethodIndex
(int midx) Set an explicit low-level dex method index of this AST element.void
setPhysicalOffset
(int offset) Set a low-level physical offset to this AST element.void
setReconAnon
(JavaReconAnon recon) void
setReconEnum
(JavaReconEnum recon) void
setReconEnummap
(JavaReconEnummap recon) Generate a short-string version of this element.boolean
visitDepthPost
(IJVisitor visitor) Depth-first search, post-order visit of an expression tree or sub-tree.boolean
visitDepthPost
(IJVisitor visitor, IJavaElement parent) Depth-first search, post-order visit of an expression tree or sub-tree.boolean
visitDepthPost
(IJVisitor visitor, IJavaElement parent, JVisitResults results) Depth-first search, post-order visit of an expression tree or sub-tree.boolean
visitDepthPost
(IJVisitor visitor, IJavaElement parent, JVisitResults results, boolean doNotVisitBlocksInsideCompounds) Depth-first search, post-order visit of an expression tree or sub-tree.boolean
visitDepthPre
(IJVisitor visitor) Visit this AST tree.boolean
visitDepthPre
(IJVisitor visitor, IJavaElement parent) Visit this AST tree.boolean
visitDepthPre
(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 elementadded
is 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
type
andannotation
elements 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
type
andannotation
elements cannot be replaced using this method.- Parameters:
oldElement
- the element to be replacednewElement
- 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_xxx
for a list of legal flags.- Parameters:
f
-
-
getFlags
int getFlags()Retrieve the flags set on this element. SeeFLAG_xxx
for a list of legal flags.- Returns:
-
addFlags
void addFlags(int f) Add flags to the current list of flags on this element. SeeFLAG_xxx
for a list of legal flags.- Parameters:
f
-
-
removeFlags
void removeFlags(int f) Remove some flags from this element. SeeFLAG_xxx
for a list of legal flags.- Parameters:
f
-
-
hasFlags
boolean hasFlags(int f) Determine whether any flags have been set on this element. SeeFLAG_xxx
for 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 ofcompound
statements (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()
-