public abstract class AbstractDiagnosticFormatter extends Object implements DiagnosticFormatter<JCDiagnostic>
This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
Modifier and Type | Class and Description |
---|---|
static class |
AbstractDiagnosticFormatter.SimpleConfiguration |
DiagnosticFormatter.Configuration, DiagnosticFormatter.PositionKind
Modifier and Type | Field and Description |
---|---|
protected int |
depth
Current depth level of the disgnostic being formatted
(!= 0 for subdiagnostics)
|
protected JavacMessages |
messages
JavacMessages object used by this formatter for i18n.
|
protected Printer |
printer
An enhanced printer for formatting types/symbols used by
AbstractDiagnosticFormatter.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractDiagnosticFormatter(JavacMessages messages,
AbstractDiagnosticFormatter.SimpleConfiguration config)
Initialize an AbstractDiagnosticFormatter by setting its JavacMessages object.
|
Modifier and Type | Method and Description |
---|---|
boolean |
displaySource(JCDiagnostic d)
Whether the source code output for this diagnostic is to be displayed.
|
String |
format(JCDiagnostic d,
Locale locale)
Format the contents of a diagnostics.
|
protected String |
formatArgument(JCDiagnostic d,
Object arg,
Locale l)
Format a single argument of a given diagnostic.
|
protected Collection<String> |
formatArguments(JCDiagnostic d,
Locale l)
Format the arguments of a given diagnostic.
|
protected abstract String |
formatDiagnostic(JCDiagnostic d,
Locale locale) |
protected String |
formatIterable(JCDiagnostic d,
Iterable<?> it,
Locale l)
Format an iterable argument of a given diagnostic.
|
String |
formatKind(JCDiagnostic d,
Locale l)
Controls the way in which a diagnostic kind is displayed.
|
protected String |
formatLintCategory(JCDiagnostic d,
Locale l) |
String |
formatPosition(JCDiagnostic d,
DiagnosticFormatter.PositionKind pk,
Locale l)
Controls the way in which a diagnostic position is displayed.
|
String |
formatSource(JCDiagnostic d,
boolean fullname,
Locale l)
Controls the way in which a diagnostic source is displayed.
|
protected String |
formatSourceLine(JCDiagnostic d,
int nSpaces)
Format the faulty source code line and point to the error.
|
protected String |
formatSubdiagnostic(JCDiagnostic parent,
JCDiagnostic sub,
Locale l)
Format a subdiagnostics attached to a given diagnostic.
|
protected List<String> |
formatSubdiagnostics(JCDiagnostic d,
Locale l)
Format all the subdiagnostics attached to a given diagnostic.
|
AbstractDiagnosticFormatter.SimpleConfiguration |
getConfiguration()
Get a list of all the enabled verbosity options.
|
Printer |
getPrinter() |
protected String |
indent(String s,
int nSpaces)
Indent a string by prepending a given amount of empty spaces to each line
of the string.
|
protected String |
indentString(int nSpaces)
Creates a string with a given amount of empty spaces.
|
boolean |
isRaw() |
protected String |
localize(Locale l,
String key,
Object... args)
Converts a String into a locale-dependent representation accordingly to a given locale.
|
void |
setPrinter(Printer printer) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
formatMessage
protected JavacMessages messages
protected int depth
protected Printer printer
protected AbstractDiagnosticFormatter(JavacMessages messages, AbstractDiagnosticFormatter.SimpleConfiguration config)
messages
- public String formatKind(JCDiagnostic d, Locale l)
DiagnosticFormatter
formatKind
in interface DiagnosticFormatter<JCDiagnostic>
d
- diagnostic to be formattedl
- locale object to be used for i18npublic String format(JCDiagnostic d, Locale locale)
DiagnosticFormatter
format
in interface DiagnosticFormatter<JCDiagnostic>
d
- the diagnostic to be formattedlocale
- locale object to be used for i18nprotected abstract String formatDiagnostic(JCDiagnostic d, Locale locale)
public String formatPosition(JCDiagnostic d, DiagnosticFormatter.PositionKind pk, Locale l)
DiagnosticFormatter
formatPosition
in interface DiagnosticFormatter<JCDiagnostic>
d
- diagnostic to be formattedpk
- enum constant representing the position kindl
- locale object to be used for i18npublic String formatSource(JCDiagnostic d, boolean fullname, Locale l)
DiagnosticFormatter
formatSource
in interface DiagnosticFormatter<JCDiagnostic>
d
- diagnostic to be formattedfullname
- whether the source fullname should be printedl
- locale object to be used for i18nprotected Collection<String> formatArguments(JCDiagnostic d, Locale l)
d
- diagnostic whose arguments are to be formattedl
- locale object to be used for i18nprotected String formatArgument(JCDiagnostic d, Object arg, Locale l)
d
- diagnostic whose argument is to be formattedarg
- argument to be formattedl
- locale object to be used for i18nprotected String formatIterable(JCDiagnostic d, Iterable<?> it, Locale l)
d
- diagnostic whose argument is to be formattedit
- iterable argument to be formattedl
- locale object to be used for i18nprotected List<String> formatSubdiagnostics(JCDiagnostic d, Locale l)
d
- diagnostic whose subdiagnostics are to be formattedl
- locale object to be used for i18nprotected String formatSubdiagnostic(JCDiagnostic parent, JCDiagnostic sub, Locale l)
parent
- multiline diagnostic whose subdiagnostics is to be formattedsub
- subdiagnostic to be formattedl
- locale object to be used for i18nprotected String formatSourceLine(JCDiagnostic d, int nSpaces)
d
- The diagnostic for which the error line should be printedprotected String formatLintCategory(JCDiagnostic d, Locale l)
protected String localize(Locale l, String key, Object... args)
l
- locale object to be used for i18nkey
- locale-independent key used for looking up in a resource fileargs
- localization argumentspublic boolean displaySource(JCDiagnostic d)
DiagnosticFormatter
displaySource
in interface DiagnosticFormatter<JCDiagnostic>
d
- diagnostic to be formattedpublic boolean isRaw()
protected String indentString(int nSpaces)
nSpaces
- the amount of spaces to be added to the result stringprotected String indent(String s, int nSpaces)
s
- the string to be indentednSpaces
- the amount of spaces that should be prepended to each line
of the stringpublic AbstractDiagnosticFormatter.SimpleConfiguration getConfiguration()
DiagnosticFormatter
getConfiguration
in interface DiagnosticFormatter<JCDiagnostic>
public Printer getPrinter()
public void setPrinter(Printer printer)
Copyright © 2017 earcam. All rights reserved.