Package io.github.qishr.cascara.common.diagnostic
Interface Reporter
java.lang.Object
io.github.qishr.cascara.common.diagnostic.Reporter
All Known Implementing Classes:
SilentErrorTracker, NoOpReporter, AbstractReporter
public interface Reporter
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
| public abstract Reporter | setLevel(Level level) | Sets the level of output when logging directly to the console. |
| public abstract Reporter | setDiagnosticCollector(Consumer<Diagnostic> collector) | Registers a collector to receive all diagnostics processed by this reporter. |
| public abstract Reporter | setProblemCollector(Consumer<Diagnostic> collector) | Registers a specialized collector to receive only problem-level diagnostics. |
| public abstract boolean | collectsProblems() | Checks whether any active listener or collector is tracking problems. |
| public abstract void | trace(String format, Object[] args) | Reports a trace message through the reporter. |
| public abstract void | debug(String format, Object[] args) | Reports a debug message through the reporter. |
| public abstract void | info(String format, Object[] args) | Reports an informational message through the reporter. |
| public abstract void | warn(String code, String format, Object[] args) | Reports a warning message including location information. |
| public abstract void | error(String code, String format, Object[] args) | Reports an error message including location information. |
| public abstract void | infoAt(int line, int column, String format, Object[] args) | Reports an informational message anchored to a resource location by line and column. |
| public abstract void | warnAt(int line, int column, String code, String format, Object[] args) | Reports a warning anchored to a resource location by line and column. |
| public abstract void | errorAt(int line, int column, String code, String format, Object[] args) | Reports an error anchored to a resource location by line and column. |
| public abstract void | infoAt(int line, int column, int start, int end, String format, Object[] args) | Reports an informational message anchored to a precise character span within a resource. |
| public abstract void | warnAt(int line, int column, int start, int end, String code, String format, Object[] args) | Reports a warning anchored to a precise character span within a resource. |
| public abstract void | errorAt(int line, int column, int start, int end, String code, String format, Object[] args) | Reports an error anchored to a precise character span within a resource. |
| public abstract void | infoAt(Token token, String format, Object[] args) | Reports an informational message derived from the location attributes of a structural token. |
| public abstract void | warnAt(Token token, String code, String format, Object[] args) | Reports a warning derived from the location attributes of a structural token. |
| public abstract void | errorAt(Token token, String code, String format, Object[] args) | Reports an error derived from the location attributes of a structural token. |
Method Details
setLevel
public abstract Reporter setLevel(Level level)
Sets the level of output when logging directly to the console.
setDiagnosticCollector
public abstract Reporter setDiagnosticCollector(Consumer<Diagnostic> collector)
Registers a collector to receive all diagnostics processed by this reporter.This includes debugging info, trace states, warnings, and error diagnostics.
Parameters:
collector - The consumer that processes each produced Diagnostic.
setProblemCollector
public abstract Reporter setProblemCollector(Consumer<Diagnostic> collector)
Registers a specialized collector to receive only problem-level diagnostics.This collector is filtered to intercept only Level.WARN and Level.ERROR items.
Parameters:
collector - The consumer that processes problem Diagnostic objects.
collectsProblems
public abstract boolean collectsProblems()
Checks whether any active listener or collector is tracking problems.This can be used as an optimization flag by sub-parsers or AST-walkers to skip expensive location token captures or contextual allocations if nobody is actively listening for error diagnostics.
Returns:
true if warnings or errors are being collected, otherwise false.
trace
public abstract void trace(String format, Object[] args)
Reports a trace message through the reporter.
Parameters:
format - The format of the message to report.
args - Arguments referenced by the format specifiers in the format string.
If the last argument is a Throwable, it will not be used in message formatting
and will instead become a field in the Diagnostic produced by this call.
debug
public abstract void debug(String format, Object[] args)
Reports a debug message through the reporter.
Parameters:
format - The format of the message to report.
args - Arguments referenced by the format specifiers in the format string.
If the last argument is a Throwable, it will not be used in message formatting
and will instead become a field in the Diagnostic produced by this call.
info
public abstract void info(String format, Object[] args)
Reports an informational message through the reporter.
Parameters:
format - The format of the message to report.
args - Arguments referenced by the format specifiers in the format string.
If the last argument is a Throwable, it will not be used in message formatting
and will instead become a field in the Diagnostic produced by this call.
warn
public abstract void warn(String code, String format, Object[] args)
Reports a warning message including location information.
Parameters:
code - The code of this warning.
format - The format of the message to report.
args - Arguments referenced by the format specifiers in the format string.
If the last argument is a Throwable, it will not be used in message formatting
and will instead become a field in the Diagnostic produced by this call.
error
public abstract void error(String code, String format, Object[] args)
Reports an error message including location information.
Parameters:
code - The code of this error.
format - The format of the message to report.
args - Arguments referenced by the format specifiers in the format string.
If the last argument is a Throwable, it will not be used in message formatting
and will instead become a field in the Diagnostic produced by this call.
infoAt
public abstract void infoAt(int line, int column, String format, Object[] args)
Reports an informational message anchored to a resource location by line and column.Useful when text stream indices are unavailable.
Parameters:
line - The 1-based line number of the diagnostic.
column - The 1-based column number of the diagnostic.
format - The format string.
args - Arguments for the format string. If the last argument is a Throwable,
it maps directly to the diagnostic's cause.
warnAt
public abstract void warnAt(int line, int column, String code, String format, Object[] args)
Reports a warning anchored to a resource location by line and column.Useful when text stream indices are unavailable.
Parameters:
line - The 1-based line number of the diagnostic.
column - The 1-based column number of the diagnostic.
code - The semantic classification code for this warning.
format - The format string.
args - Arguments for the format string. If the last argument is a Throwable,
it maps directly to the diagnostic's cause.
errorAt
public abstract void errorAt(int line, int column, String code, String format, Object[] args)
Reports an error anchored to a resource location by line and column.Useful when text stream indices are unavailable.
Parameters:
line - The 1-based line number of the diagnostic.
column - The 1-based column number of the diagnostic.
code - The semantic classification code for this error.
format - The format string.
args - Arguments for the format string. If the last argument is a Throwable,
it maps directly to the diagnostic's cause.
infoAt
public abstract void infoAt(int line, int column, int start, int end, String format, Object[] args)
Reports an informational message anchored to a precise character span within a resource.
Parameters:
line - The 1-based line number of the diagnostic.
column - The 1-based column number of the diagnostic.
start - The 0-based absolute character index indicating the start of the span.
end - The 0-based absolute character index indicating the end of the span (exclusive).
format - The format string.
args - Arguments for the format string. If the last argument is a Throwable,
it maps directly to the diagnostic's cause.
warnAt
public abstract void warnAt(int line, int column, int start, int end, String code, String format, Object[] args)
Reports a warning anchored to a precise character span within a resource.
Parameters:
line - The 1-based line number of the diagnostic.
column - The 1-based column number of the diagnostic.
start - The 0-based absolute character index indicating the start of the span.
end - The 0-based absolute character index indicating the end of the span (exclusive).
code - The semantic classification code for this warning.
format - The format string.
args - Arguments for the format string. If the last argument is a Throwable,
it maps directly to the diagnostic's cause.
errorAt
public abstract void errorAt(int line, int column, int start, int end, String code, String format, Object[] args)
Reports an error anchored to a precise character span within a resource.
Parameters:
line - The 1-based line number of the diagnostic.
column - The 1-based column number of the diagnostic.
start - The 0-based absolute character index indicating the start of the span.
end - The 0-based absolute character index indicating the end of the span (exclusive).
code - The semantic classification code for this error.
format - The format string.
args - Arguments for the format string. If the last argument is a Throwable,
it maps directly to the diagnostic's cause.
infoAt
public abstract void infoAt(Token token, String format, Object[] args)
Reports an informational message derived from the location attributes of a structural token.
Parameters:
token - The syntactic Token supplying the positional bounds.
format - The format string.
args - Arguments for the format string. If the last argument is a Throwable,
it maps directly to the diagnostic's cause.
warnAt
public abstract void warnAt(Token token, String code, String format, Object[] args)
Reports a warning derived from the location attributes of a structural token.
Parameters:
token - The syntactic Token supplying the positional bounds.
code - The semantic classification code for this warning.
format - The format string.
args - Arguments for the format string. If the last argument is a Throwable,
it maps directly to the diagnostic's cause.
errorAt
public abstract void errorAt(Token token, String code, String format, Object[] args)
Reports an error derived from the location attributes of a structural token.
Parameters:
token - The syntactic Token supplying the positional bounds.
code - The semantic classification code for this error.
format - The format string.
args - Arguments for the format string. If the last argument is a Throwable,
it maps directly to the diagnostic's cause.