Class TracingDiagnosticListener<S extends JavaFileObject>
java.lang.Object
io.github.ascopes.jct.diagnostics.TracingDiagnosticListener<S>
- Type Parameters:
S
- the file type.
- All Implemented Interfaces:
DiagnosticListener<S>
public class TracingDiagnosticListener<S extends JavaFileObject>
extends Object
implements DiagnosticListener<S>
A diagnostics listener that wraps all diagnostics in additional invocation information, and then
stores them in a queue for processing later.
- Since:
- 0.0.1
- Author:
- Ashley Scopes
-
Constructor Summary
ModifierConstructorDescriptionTracingDiagnosticListener
(boolean logging, boolean stackTraces) Initialize this listener.protected
TracingDiagnosticListener
(Logger logger, Supplier<? extends Thread> threadGetter, boolean logging, boolean stackTraces) Only visible for testing. -
Method Summary
Modifier and TypeMethodDescriptionGet a copy of the queue containing all the diagnostics that have been detected.boolean
Determine if logging is enabled.boolean
Determine if stack trace reporting is enabled.final void
report
(Diagnostic<? extends S> diagnostic)
-
Constructor Details
-
TracingDiagnosticListener
Initialize this listener.- Parameters:
logging
-true
if logging is enabled,false
otherwise.stackTraces
-true
if logging stack traces is enabled,false
otherwise. This is ignored iflogging
isfalse
.
-
TracingDiagnosticListener
@VisibleForTestingOnly protected TracingDiagnosticListener(Logger logger, Supplier<? extends Thread> threadGetter, boolean logging, boolean stackTraces) Only visible for testing.Users should NOT use this constructor. It may be changed or removed without notice.
- Parameters:
logger
- the logger to use.threadGetter
- the supplier of the current thread.logging
- whether to enable logging.stackTraces
- whether to enable stack traces in the logging.
-
-
Method Details
-
isLoggingEnabled
Determine if logging is enabled.- Returns:
true
if enabled, orfalse
if disabled.
-
isStackTraceReportingEnabled
Determine if stack trace reporting is enabled.Note that stack traces are only reported if
logging is enabled
as well.- Returns:
true
if enabled, orfalse
if disabled.
-
getDiagnostics
Get a copy of the queue containing all the diagnostics that have been detected.- Returns:
- the diagnostics in a list.
-
report
- Specified by:
report
in interfaceDiagnosticListener<S extends JavaFileObject>
-