Package gw.internal.gosu.parser
Class ParseTree
java.lang.Object
gw.internal.gosu.parser.ParseTree
- All Implemented Interfaces:
IParseTree,Serializable
Intended to specify the location of a parsed element within the source.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface gw.lang.parser.IParseTree
IParseTree.Search -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DynamicArray<ParseTree>private intprivate intprivate ParsedElementprivate IScriptPartIdprivate static final DynamicArray<ParseTree> -
Constructor Summary
ConstructorsConstructorDescriptionParseTree(ParsedElement pe, int iOffset, int iLength, IScriptPartId scriptPart) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(int iIndex, IParseTree l) voidAdds a child location to this location.private voidaddTokens(ParseTree after, List<IToken> tokens, StringBuilder source) voidaddUnder(IParseTree parent) (package private) voidadjustOffset(int offset, int lineNumOffset, int columnOffset) private voidappendTokensForOutline(ParseTree child, List<IToken> tokens, StringBuilder source) booleanareAllChildrenAfterPosition(int caret) booleanareOffsetAndExtentEqual(IParseTree location) Is just the physical location equal?voidvoidbooleancontains(int iPosition) private booleancontains(int start, int end) booleanbooleancontainsOrBorders(int iPosition, boolean strict) private booleancontainsOrBorders(int start, int end, boolean strict) booleancontainsOrBorders(IParseTree l, boolean strict) private voidfindDescendantsWithParsedElementType(ArrayList<IParseTree> matches, Class type) getChild(int index) getChildAfter(int point) getChildAfter(IParseTree child) getChildBefore(int point) getChildBefore(IParseTree child) intgetChildrenBefore(IParseTree parseTree) intprivate ParseTreegetDeepestLocation(boolean statementsOnly, int iPosition, boolean strict) getDeepestLocation(boolean statementsOnly, int iStart, int iEnd, boolean strict) getDeepestLocation(int iPosition, boolean strict) getDeepestLocation(int iStart, int iEnd, boolean strict) getDeepestStatementLocation(int iPosition, boolean strict) intgetFirstChildWithParsedElementType(Class<? extends IParsedElement> aClass) getLastChildWithParsedElementType(Class<? extends IParsedElement> aClass) intintfinal IParseTreegetMatchingElement(int iStart, int iLength) intLike getParent, but won't infinitely recurse if the parent turns out to be equal to this, which can happen when the expression in question is a program (since the outer program has the same location as the main statement).getStatementAtLine(int iLineNum, Class clsSkip) private StringgetTreeOutline(String strIndent) voidinitLocation(ParsedElement pe, int iOffset, int iLength) booleanisAncestor(IParseTree child) booleanbooleanisSiblingOf(IParseTree deepestAtEnd) private voidrecursivelyAdjustOffset(int offset, int lineNumOffset, int columnOffset) voidvoidsetLength(int iLength) voidSets the parent location.toString()
-
Field Details
-
EMPTY_PARSE_TREE_LIST
-
_pe
-
_children
-
_iOffset
private int _iOffset -
_iLength
private int _iLength -
_scriptPart
-
-
Constructor Details
-
ParseTree
-
-
Method Details
-
getEnclosingType
- Specified by:
getEnclosingTypein interfaceIParseTree
-
getScriptPartId
- Specified by:
getScriptPartIdin interfaceIParseTree
-
getOffset
public int getOffset()- Specified by:
getOffsetin interfaceIParseTree- Returns:
- The zero-based offset of the parsed element within the source.
-
getLength
public int getLength()- Specified by:
getLengthin interfaceIParseTree- Returns:
- The length of the parsed element in the source.
-
setLength
public void setLength(int iLength) - Specified by:
setLengthin interfaceIParseTree
-
getLineNum
public int getLineNum()- Specified by:
getLineNumin interfaceIParseTree- Returns:
- The one based line number of the beginning of the parsed element
-
getColumn
public int getColumn()- Specified by:
getColumnin interfaceIParseTree- Returns:
- The offset from the beginning of the line where the parsed element starts
-
getParsedElement
- Specified by:
getParsedElementin interfaceIParseTree- Returns:
- The parsed element to which this location corresponds.
-
getExtent
public int getExtent()- Specified by:
getExtentin interfaceIParseTree- Returns:
- The most distant position this location occupies i.e., offset + length - 1.
-
contains
public boolean contains(int iPosition) - Specified by:
containsin interfaceIParseTree- Parameters:
iPosition- Any position within the source.- Returns:
- True if this location contains the position.
-
contains
- Specified by:
containsin interfaceIParseTree- Parameters:
l- A location to check.- Returns:
- True if the space occupied by this location is a superset of the space occupied by the specified location.
-
contains
private boolean contains(int start, int end) -
containsOrBorders
public boolean containsOrBorders(int iPosition, boolean strict) - Specified by:
containsOrBordersin interfaceIParseTree
-
containsOrBorders
- Specified by:
containsOrBordersin interfaceIParseTree
-
containsOrBorders
private boolean containsOrBorders(int start, int end, boolean strict) -
getDeepestLocation
- Specified by:
getDeepestLocationin interfaceIParseTree
-
isAncestorOf
- Specified by:
isAncestorOfin interfaceIParseTree
-
getDeepestLocation
-
getDeepestLocation
- Specified by:
getDeepestLocationin interfaceIParseTree- Parameters:
iPosition- The location to check.strict- Whether to match strictly or accept white spaces to the right- Returns:
- The deepest descendent location containing the specified location.
-
getDeepestLocation
- Specified by:
getDeepestLocationin interfaceIParseTree- Parameters:
iStart- The start of the segment (inclusive)iEnd- The end of the segment (inclusive)strict- Whether to match strictly or accept white spaces to the right- Returns:
- The deepest descendent location containing the segment.
-
getDeepestStatementLocation
- Specified by:
getDeepestStatementLocationin interfaceIParseTree- Parameters:
iPosition- The location to check.strict- Whether to match strictly or accept white spaces to the right- Returns:
- The deepest descendent statement location containing the specified location.
-
getStatementAtLine
- Specified by:
getStatementAtLinein interfaceIParseTree- Parameters:
iLineNum- The one based line number to check.clsSkip- A statement sublcass to ignore. Optional.- Returns:
- The first statement beginning at the specified line number, or null if no statements start at the line number.
-
addChild
Adds a child location to this location. Note the location must cover only a subset of this locations area.- Specified by:
addChildin interfaceIParseTree- Parameters:
l- The location to add.
-
addChild
-
removeChild
- Specified by:
removeChildin interfaceIParseTree
-
getChildren
- Specified by:
getChildrenin interfaceIParseTree- Returns:
- The list of child locations covered by this location.
-
getChildCount
public int getChildCount() -
setParent
Sets the parent location. Note the parent location must cover a superset of the specified location's area.- Specified by:
setParentin interfaceIParseTree- Parameters:
l- The parent location.
-
getParent
- Specified by:
getParentin interfaceIParseTree- Returns:
- This location's parent location. Note the parent covers a superset of the this location's area.
-
getParentOtherThanThis
Like getParent, but won't infinitely recurse if the parent turns out to be equal to this, which can happen when the expression in question is a program (since the outer program has the same location as the main statement).- Specified by:
getParentOtherThanThisin interfaceIParseTree
-
areOffsetAndExtentEqual
Is just the physical location equal?- Specified by:
areOffsetAndExtentEqualin interfaceIParseTree- Parameters:
location- Location to check- Returns:
- True if the given physical location's offset and extents are equal to this one's
-
toString
- Specified by:
toStringin interfaceIParseTree- Overrides:
toStringin classObject
-
initLocation
-
compactParseTree
public void compactParseTree() -
clearParseTreeInformation
public void clearParseTreeInformation()- Specified by:
clearParseTreeInformationin interfaceIParseTree
-
areAllChildrenAfterPosition
public boolean areAllChildrenAfterPosition(int caret) - Specified by:
areAllChildrenAfterPositionin interfaceIParseTree
-
getDominatingLocationList
- Specified by:
getDominatingLocationListin interfaceIParseTree
-
getChildrenBefore
- Specified by:
getChildrenBeforein interfaceIParseTree
-
isSiblingOf
- Specified by:
isSiblingOfin interfaceIParseTree
-
getChildAfter
- Specified by:
getChildAfterin interfaceIParseTree
-
getChildBefore
- Specified by:
getChildBeforein interfaceIParseTree
-
getChildBefore
- Specified by:
getChildBeforein interfaceIParseTree
-
getChildAfter
- Specified by:
getChildAfterin interfaceIParseTree
-
getFirstChildWithParsedElementType
- Specified by:
getFirstChildWithParsedElementTypein interfaceIParseTree
-
getLastChildWithParsedElementType
- Specified by:
getLastChildWithParsedElementTypein interfaceIParseTree
-
getLastChild
- Specified by:
getLastChildin interfaceIParseTree
-
getNextSibling
- Specified by:
getNextSiblingin interfaceIParseTree
-
getPreviousSibling
- Specified by:
getPreviousSiblingin interfaceIParseTree
-
getDeepestFirstChild
- Specified by:
getDeepestFirstChildin interfaceIParseTree
-
findDescendantsWithParsedElementType
- Specified by:
findDescendantsWithParsedElementTypein interfaceIParseTree
-
addUnder
- Specified by:
addUnderin interfaceIParseTree
-
adjustOffset
void adjustOffset(int offset, int lineNumOffset, int columnOffset) -
recursivelyAdjustOffset
private void recursivelyAdjustOffset(int offset, int lineNumOffset, int columnOffset) -
findDescendantsWithParsedElementType
-
getEnclosingFunctionStatement
- Specified by:
getEnclosingFunctionStatementin interfaceIParseTree
-
getMatchingElement
- Specified by:
getMatchingElementin interfaceIParseTree
-
getTreeOutline
-
getTreeOutline
-
appendTokensForOutline
-
getTextFromTokens
- Specified by:
getTextFromTokensin interfaceIParseTree
-
addTokens
-
getChildrenSorted
-
isAncestor
- Specified by:
isAncestorin interfaceIParseTree
-
getChild
-