Package gw.lang.parser.exceptions
Class ParseIssue
java.lang.Object
java.lang.Throwable
java.lang.Exception
gw.lang.parser.exceptions.ParseIssue
- All Implemented Interfaces:
IParseIssue,Serializable
- Direct Known Subclasses:
ParseException,ParseWarning
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Integerprivate Integerprivate Object[]private ResourceKeyprivate IGosuClassprivate IParsedElementprivate Stringprivate ISymbolTableprivate Integerprivate Integerprivate Integerprivate static final intprivate static final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedParseIssue(IParserState parserState, ResourceKey key, Object... msgArgs) protectedParseIssue(IParserState state, Throwable t) protectedParseIssue(Integer lineNumber, Integer lineOffset, Integer tokenColumn, Integer tokenStart, Integer tokenEnd, ISymbolTable symbolTable, ResourceKey key, Object... msgArgs) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLineOffset(int offset) voidadjustOffset(int offset, int lineNumOffset, int columnOffset) booleanappliesToPosition(int iPos) Returns true if this issue is relevant to the given positionprivate voiddebug()Don't fill in stack trace since parse issues are not really "exceptional" in terms of the parser's Java implementation; we don't care much about the Java stack trace when these are thrown.protected static StringformatError(ResourceKey key, Object... msgArgs) intintgetLine()intObject[]private StringWarning: Only valid if called from the parser thread.Warning: Only valid if called from the parser thread.private voidinitFieldsFromParserState(IParserState parserState) static StringmakeContextString(int lineOfError, String source, int lineReportingOffset) private static StringmakeContextString(int lineOfError, String source, int lineReportingOffset, boolean showLineNumbers) private Object[]normalizeMessageArgs(Object[] args) Normalize all non string & non number args to string types to prevent race conditions wrt/ the TypeSystem lock when the message is formatted.voidvoidresolve(IParserPart parserBase) voidsetMessage(ResourceKey key, Object... args) voidsetSource(IParsedElement sourceOfError) voidsetStateSource(String parserSource) Methods inherited from class java.lang.Throwable
addSuppressed, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface gw.lang.parser.IParseIssue
printStackTrace, setExpectedType
-
Field Details
-
SOURCE_DELIMITER
- See Also:
-
CONTEXT_LINES
private static final int CONTEXT_LINES- See Also:
-
_lineNumber
-
_lineOffset
-
_tokenColumn
-
_tokenStart
-
_tokenEnd
-
_messageKey
-
_messageArgs
-
_symbolTable
-
_parentElement
-
_stateSource
-
_parentClass
-
-
Constructor Details
-
ParseIssue
-
ParseIssue
protected ParseIssue(Integer lineNumber, Integer lineOffset, Integer tokenColumn, Integer tokenStart, Integer tokenEnd, ISymbolTable symbolTable, ResourceKey key, Object... msgArgs) -
ParseIssue
-
-
Method Details
-
debug
private void debug() -
fillInStackTrace
Don't fill in stack trace since parse issues are not really "exceptional" in terms of the parser's Java implementation; we don't care much about the Java stack trace when these are thrown. Rather parse issues provide a means to tag parsed elements with issues discovered during parsing, such as syntax warnings and errors. Hence, the ParseIssue interface. Note this method is otherwise very costly from a performance standpoint.- Overrides:
fillInStackTracein classThrowable
-
initFieldsFromParserState
-
normalizeMessageArgs
Normalize all non string & non number args to string types to prevent race conditions wrt/ the TypeSystem lock when the message is formatted. -
formatError
-
getLineNumber
-
getLineOffset
-
addLineOffset
public void addLineOffset(int offset) -
getTokenColumn
-
getTokenEnd
- Specified by:
getTokenEndin interfaceIParseIssue
-
getTokenStart
- Specified by:
getTokenStartin interfaceIParseIssue
-
getContextString
-
getContextStringNoLineNumbers
-
getStateSource
-
setStateSource
-
getMyMessage
-
getPlainMessage
- Specified by:
getPlainMessagein interfaceIParseIssue- Returns:
- the raw message for this parse issue, with no formatting
-
getConsoleMessage
- Specified by:
getConsoleMessagein interfaceIParseIssue- Returns:
- the message for this parse issue formatted for printing out to a console
-
makeContextString
-
makeContextString
-
getUIMessage
- Specified by:
getUIMessagein interfaceIParseIssue- Returns:
- the message formatted for use by an IDE
-
getLine
public int getLine()- Specified by:
getLinein interfaceIParseIssue- Returns:
- the line that this issue is on
-
getColumn
public int getColumn()- Specified by:
getColumnin interfaceIParseIssue
-
getSource
Warning: Only valid if called from the parser thread. Otherwise we null it out.- Specified by:
getSourcein interfaceIParseIssue- Returns:
- the parsed element that this issue is associated with
-
setSource
-
getSymbolTable
Warning: Only valid if called from the parser thread. Otherwise we null it out.- Specified by:
getSymbolTablein interfaceIParseIssue- Returns:
- the symbol table state at the creation of this issue. Can return null if no symbol table is present.
-
appliesToPosition
public boolean appliesToPosition(int iPos) Description copied from interface:IParseIssueReturns true if this issue is relevant to the given position- Specified by:
appliesToPositionin interfaceIParseIssue
-
getMessageKey
- Specified by:
getMessageKeyin interfaceIParseIssue- Returns:
- the resource key for this ParseIssue, which can be used as a kind of identifier for the type of issue.
-
resolve
- Specified by:
resolvein interfaceIParseIssue
-
resetPositions
public void resetPositions()- Specified by:
resetPositionsin interfaceIParseIssue
-
adjustOffset
public void adjustOffset(int offset, int lineNumOffset, int columnOffset) -
setMessage
-
getMessageArgs
- Specified by:
getMessageArgsin interfaceIParseIssue
-
getLineReportingOffset
public int getLineReportingOffset() -
getExpectedType
- Specified by:
getExpectedTypein interfaceIParseIssue
-