Class AstNode
- java.lang.Object
-
- com.strobel.core.Freezable
-
- com.strobel.decompiler.languages.java.ast.AstNode
-
- All Implemented Interfaces:
UserDataStore,IFreezable,INode,java.lang.Cloneable
- Direct Known Subclasses:
ArraySpecifier,AstNode.NullAstNode,AstNode.PatternPlaceholder,AstType,CaseLabel,CatchClause,Comment,CompilationUnit,EntityDeclaration,Expression,Identifier,ImportDeclaration,JavaTokenNode,NewLineNode,PackageDeclaration,Statement,SwitchExpressionArm,SwitchSection,TextNode,TypeParameterDeclaration,VariableInitializer
public abstract class AstNode extends Freezable implements INode, UserDataStore, java.lang.Cloneable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAstNode.NullAstNodeprivate static classAstNode.PatternPlaceholder
-
Field Summary
Fields Modifier and Type Field Description private UserDataStore_dataStoreprivate AstNode_firstChildprivate AstNode_lastChildprivate AstNode_nextSiblingprivate AstNode_parentprivate AstNode_previousSiblingprotected static intAST_NODE_USED_FLAGSprotected intflags(package private) static intFROZEN_BITstatic AstNodeNULL(package private) static intROLE_INDEX_MASK(package private) static Role<AstNode>ROOT_ROLE-
Fields inherited from interface com.strobel.decompiler.patterns.INode
CHILD_ITERATOR
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAstNode()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract <T,R>
RacceptVisitor(IAstVisitor<? super T,? extends R> visitor, T data)<T extends AstNode>
voidaddChild(T child, Role<? extends T> role)(package private) voidaddChildUnsafe(AstNode child, Role<?> role)AstNodeclone()booleancontains(int line, int column)booleancontains(TextLocation location)private static <T> voidcopyKey(AstNode source, AstNode target, Key<T> key)voidcopyUserDataFrom(AstNode source)(package private) java.lang.StringdebugToString()static AstNodeforPattern(Pattern pattern)protected voidfreezeCore()java.lang.Iterable<AstNode>getAncestors()<T extends AstNode>
java.lang.Iterable<T>getAncestors(java.lang.Class<T> type)java.lang.Iterable<AstNode>getAncestorsAndSelf()<T extends AstNode>
TgetChildByRole(Role<? extends T> role)java.lang.Iterable<AstNode>getChildren()<T extends AstNode>
AstNodeCollection<T>getChildrenByRole(Role<? extends T> role)java.lang.Iterable<AstNode>getDescendants()java.lang.Iterable<AstNode>getDescendantsAndSelf()TextLocationgetEndLocation()AstNodegetFirstChild()AstNodegetLastChild()AstNodegetNextNode()AstNodegetNextSibling()<T extends AstNode>
TgetNextSibling(Role<? extends T> role)abstract NodeTypegetNodeType()AstNodegetParent()<T extends AstNode>
TgetParent(java.lang.Class<T> nodeType)AstNodegetPreviousNode()AstNodegetPreviousSibling()<T extends AstNode>
TgetPreviousSibling(Role<? extends T> role)RegiongetRegion()Role<? extends AstNode>getRole()TextLocationgetStartLocation()java.lang.StringgetText()java.lang.StringgetText(JavaFormattingOptions options)<T> TgetUserData(Key<T> key)booleanhasChildren()<T extends AstNode>
voidinsertChildAfter(AstNode previousSibling, T child, Role<? extends T> role)<T extends AstNode>
voidinsertChildBefore(AstNode nextSibling, T child, Role<? extends T> role)(package private) voidinsertChildBeforeUnsafe(AstNode nextSibling, AstNode child, Role<?> role)<T extends AstNode>
voidinsertChildrenAfter(AstNode nextSibling, Role<? extends T> role, T... children)<T extends AstNode>
voidinsertChildrenBefore(AstNode nextSibling, Role<? extends T> role, T... children)booleanisAncestorOf(AstNode node)booleanisAncestorOf(AstNode node, AstNode stopAt)booleanisDescendantOf(AstNode node)booleanisInside(int line, int column)booleanisInside(TextLocation location)static booleanisLoop(AstNode statement)booleanisNull()booleanisReference()static booleanisUnconditionalBranch(AstNode statement)OptionalNodemakeOptional()Matchmatch(INode other)booleanmatches(INode other)abstract booleanmatches(INode other, Match match)booleanmatchesCollection(Role<?> role, INode position, Match match, BacktrackingInfo backtrackingInfo)protected static booleanmatchString(java.lang.String pattern, java.lang.String text)<T> voidputUserData(Key<T> key, T value)<T> TputUserDataIfAbsent(Key<T> key, T value)voidremove()<T> booleanreplace(Key<T> key, T oldValue, T newValue)voidreplaceWith(AstNode newNode)<T extends AstNode>
TreplaceWith(Function<? super AstNode,? extends T> replaceFunction)protected <T extends AstNode>
voidsetChildByRole(Role<? extends T> role, T newChild)voidsetRole(Role<?> role)(package private) voidsetRoleUnsafe(Role<?> role)java.lang.StringtoString()NamedNodewithName(java.lang.String name)-
Methods inherited from class com.strobel.core.Freezable
canFreeze, freeze, freezeIfUnfrozen, isFrozen, tryFreeze, verifyFrozen, verifyNotFrozen
-
-
-
-
Field Detail
-
ROLE_INDEX_MASK
static final int ROLE_INDEX_MASK
- See Also:
- Constant Field Values
-
FROZEN_BIT
static final int FROZEN_BIT
- See Also:
- Constant Field Values
-
AST_NODE_USED_FLAGS
protected static final int AST_NODE_USED_FLAGS
- See Also:
- Constant Field Values
-
flags
protected int flags
-
_parent
private AstNode _parent
-
_previousSibling
private AstNode _previousSibling
-
_nextSibling
private AstNode _nextSibling
-
_firstChild
private AstNode _firstChild
-
_lastChild
private AstNode _lastChild
-
NULL
public static final AstNode NULL
-
_dataStore
private final UserDataStore _dataStore
-
-
Method Detail
-
matchString
protected static boolean matchString(java.lang.String pattern, java.lang.String text)
-
isLoop
public static boolean isLoop(AstNode statement)
-
isUnconditionalBranch
public static boolean isUnconditionalBranch(AstNode statement)
-
setRoleUnsafe
final void setRoleUnsafe(Role<?> role)
-
acceptVisitor
public abstract <T,R> R acceptVisitor(IAstVisitor<? super T,? extends R> visitor, T data)
-
clone
public AstNode clone()
- Overrides:
clonein classjava.lang.Object
-
copyUserDataFrom
public void copyUserDataFrom(AstNode source)
-
getParent
public final AstNode getParent()
-
getPreviousSibling
public final AstNode getPreviousSibling()
-
getLastChild
public final AstNode getLastChild()
-
getFirstChild
public final AstNode getFirstChild()
- Specified by:
getFirstChildin interfaceINode
-
getNextSibling
public final AstNode getNextSibling()
- Specified by:
getNextSiblingin interfaceINode
-
hasChildren
public final boolean hasChildren()
-
getNextNode
public final AstNode getNextNode()
-
getPreviousNode
public final AstNode getPreviousNode()
-
getChildren
public final java.lang.Iterable<AstNode> getChildren()
-
isAncestorOf
public final boolean isAncestorOf(AstNode node)
-
isDescendantOf
public final boolean isDescendantOf(AstNode node)
-
getAncestors
public final <T extends AstNode> java.lang.Iterable<T> getAncestors(@NotNull java.lang.Class<T> type)
-
getAncestors
public final java.lang.Iterable<AstNode> getAncestors()
-
getAncestorsAndSelf
public final java.lang.Iterable<AstNode> getAncestorsAndSelf()
-
getDescendants
public final java.lang.Iterable<AstNode> getDescendants()
-
getDescendantsAndSelf
public final java.lang.Iterable<AstNode> getDescendantsAndSelf()
-
getChildrenByRole
@NotNull public final <T extends AstNode> AstNodeCollection<T> getChildrenByRole(Role<? extends T> role)
-
setChildByRole
protected final <T extends AstNode> void setChildByRole(Role<? extends T> role, T newChild)
-
getParent
public final <T extends AstNode> T getParent(java.lang.Class<T> nodeType)
-
insertChildrenBefore
@SafeVarargs public final <T extends AstNode> void insertChildrenBefore(AstNode nextSibling, Role<? extends T> role, T... children)
-
insertChildBefore
public final <T extends AstNode> void insertChildBefore(AstNode nextSibling, T child, Role<? extends T> role)
-
insertChildrenAfter
@SafeVarargs public final <T extends AstNode> void insertChildrenAfter(AstNode nextSibling, Role<? extends T> role, T... children)
-
insertChildAfter
public final <T extends AstNode> void insertChildAfter(AstNode previousSibling, T child, Role<? extends T> role)
-
insertChildBeforeUnsafe
final void insertChildBeforeUnsafe(AstNode nextSibling, AstNode child, Role<?> role)
-
remove
public final void remove()
-
replaceWith
public final void replaceWith(AstNode newNode)
-
replaceWith
public final <T extends AstNode> T replaceWith(Function<? super AstNode,? extends T> replaceFunction)
-
freezeCore
protected void freezeCore()
- Overrides:
freezeCorein classFreezable
-
getNodeType
public abstract NodeType getNodeType()
-
isReference
public boolean isReference()
-
setRole
public final void setRole(Role<?> role)
-
matchesCollection
public boolean matchesCollection(Role<?> role, INode position, Match match, BacktrackingInfo backtrackingInfo)
- Specified by:
matchesCollectionin interfaceINode
-
withName
public NamedNode withName(java.lang.String name)
-
makeOptional
public OptionalNode makeOptional()
-
getStartLocation
public TextLocation getStartLocation()
-
getEndLocation
public TextLocation getEndLocation()
-
getRegion
public Region getRegion()
-
contains
public final boolean contains(int line, int column)
-
contains
public final boolean contains(TextLocation location)
-
isInside
public final boolean isInside(int line, int column)
-
isInside
public final boolean isInside(TextLocation location)
-
getText
public java.lang.String getText()
-
getText
public java.lang.String getText(JavaFormattingOptions options)
-
debugToString
java.lang.String debugToString()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getUserData
public final <T> T getUserData(Key<T> key)
- Specified by:
getUserDatain interfaceUserDataStore
-
putUserData
public final <T> void putUserData(Key<T> key, T value)
- Specified by:
putUserDatain interfaceUserDataStore
-
putUserDataIfAbsent
public final <T> T putUserDataIfAbsent(Key<T> key, T value)
- Specified by:
putUserDataIfAbsentin interfaceUserDataStore
-
replace
public final <T> boolean replace(Key<T> key, T oldValue, T newValue)
- Specified by:
replacein interfaceUserDataStore
-
-