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 Integer
private Integer
private Object[]
private ResourceKey
private IGosuClass
private IParsedElement
private String
private ISymbolTable
private Integer
private Integer
private Integer
private static final int
private static final String
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ParseIssue
(IParserState parserState, ResourceKey key, Object... msgArgs) protected
ParseIssue
(IParserState state, Throwable t) protected
ParseIssue
(Integer lineNumber, Integer lineOffset, Integer tokenColumn, Integer tokenStart, Integer tokenEnd, ISymbolTable symbolTable, ResourceKey key, Object... msgArgs) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLineOffset
(int offset) void
adjustOffset
(int offset, int lineNumOffset, int columnOffset) boolean
appliesToPosition
(int iPos) Returns true if this issue is relevant to the given positionprivate void
debug()
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 String
formatError
(ResourceKey key, Object... msgArgs) int
int
getLine()
int
Object[]
private String
Warning: Only valid if called from the parser thread.Warning: Only valid if called from the parser thread.private void
initFieldsFromParserState
(IParserState parserState) static String
makeContextString
(int lineOfError, String source, int lineReportingOffset) private static String
makeContextString
(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.void
void
resolve
(IParserPart parserBase) void
setMessage
(ResourceKey key, Object... args) void
setSource
(IParsedElement sourceOfError) void
setStateSource
(String parserSource) Methods inherited from class java.lang.Throwable
addSuppressed, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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:
fillInStackTrace
in 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:
getTokenEnd
in interfaceIParseIssue
-
getTokenStart
- Specified by:
getTokenStart
in interfaceIParseIssue
-
getContextString
-
getContextStringNoLineNumbers
-
getStateSource
-
setStateSource
-
getMyMessage
-
getPlainMessage
- Specified by:
getPlainMessage
in interfaceIParseIssue
- Returns:
- the raw message for this parse issue, with no formatting
-
getConsoleMessage
- Specified by:
getConsoleMessage
in interfaceIParseIssue
- Returns:
- the message for this parse issue formatted for printing out to a console
-
makeContextString
-
makeContextString
-
getUIMessage
- Specified by:
getUIMessage
in interfaceIParseIssue
- Returns:
- the message formatted for use by an IDE
-
getLine
public int getLine()- Specified by:
getLine
in interfaceIParseIssue
- Returns:
- the line that this issue is on
-
getColumn
public int getColumn()- Specified by:
getColumn
in interfaceIParseIssue
-
getSource
Warning: Only valid if called from the parser thread. Otherwise we null it out.- Specified by:
getSource
in 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:
getSymbolTable
in 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:IParseIssue
Returns true if this issue is relevant to the given position- Specified by:
appliesToPosition
in interfaceIParseIssue
-
getMessageKey
- Specified by:
getMessageKey
in 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:
resolve
in interfaceIParseIssue
-
resetPositions
public void resetPositions()- Specified by:
resetPositions
in interfaceIParseIssue
-
adjustOffset
public void adjustOffset(int offset, int lineNumOffset, int columnOffset) -
setMessage
-
getMessageArgs
- Specified by:
getMessageArgs
in interfaceIParseIssue
-
getLineReportingOffset
public int getLineReportingOffset() -
getExpectedType
- Specified by:
getExpectedType
in interfaceIParseIssue
-