Skip to content

Package io.github.qishr.cascara.common.diagnostic

Class AbstractReporter

java.lang.Object
        io.github.qishr.cascara.common.diagnostic.AbstractReporter

All Implemented Interfaces:
    Reporter

Direct Known Subtypes:
    SilentCollectingReporter, GlobalReporter, StandardReporter


public abstract class AbstractReporter

Field Summary

Modifier and Type Field Description
protected static final boolean CAN_USE_ANSI_COLORING
protected boolean ansiColoringEnabled
protected Consumer diagnosticConsumer Consumes diagnostics included in the current Level or more important, with ERROR being the most important.
protected boolean flushEnabled
protected Level level
protected static final String[] levelColors
protected Consumer lineConsumer Consumes every line of diagnostic output as a String.
protected boolean prefixEveryLine
protected Consumer problemConsumer Consumes ERROR, WARN, and INFO diagnostics.
protected boolean showProblemCodes
protected String source The simple name of the class that made the report
protected boolean stackTraceEnabled
protected boolean systemErrorEnabled
protected boolean systemOutputEnabled
protected ReportWriter[] writers

Constructor Summary

Constructor Description
AbstractReporter()
AbstractReporter(Consumer<String> logger)

Method Summary

Modifier and Type Method Description
protected abstract T self()
public boolean collectsProblems() Checks whether any active listener or collector is tracking problems.
public T setLevel(Level level) Sets the level of output when logging directly to the console.
public T setLineConsumer(Consumer<String> logger)
public T setDiagnosticConsumer(Consumer<Diagnostic> collector) Registers a collector to receive all diagnostics processed by this reporter.
public T setProblemConsumer(Consumer<Diagnostic> collector) Registers a specialized collector to receive only problem-level diagnostics.
public T setSystemOutputEnabled(boolean b)
public T setFlushEnabled(boolean b)
public T setStackTraceEnabled(boolean b)
public T setSystemErrorEnabled(boolean b)
public T setAnsiColoringEnabled(boolean b)
public T setPrefixEveryLine(boolean b)
public T setShowProblemCodes(boolean b)
public Level getLevel()
public boolean isSilent()
public ReportWriter getWriter(Level level)
public void error(Exception e) Reports an Exception
public void trace(String message, Object[] details) Reports a trace message through the reporter.
public void debug(String message, Object[] details) Reports a debug message through the reporter.
public void info(DiagnosticCode code, Object[] details) Reports an informational message through the reporter.
public void warn(DiagnosticCode code, Object[] details) Reports a warning message including location information.
public void error(DiagnosticCode code, Object[] details) Reports an error message including location information.
public void error(Throwable cause, DiagnosticCode code, Object[] details) Reports an error message including location information.
public void infoAt(int line, int column, DiagnosticCode code, Object[] details) Reports an informational message anchored to a resource location by line and column.
public void warnAt(int line, int column, DiagnosticCode code, Object[] details) Reports a warning anchored to a resource location by line and column.
public void errorAt(int line, int column, DiagnosticCode code, Object[] details) Reports an error anchored to a resource location by line and column.
public void errorAt(int line, int column, Throwable cause, DiagnosticCode code, Object[] details) Reports an error anchored to a resource location by line and column.
public void infoAt(int line, int column, int startOffset, int endOffset, DiagnosticCode code, Object[] details) Reports an informational message anchored to a precise character span within a resource.
public void warnAt(int line, int column, int startOffset, int endOffset, DiagnosticCode code, Object[] details) Reports a warning anchored to a precise character span within a resource.
public void errorAt(int line, int column, int startOffset, int endOffset, DiagnosticCode code, Object[] details) Reports an error anchored to a precise character span within a resource.
public void errorAt(int line, int column, int startOffset, int endOffset, Throwable cause, DiagnosticCode code, Object[] details) Reports an error anchored to a precise character span within a resource.
public void infoAt(Token token, DiagnosticCode code, Object[] details) Reports an informational message derived from the location attributes of a structural token.
public void warnAt(Token token, DiagnosticCode code, Object[] details) Reports a warning derived from the location attributes of a structural token.
public void errorAt(Token token, DiagnosticCode code, Object[] details) Reports an error derived from the location attributes of a structural token.
public void errorAt(Token token, Throwable cause, DiagnosticCode code, Object[] details) Reports an error derived from the location attributes of a structural token.
public void warnAt(URI uri, int line, int column, DiagnosticCode code, Object[] details)
public void errorAt(URI uri, int line, int column, DiagnosticCode code, Object[] details)
public void warnAt(URI uri, Token token, DiagnosticCode code, Object[] details)
public void errorAt(URI uri, Token token, DiagnosticCode code, Object[] details)
public void errorAt(URI uri, Token token, Throwable t, DiagnosticCode code, Object[] details)
protected abstract String formatMessage(Diagnostic diagnostic, String line, int lineNumber, boolean ansiColoring)
protected Consumer<Diagnostic> getDiagnosticConsumer()
protected Consumer<Diagnostic> getProblemConsumer()
protected Consumer<String> getLineConsumer()
protected boolean isSystemOutputEnabled()
protected boolean isFlushEnabled()
protected boolean isStackTraceEnabled()
protected void report(Diagnostic diagnostic)
protected void writeString(Diagnostic diagnostic)
protected void logLine(Level level, String msgLine, int msgLineNumber)
protected void displayLine(Level diagnosticLevel, String msgLine, int msgLineNumber)
protected Diagnostic buildDiagnostic(String source, Level level, String message, Object[] details) With message string
protected Diagnostic buildDiagnostic(String source, Level level, Throwable cause, DiagnosticCode code, Object[] details) With diagnostic code, and cause
protected Diagnostic buildDiagnostic(URI uri, int line, int column, int startOffset, int endOffset, String source, Level level, Throwable cause, DiagnosticCode code, Object[] details) With diagnostic code, location, and cause
protected Diagnostic buildDiagnostic(Token token, String source, Level level, Throwable cause, DiagnosticCode code, Object[] details) With diagnostic code, token, and cause
protected boolean isProblem(Level level)
public boolean reportsDebug()
public boolean reportsTrace()

