Package gw.internal.gosu.parser
Class ParsedElement
- java.lang.Object
-
- gw.internal.gosu.parser.ParsedElement
-
- All Implemented Interfaces:
IParsedElement
- Direct Known Subclasses:
Expression
,Statement
public abstract class ParsedElement extends Object implements IParsedElement
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.
-
-
Field Summary
Fields Modifier and Type Field Description protected List<IToken>
_tokens
static String
UNDEF_FILE
static String
UNDEF_FUNCTION
static String
UNDEF_MODULE
-
Method Summary
-
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 Detail
-
UNDEF_MODULE
public static final String UNDEF_MODULE
- See Also:
- Constant Field Values
-
UNDEF_FUNCTION
public static final String UNDEF_FUNCTION
- See Also:
- Constant Field Values
-
UNDEF_FILE
public static final String UNDEF_FILE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getGosuProgram
public IGosuProgramInternal getGosuProgram()
- Specified by:
getGosuProgram
in interfaceIParsedElement
-
setGosuProgram
public void setGosuProgram(IGosuProgramInternal gosuProgram)
-
addExceptionsFrom
public void addExceptionsFrom(IParsedElement elem)
- Specified by:
addExceptionsFrom
in interfaceIParsedElement
-
getLocation
public ParseTree getLocation()
- Specified by:
getLocation
in interfaceIParsedElement
- Returns:
- The location of this parsed element within the source.
-
setLocation
public void setLocation(IParseTree location)
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
public void visit(Consumer<IParsedElement> visitor)
- Specified by:
visit
in interfaceIParsedElement
-
initEmptyParseTree
public void initEmptyParseTree()
-
hasParseIssues
public boolean hasParseIssues()
- Specified by:
hasParseIssues
in interfaceIParsedElement
-
getParseIssues
public List<IParseIssue> getParseIssues()
- Specified by:
getParseIssues
in interfaceIParsedElement
-
getImmediateParseIssues
public List<IParseIssue> getImmediateParseIssues()
- Specified by:
getImmediateParseIssues
in interfaceIParsedElement
-
hasParseExceptions
public boolean hasParseExceptions()
- Specified by:
hasParseExceptions
in interfaceIParsedElement
-
hasParseException
public boolean hasParseException(ResourceKey errKey)
- Specified by:
hasParseException
in interfaceIParsedElement
-
getImmediateParseIssue
public IParseIssue getImmediateParseIssue(ResourceKey errKey)
- Specified by:
getImmediateParseIssue
in interfaceIParsedElement
-
hasImmediateParseIssue
public boolean hasImmediateParseIssue(ResourceKey errKey)
- Specified by:
hasImmediateParseIssue
in interfaceIParsedElement
-
hasParseWarning
public boolean hasParseWarning(ResourceKey errKey)
- Specified by:
hasParseWarning
in interfaceIParsedElement
-
addParseWarnings
public void addParseWarnings(List<IParseIssue> parseWarnings)
-
addParseExceptions
public void addParseExceptions(List<IParseIssue> parseExceptions)
-
addParseIssues
public void addParseIssues(List<IParseIssue> parseIssues)
-
getParseExceptions
public List<IParseIssue> getParseExceptions()
- Specified by:
getParseExceptions
in interfaceIParsedElement
-
addParseException
public void addParseException(ResourceKey msgKey, Object... args)
- Specified by:
addParseException
in interfaceIParsedElement
-
addParseException
public void addParseException(IFullParserState parserState, ResourceKey msgKey, Object... args)
-
removeParseException
public ParseException removeParseException(ResourceKey keyToRemove)
Removes the specified parse exception or removes them all if the specified exception is null.
-
removeParseWarning
public ParseWarning removeParseWarning(ResourceKey keyToRemove)
-
removeParseWarningRecursively
public void removeParseWarningRecursively(ResourceKey keyToRemove)
-
getGosuClass
public IGosuClass getGosuClass()
- Specified by:
getGosuClass
in interfaceIParsedElement
-
addParseWarning
public void addParseWarning(ResourceKey msgKey, Object... args)
- Specified by:
addParseWarning
in interfaceIParsedElement
-
addParseException
public void addParseException(IParseIssue pe)
- 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
public boolean hasImmediateParseWarning(ResourceKey errKey)
-
hasParseWarnings
public boolean hasParseWarnings()
- Specified by:
hasParseWarnings
in interfaceIParsedElement
-
getParseWarnings
public List<IParseIssue> getParseWarnings()
- Specified by:
getParseWarnings
in interfaceIParsedElement
-
addParseWarning
public void addParseWarning(IParseIssue warning)
- Specified by:
addParseWarning
in interfaceIParsedElement
-
hasParseIssue
public boolean hasParseIssue(IParseIssue pi)
- Specified by:
hasParseIssue
in interfaceIParsedElement
-
isSuppressed
public boolean isSuppressed(IParseIssue issue)
-
isSuppressed
public boolean isSuppressed(IWarningSuppressor suppressor)
- Specified by:
isSuppressed
in interfaceIParsedElement
-
getAnnotations
public List<IGosuAnnotation> 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
-
makeDoubleValue
public static double makeDoubleValue(Object obj)
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
public static float makeFloatValue(Object obj)
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
public IParsedElement getParent()
- Specified by:
getParent
in interfaceIParsedElement
-
setParent
public void setParent(IParsedElement parent)
- 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
public String getFunctionName()
- Specified by:
getFunctionName
in interfaceIParsedElement
-
isSynthetic
public boolean isSynthetic()
- Specified by:
isSynthetic
in interfaceIParsedElement
-
setSynthetic
public void setSynthetic(boolean bSynthetic)
-
getModule
public IModule getModule()
- Specified by:
getModule
in interfaceIParsedElement
-
getEnclosingFeatureInfo
public static IFeatureInfo getEnclosingFeatureInfo(Stack<IFeatureInfo> enclosingFeatureInfos)
-
getQualifyingEnclosingTypeInfo
public static ITypeInfo getQualifyingEnclosingTypeInfo(Stack<IFeatureInfo> enclosingFeatureInfos)
-
findLineNumberOfDeclaration
public int findLineNumberOfDeclaration(String identifierName)
-
findDeclaringStatement
public IParsedElementWithAtLeastOneDeclaration findDeclaringStatement(IParsedElement element, String identifierName)
- Specified by:
findDeclaringStatement
in interfaceIParsedElement
-
findRootParsedElement
public IParsedElement findRootParsedElement()
- Specified by:
findRootParsedElement
in interfaceIParsedElement
-
findAncestorParsedElementByType
public IParsedElement findAncestorParsedElementByType(Class... parsedElementClasses)
- 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
-
shouldClearParseInfo
public boolean shouldClearParseInfo()
-
addToken
protected void addToken(IToken token, IParseTree after)
-
getTokens
public List<IToken> getTokens()
- Specified by:
getTokens
in interfaceIParsedElement
-
-