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
public abstract class ParseIssue extends Exception implements IParseIssue
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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 positionThrowable
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.protected static String
formatError(ResourceKey key, Object... msgArgs)
int
getColumn()
String
getConsoleMessage()
String
getContextString()
String
getContextStringNoLineNumbers()
IType
getExpectedType()
int
getLine()
Integer
getLineNumber()
Integer
getLineOffset()
int
getLineReportingOffset()
Object[]
getMessageArgs()
ResourceKey
getMessageKey()
String
getPlainMessage()
IParsedElement
getSource()
Warning: Only valid if called from the parser thread.String
getStateSource()
ISymbolTable
getSymbolTable()
Warning: Only valid if called from the parser thread.Integer
getTokenColumn()
Integer
getTokenEnd()
Integer
getTokenStart()
String
getUIMessage()
static String
makeContextString(int lineOfError, String source, int lineReportingOffset)
void
resetPositions()
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
-
-
-
-
Constructor Detail
-
ParseIssue
protected ParseIssue(IParserState parserState, ResourceKey key, Object... msgArgs)
-
ParseIssue
protected ParseIssue(Integer lineNumber, Integer lineOffset, Integer tokenColumn, Integer tokenStart, Integer tokenEnd, ISymbolTable symbolTable, ResourceKey key, Object... msgArgs)
-
ParseIssue
protected ParseIssue(IParserState state, Throwable t)
-
-
Method Detail
-
fillInStackTrace
public Throwable 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
-
formatError
protected static String formatError(ResourceKey key, Object... msgArgs)
-
getLineNumber
public Integer getLineNumber()
-
getLineOffset
public Integer getLineOffset()
-
addLineOffset
public void addLineOffset(int offset)
-
getTokenColumn
public Integer getTokenColumn()
-
getTokenEnd
public Integer getTokenEnd()
- Specified by:
getTokenEnd
in interfaceIParseIssue
-
getTokenStart
public Integer getTokenStart()
- Specified by:
getTokenStart
in interfaceIParseIssue
-
getContextString
public String getContextString()
-
getContextStringNoLineNumbers
public String getContextStringNoLineNumbers()
-
getStateSource
public String getStateSource()
-
setStateSource
public void setStateSource(String parserSource)
-
getPlainMessage
public String getPlainMessage()
- Specified by:
getPlainMessage
in interfaceIParseIssue
- Returns:
- the raw message for this parse issue, with no formatting
-
getConsoleMessage
public String getConsoleMessage()
- Specified by:
getConsoleMessage
in interfaceIParseIssue
- Returns:
- the message for this parse issue formatted for printing out to a console
-
makeContextString
public static String makeContextString(int lineOfError, String source, int lineReportingOffset)
-
getUIMessage
public String 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
public IParsedElement 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
public void setSource(IParsedElement sourceOfError)
-
getSymbolTable
public ISymbolTable 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
public ResourceKey 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
public void resolve(IParserPart parserBase)
- 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
public void setMessage(ResourceKey key, Object... args)
-
getMessageArgs
public Object[] getMessageArgs()
- Specified by:
getMessageArgs
in interfaceIParseIssue
-
getLineReportingOffset
public int getLineReportingOffset()
-
getExpectedType
public IType getExpectedType()
- Specified by:
getExpectedType
in interfaceIParseIssue
-
-