Field Details

CAN_USE_ANSI_COLORING

protected static final boolean CAN_USE_ANSI_COLORING


ansiColoringEnabled

protected boolean ansiColoringEnabled


diagnosticConsumer

protected Consumer diagnosticConsumer

Consumes diagnostics included in the current Level or more important, with ERROR being the most important.


flushEnabled

protected boolean flushEnabled


level

protected Level level


levelColors

protected static final String[] levelColors


lineConsumer

protected Consumer lineConsumer

Consumes every line of diagnostic output as a String.


prefixEveryLine

protected boolean prefixEveryLine


problemConsumer

protected Consumer problemConsumer

Consumes ERROR, WARN, and INFO diagnostics.


showProblemCodes

protected boolean showProblemCodes


source

protected String source

The simple name of the class that made the report


stackTraceEnabled

protected boolean stackTraceEnabled


systemErrorEnabled

protected boolean systemErrorEnabled


systemOutputEnabled

protected boolean systemOutputEnabled


writers

protected ReportWriter[] writers


Method Details

self

protected abstract T self()


collectsProblems

public boolean collectsProblems()

Checks whether any active listener or collector is tracking problems.

Specified By:

Reporter


setLevel

public T setLevel(Level level)

Sets the level of output when logging directly to the console.

Specified By:

Reporter


setLineConsumer

public T setLineConsumer(Consumer<String> logger)

Specified By:

Reporter


setDiagnosticConsumer

public T setDiagnosticConsumer(Consumer<Diagnostic> collector)

Registers a collector to receive all diagnostics processed by this reporter.

Specified By:

Reporter


setProblemConsumer

public T setProblemConsumer(Consumer<Diagnostic> collector)

Registers a specialized collector to receive only problem-level diagnostics.

Specified By:

Reporter


setSystemOutputEnabled

public T setSystemOutputEnabled(boolean b)


setFlushEnabled

public T setFlushEnabled(boolean b)


setStackTraceEnabled

public T setStackTraceEnabled(boolean b)


setSystemErrorEnabled

public T setSystemErrorEnabled(boolean b)


setAnsiColoringEnabled

public T setAnsiColoringEnabled(boolean b)


setPrefixEveryLine

@io.github.qishr.cascara.common.annotation.Experimental
public T setPrefixEveryLine(boolean b)


setShowProblemCodes

public T setShowProblemCodes(boolean b)


getLevel

public Level getLevel()

Specified By:

Reporter


isSilent

public boolean isSilent()

Specified By:

Reporter


getWriter

public ReportWriter getWriter(Level level)

Specified By:

Reporter


error

public void error(Exception e)

Reports an Exception

Specified By:

Reporter


trace

public void trace(String message, Object[] details)

Reports a trace message through the reporter.

Specified By:

Reporter


debug

public void debug(String message, Object[] details)

Reports a debug message through the reporter.

Specified By:

Reporter


info

public void info(DiagnosticCode code, Object[] details)

Reports an informational message through the reporter.

Specified By:

Reporter


warn

public void warn(DiagnosticCode code, Object[] details)

Reports a warning message including location information.

Specified By:

Reporter


error

public void error(DiagnosticCode code, Object[] details)

Reports an error message including location information.

Specified By:

Reporter


error

