Package gw.internal.gosu.parser
Class ParsedElement
java.lang.Object
gw.internal.gosu.parser.ParsedElement
- All Implemented Interfaces:
IParsedElement
- Direct Known Subclasses:
Expression
,Statement
ParsedElement is the root class for all non-terminal elements represented in
a parse tree i.e., all non-terminal expressions and statements derive either
directly or indirectly from this class.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate IGosuProgramInternal
private int
private int
private ParsedElement.LikelyNullFields
private ParseTree
private IParsedElement
private static final List<IParseTree>
static final String
static final String
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addParseException
(IFullParserState parserState, ResourceKey msgKey, Object... args) void
void
addParseException
(ResourceKey msgKey, Object... args) void
addParseExceptions
(List<IParseIssue> parseExceptions) void
addParseIssues
(List<IParseIssue> parseIssues) void
addParseWarning
(IParseIssue warning) void
addParseWarning
(ResourceKey msgKey, Object... args) void
addParseWarnings
(List<IParseIssue> parseWarnings) protected void
addToken
(IToken token, IParseTree after) void
adjustColumn
(int offset) void
adjustLineNum
(int offset) void
assignTokens
(List<Token> tokens) private void
assignTokensToJustMe
(List<Token> tokens) private int
binarySearchForFirstToken
(List<Token> tokens, int iTreeOffset, int iTreeEnd, boolean bZeroLengthTree) private static IParsedElementWithAtLeastOneDeclaration
checkIfDeclaringStatement
(IParsedElement parsedElement, String identifierName) void
void
void
void
private boolean
containsToken
(List<IToken> tokens, IToken target) private static boolean
elementIsOneOfType
(IParsedElement element, Class[] parsedElementClasses) findAncestorParsedElementByType
(Class... parsedElementClasses) findDeclaringStatement
(IParsedElement element, String identifierName) private static IParsedElementWithAtLeastOneDeclaration
findDeclaringStatementInChildren
(IParsedElement element, String identifierName) int
findLineNumberOfDeclaration
(String identifierName) int
<E extends IParsedElement>
booleangetContainedParsedElementsByType
(Class<E> parsedElementType, List<E> listResults) Find all the parsed elements of a given type contained within this parsed element.boolean
getContainedParsedElementsByTypes
(List<IParsedElement> listResults, Class<? extends IParsedElement>... parsedElementTypes) boolean
getContainedParsedElementsByTypesWithIgnoreSet
(List<IParsedElement> listResults, Set<Class<? extends IParsedElement>> ignoreSet, Class<? extends IParsedElement>... parsedElementTypes) static IFeatureInfo
getEnclosingFeatureInfo
(Stack<IFeatureInfo> enclosingFeatureInfos) getImmediateParseIssue
(ResourceKey errKey) int
private void
getParseExceptions
(List<IParseIssue> allParseExceptions) private void
getParseWarnings
(List<IParseIssue> allWarnings) static ITypeInfo
getQualifyingEnclosingTypeInfo
(Stack<IFeatureInfo> enclosingFeatureInfos) private String
boolean
hasImmediateParseIssue
(ResourceKey errKey) boolean
hasImmediateParseWarning
(ResourceKey errKey) boolean
boolean
hasParseException
(ResourceKey errKey) boolean
boolean
boolean
boolean
hasParseWarning
(ResourceKey errKey) boolean
void
initLocation
(int offset, int length, int lineNumber, int iColumn, IScriptPartId scriptPart) boolean
private boolean
isDescendent
(IParseTree after) boolean
isSuppressed
(IWarningSuppressor suppressor) boolean
isSuppressed
(IParseIssue issue) boolean
static double
makeDoubleValue
(Object obj) Just like makeDouble(), but creates a double primitive value instead of a Double object.static float
makeFloatValue
(Object obj) Just like makeFloat(), but creates a float primitive value instead of a Float object.final Integer
makeInteger
(Object obj) static Long
private void
removeParseException
(ResourceKey keyToRemove) Removes the specified parse exception or removes them all if the specified exception is null.private <E extends IParseIssue>
EremoveParseIssue
(ResourceKey keyToRemove, List<E> issues) removeParseWarning
(ResourceKey keyToRemove) void
removeParseWarningRecursively
(ResourceKey keyToRemove) void
setGosuProgram
(IGosuProgramInternal gosuProgram) void
setLineNum
(int iLineNum) void
setLocation
(IParseTree location) Specifiy the location of this parsed element within the source.void
setParent
(IParsedElement parent) void
setSynthetic
(boolean bSynthetic) boolean
void
visit
(Consumer<IParsedElement> visitor) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface gw.lang.parser.IParsedElement
getReturnType
-
Field Details
-
EMPTY_PARSETREE_LIST
-
UNDEF_MODULE
- See Also:
-
UNDEF_FUNCTION
- See Also:
-
UNDEF_FILE
- See Also:
-
_location
-
_parent
-
_iLineNum
private int _iLineNum -
_iColumn
private int _iColumn -
_lnf
-
_gosuProgram
-
_tokens
-
-
Constructor Details
-
ParsedElement
ParsedElement()
-
-
Method Details
-
getGosuProgram
- Specified by:
getGosuProgram
in interfaceIParsedElement
-
setGosuProgram
-
addExceptionsFrom
- Specified by:
addExceptionsFrom
in interfaceIParsedElement
-
maybeInitLikelyNullFields
private void maybeInitLikelyNullFields() -
getLocation
- Specified by:
getLocation
in interfaceIParsedElement
- Returns:
- The location of this parsed element within the source.
-
setLocation
Specifiy the location of this parsed element within the source.- Specified by:
setLocation
in interfaceIParsedElement
- Parameters:
location
- The location of this parsed element within the source.
-
initLocation
public ParseTree initLocation(int offset, int length, int lineNumber, int iColumn, IScriptPartId scriptPart) -
visit
- Specified by:
visit
in interfaceIParsedElement
-
initEmptyParseTree
public void initEmptyParseTree() -
hasParseIssues
public boolean hasParseIssues()- Specified by:
hasParseIssues
in interfaceIParsedElement
-
getParseIssues
- Specified by:
getParseIssues
in interfaceIParsedElement
-
getImmediateParseIssues
- Specified by:
getImmediateParseIssues
in interfaceIParsedElement
-
hasParseExceptions
public boolean hasParseExceptions()- Specified by:
hasParseExceptions
in interfaceIParsedElement
-
hasParseException
- Specified by:
hasParseException
in interfaceIParsedElement
-
getImmediateParseIssue
- Specified by:
getImmediateParseIssue
in interfaceIParsedElement
-
hasImmediateParseIssue
- Specified by:
hasImmediateParseIssue
in interfaceIParsedElement
-
hasParseWarning
- Specified by:
hasParseWarning
in interfaceIParsedElement
-
addParseWarnings
-
addParseExceptions
-
addParseIssues
-
getParseExceptions
- Specified by:
getParseExceptions
in interfaceIParsedElement
-
getParseExceptions
-
addParseException
- Specified by:
addParseException
in interfaceIParsedElement
-
addParseException
-
removeParseException
Removes the specified parse exception or removes them all if the specified exception is null. -
removeParseWarning
-
removeParseWarningRecursively
-
removeParseIssue
-
getSource
-
getGosuClass
- Specified by:
getGosuClass
in interfaceIParsedElement
-
addParseWarning
- Specified by:
addParseWarning
in interfaceIParsedElement
-
addParseException
- Specified by:
addParseException
in interfaceIParsedElement
-
clearParseExceptions
public void clearParseExceptions()- Specified by:
clearParseExceptions
in interfaceIParsedElement
-
clearParseWarnings
public void clearParseWarnings()- Specified by:
clearParseWarnings
in interfaceIParsedElement
-
hasImmediateParseWarnings
public boolean hasImmediateParseWarnings()- Specified by:
hasImmediateParseWarnings
in interfaceIParsedElement
-
hasImmediateParseWarning
-
hasParseWarnings
public boolean hasParseWarnings()- Specified by:
hasParseWarnings
in interfaceIParsedElement
-
getParseWarnings
- Specified by:
getParseWarnings
in interfaceIParsedElement
-
getParseWarnings
-
addParseWarning
- Specified by:
addParseWarning
in interfaceIParsedElement
-
hasParseIssue
- Specified by:
hasParseIssue
in interfaceIParsedElement
-
isSuppressed
-
isSuppressed
- Specified by:
isSuppressed
in interfaceIParsedElement
-
getAnnotations
-
isCompileTimeConstant
public boolean isCompileTimeConstant()- Specified by:
isCompileTimeConstant
in interfaceIParsedElement
-
getContainedParsedElementsByType
public <E extends IParsedElement> boolean getContainedParsedElementsByType(Class<E> parsedElementType, List<E> listResults) Find all the parsed elements of a given type contained within this parsed element.- Specified by:
getContainedParsedElementsByType
in interfaceIParsedElement
- Parameters:
parsedElementType
- The type of parsed element to find.listResults
- A list of all the contained parsed elements matching the specified type. Can be null if you are only interested in whether or not parsedElementType exists in this element.- Returns:
- True iff one or more parseElementType are found.
-
getContainedParsedElementsByTypes
public boolean getContainedParsedElementsByTypes(List<IParsedElement> listResults, Class<? extends IParsedElement>... parsedElementTypes) - Specified by:
getContainedParsedElementsByTypes
in interfaceIParsedElement
-
getContainedParsedElementsByTypesWithIgnoreSet
public boolean getContainedParsedElementsByTypesWithIgnoreSet(List<IParsedElement> listResults, Set<Class<? extends IParsedElement>> ignoreSet, Class<? extends IParsedElement>... parsedElementTypes) - Specified by:
getContainedParsedElementsByTypesWithIgnoreSet
in interfaceIParsedElement
-
makeInteger
-
makeLong
-
makeDoubleValue
Just like makeDouble(), but creates a double primitive value instead of a Double object. Much more efficient if you don't need the object.- Parameters:
obj
- Any double convertible object- Returns:
- The double primitive value.
-
makeFloatValue
Just like makeFloat(), but creates a float primitive value instead of a Float object. Much more efficient if you don't need the object.- Parameters:
obj
- Any float convertible object- Returns:
- The float primitive value.
-
compactParseTree
public void compactParseTree() -
clearParseTreeInformation
public void clearParseTreeInformation()- Specified by:
clearParseTreeInformation
in interfaceIParsedElement
-
getParent
- Specified by:
getParent
in interfaceIParsedElement
-
setParent
- Specified by:
setParent
in interfaceIParsedElement
-
getLineNum
public int getLineNum()- Specified by:
getLineNum
in interfaceIParsedElement
-
adjustLineNum
public void adjustLineNum(int offset) -
setLineNum
public void setLineNum(int iLineNum) -
getColumn
public int getColumn()- Specified by:
getColumn
in interfaceIParsedElement
-
adjustColumn
public void adjustColumn(int offset) -
getFunctionName
- Specified by:
getFunctionName
in interfaceIParsedElement
-
isSynthetic
public boolean isSynthetic()- Specified by:
isSynthetic
in interfaceIParsedElement
-
setSynthetic
public void setSynthetic(boolean bSynthetic) -
getModule
- Specified by:
getModule
in interfaceIParsedElement
-
getEnclosingFeatureInfo
-
getQualifyingEnclosingTypeInfo
-
findLineNumberOfDeclaration
-
findDeclaringStatement
public IParsedElementWithAtLeastOneDeclaration findDeclaringStatement(IParsedElement element, String identifierName) - Specified by:
findDeclaringStatement
in interfaceIParsedElement
-
findDeclaringStatementInChildren
private static IParsedElementWithAtLeastOneDeclaration findDeclaringStatementInChildren(IParsedElement element, String identifierName) -
checkIfDeclaringStatement
private static IParsedElementWithAtLeastOneDeclaration checkIfDeclaringStatement(IParsedElement parsedElement, String identifierName) -
findRootParsedElement
- Specified by:
findRootParsedElement
in interfaceIParsedElement
-
findAncestorParsedElementByType
- Specified by:
findAncestorParsedElementByType
in interfaceIParsedElement
- Parameters:
parsedElementClasses
- List of statement types to find- Returns:
- The nearest ancestor statement that is any one of the given types. null if this element does not have an ancestor of any of the given types
-
elementIsOneOfType
-
shouldClearParseInfo
public boolean shouldClearParseInfo() -
assignTokens
-
addToken
-
getTokens
- Specified by:
getTokens
in interfaceIParsedElement
-
assignTokensToJustMe
-
binarySearchForFirstToken
-
containsToken
-
isDescendent
-