public void error(Throwable cause, DiagnosticCode code, Object[] details)

Reports an error message including location information.

Specified By:

Reporter


infoAt

public void infoAt(int line, int column, DiagnosticCode code, Object[] details)

Reports an informational message anchored to a resource location by line and column.

Specified By:

Reporter


warnAt

public void warnAt(int line, int column, DiagnosticCode code, Object[] details)

Reports a warning anchored to a resource location by line and column.

Specified By:

Reporter


errorAt

public void errorAt(int line, int column, DiagnosticCode code, Object[] details)

Reports an error anchored to a resource location by line and column.

Specified By:

Reporter


errorAt

public void errorAt(int line, int column, Throwable cause, DiagnosticCode code, Object[] details)

Reports an error anchored to a resource location by line and column.

Specified By:

Reporter


infoAt

public void infoAt(int line, int column, int startOffset, int endOffset, DiagnosticCode code, Object[] details)

Reports an informational message anchored to a precise character span within a resource.

Specified By:

Reporter


warnAt

public void warnAt(int line, int column, int startOffset, int endOffset, DiagnosticCode code, Object[] details)

Reports a warning anchored to a precise character span within a resource.

Specified By:

Reporter


errorAt

public void errorAt(int line, int column, int startOffset, int endOffset, DiagnosticCode code, Object[] details)

Reports an error anchored to a precise character span within a resource.

Specified By:

Reporter


errorAt

public void errorAt(int line, int column, int startOffset, int endOffset, Throwable cause, DiagnosticCode code, Object[] details)

Reports an error anchored to a precise character span within a resource.

Specified By:

Reporter


infoAt

public void infoAt(Token token, DiagnosticCode code, Object[] details)

Reports an informational message derived from the location attributes of a structural token.

Specified By:

Reporter


warnAt

public void warnAt(Token token, DiagnosticCode code, Object[] details)

Reports a warning derived from the location attributes of a structural token.

Specified By:

Reporter


errorAt

public void errorAt(Token token, DiagnosticCode code, Object[] details)

Reports an error derived from the location attributes of a structural token.

Specified By:

Reporter


errorAt

public void errorAt(Token token, Throwable cause, DiagnosticCode code, Object[] details)

Reports an error derived from the location attributes of a structural token.

Specified By:

Reporter


warnAt

public void warnAt(URI uri, int line, int column, DiagnosticCode code, Object[] details)

Specified By:

Reporter


errorAt

public void errorAt(URI uri, int line, int column, DiagnosticCode code, Object[] details)

Specified By:

Reporter


warnAt

public void warnAt(URI uri, Token token, DiagnosticCode code, Object[] details)

Specified By:

Reporter


errorAt

public void errorAt(URI uri, Token token, DiagnosticCode code, Object[] details)

Specified By:

Reporter


errorAt

public void errorAt(URI uri, Token token, Throwable t, DiagnosticCode code, Object[] details)

Specified By:

Reporter


formatMessage

protected abstract String formatMessage(Diagnostic diagnostic, String line, int lineNumber, boolean ansiColoring)


getDiagnosticConsumer

protected Consumer<Diagnostic> getDiagnosticConsumer()


getProblemConsumer

protected Consumer<Diagnostic> getProblemConsumer()


getLineConsumer

protected Consumer<String> getLineConsumer()


isSystemOutputEnabled

protected boolean isSystemOutputEnabled()


isFlushEnabled

protected boolean isFlushEnabled()


isStackTraceEnabled

protected boolean isStackTraceEnabled()


report

protected void report(Diagnostic diagnostic)


writeString

protected void writeString(Diagnostic diagnostic)


logLine

protected void logLine(Level level, String msgLine, int msgLineNumber)


displayLine

protected void displayLine(Level diagnosticLevel, String msgLine, int msgLineNumber)


buildDiagnostic

protected Diagnostic buildDiagnostic(String source, Level level, String message, Object[] details)

With message string


buildDiagnostic

protected Diagnostic buildDiagnostic(String source, Level level, Throwable cause, DiagnosticCode code, Object[] details)

With diagnostic code, and cause


buildDiagnostic

protected Diagnostic buildDiagnostic(URI uri, int line, int column, int startOffset, int endOffset, String source, Level level, Throwable cause, DiagnosticCode code, Object[] details)

With diagnostic code, location, and cause


buildDiagnostic

protected Diagnostic buildDiagnostic(Token token, String source, Level level, Throwable cause, DiagnosticCode code, Object[] details)

With diagnostic code, token, and cause


isProblem

protected boolean isProblem(Level level)


reportsDebug

public boolean reportsDebug()

Specified By:

Reporter


reportsTrace

public boolean reportsTrace()

Specified By:

Reporter