APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.util

pack-priv Class WarningAggregator

extends Object
Class Inheritance
Imports
java.util.ArrayList, .HashSet, .List, .Objects, .Set, javax.tools.JavaFileObject, com.sun.tools.javac.code.Lint, .Lint.LintCategory, .Source, com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag, .JCDiagnostic.DiagnosticPosition, .JCDiagnostic.LintWarning, .JCDiagnostic.Note, .JCDiagnostic.Warning

An aggregator for warnings, setting up a deferred diagnostic to be printed at the end of the compilation if some warnings get suppressed because the lint category is not enabled or too many warnings have already been generated.

All warnings must be in the same LintCategory provided to the constructor.

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
WarningAggregator.DeferredDiagnosticKind

The kinds of different deferred diagnostics that might be generated if a warning is suppressed because too many warnings have already been output.

Field Summary

Modifier and TypeField and Description
private boolean
anyWarningEmitted

Whether we have actually emitted a warning or just deferred everything.

private Object
deferredDiagnosticArg

An optional argument to be used when constructing the deferred diagnostic message, based on deferredDiagnosticKind.

private WarningAggregator.DeferredDiagnosticKind
deferredDiagnosticKind

A variable indicating the latest best guess at what the final deferred diagnostic will be.

private JavaFileObject
deferredDiagnosticSource

If deferredDiagnosticKind is IN_FILE or ADDITIONAL_IN_FILE, this variable gives the value of log.currentSource() for the file in question.

private final Lint.LintCategory
lintCategory

A LintCategory to be included in point-of-use diagnostics to indicate how messages might be suppressed (i.e. with @SuppressWarnings).

private final Log
log

The log to which to report warnings.

private final String
prefix

The common prefix for all I18N message keys generated by this handler.

private final Source
private Set<JavaFileObject>
sourcesWithReportedWarnings

A set containing the names of the source files for which specific warnings have been generated -- i.e. in verbose mode.

Constructor Summary

AccessConstructor and Description
public
WarningAggregator(Log
The log on which to generate any diagnostics
log
,
Source
Associated source file, or null for none
source
,
Lint.LintCategory
The lint category for all warnings
lc
)

Create an aggregator for warnings.

public
WarningAggregator(Log
The log on which to generate any diagnostics
log
,
Source
Associated source file, or null for none
source
,
Lint.LintCategory
The lint category for all warnings
lc
,
String
A common prefix for the set of message keys for the messages that may be generated, or null to infer from the lint category.
prefix
)

Create an aggregator for warnings.

Method Summary

Modifier and TypeMethod and Description
private void
addNote(List<JCDiagnostic> list, JavaFileObject file, String msg, Object... args)

public boolean

Returns:

true if diagnostic should be emitted, otherwise false
aggregate
(JCDiagnostic
the warning
diagnostic
,
boolean
whether the warning's lint category is enabled
verbose
)

Aggregate a warning and determine whether to emit it.

public List<JCDiagnostic>
aggregationNotes()

Build and return any accumulated aggregation notes.

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

anyWarningEmittedback to summary
private boolean anyWarningEmitted

Whether we have actually emitted a warning or just deferred everything. In the latter case, the "recompile" notice is included in the summary.

deferredDiagnosticArgback to summary
private Object deferredDiagnosticArg

An optional argument to be used when constructing the deferred diagnostic message, based on deferredDiagnosticKind. This variable should normally be set/updated whenever deferredDiagnosticKind is updated.

deferredDiagnosticKindback to summary
private WarningAggregator.DeferredDiagnosticKind deferredDiagnosticKind

A variable indicating the latest best guess at what the final deferred diagnostic will be. Initially as specific and helpful as possible, as more warnings are reported, the scope of the diagnostic will be broadened.

deferredDiagnosticSourceback to summary
private JavaFileObject deferredDiagnosticSource

If deferredDiagnosticKind is IN_FILE or ADDITIONAL_IN_FILE, this variable gives the value of log.currentSource() for the file in question.

lintCategoryback to summary
private final Lint.LintCategory lintCategory

A LintCategory to be included in point-of-use diagnostics to indicate how messages might be suppressed (i.e. with @SuppressWarnings).

logback to summary
private final Log log

The log to which to report warnings.

prefixback to summary
private final String prefix

The common prefix for all I18N message keys generated by this handler.

sourceback to summary
private final Source source
sourcesWithReportedWarningsback to summary
private Set<JavaFileObject> sourcesWithReportedWarnings

A set containing the names of the source files for which specific warnings have been generated -- i.e. in verbose mode. If a source name appears in this list, then deferred diagnostics will be phrased to include "additionally"...

Constructor Detail

WarningAggregatorback to summary
public WarningAggregator(Log log, Source source, Lint.LintCategory lc)

Create an aggregator for warnings.

Parameters
log:Log

The log on which to generate any diagnostics

source:Source

Associated source file, or null for none

lc:Lint.LintCategory

The lint category for all warnings

WarningAggregatorback to summary
public WarningAggregator(Log log, Source source, Lint.LintCategory lc, String prefix)

Create an aggregator for warnings.

Parameters
log:Log

The log on which to generate any diagnostics

source:Source

Associated source file, or null for none

lc:Lint.LintCategory

The lint category for all warnings

prefix:String

A common prefix for the set of message keys for the messages that may be generated, or null to infer from the lint category.

Method Detail

addNoteback to summary
private void addNote(List<JCDiagnostic> list, JavaFileObject file, String msg, Object... args)
aggregateback to summary
public boolean aggregate(JCDiagnostic diagnostic, boolean verbose)

Aggregate a warning and determine whether to emit it.

Parameters
diagnostic:JCDiagnostic

the warning

verbose:boolean

whether the warning's lint category is enabled

Returns:boolean

true if diagnostic should be emitted, otherwise false

aggregationNotesback to summary
public List<JCDiagnostic> aggregationNotes()

Build and return any accumulated aggregation notes.

clearback to summary
public void clear()
com.sun.tools.javac.util back to summary

private final Enum WarningAggregator.DeferredDiagnosticKind

extends Enum<WarningAggregator.DeferredDiagnosticKind>
Class Inheritance

The kinds of different deferred diagnostics that might be generated if a warning is suppressed because too many warnings have already been output. The parameter is a fragment used to build an I18N message key for Log.

Field Summary

Modifier and TypeField and Description
public static final WarningAggregator.DeferredDiagnosticKind
ADDITIONAL_IN_FILE

This kind is used when a single specific file is found to have warnings and when similar warnings have already been reported for the file.

public static final WarningAggregator.DeferredDiagnosticKind
ADDITIONAL_IN_FILES

This kind is used when multiple files have been found to have warnings, and some of them have had already had specific similar warnings.

public static final WarningAggregator.DeferredDiagnosticKind
IN_FILE

This kind is used when a single specific file is found to have warnings and no similar warnings have already been given.

public static final WarningAggregator.DeferredDiagnosticKind
IN_FILES

This kind is used when multiple files have been found to have warnings, and none of them have had any similar warnings.

private final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv String
getKey(String prefix)

public static WarningAggregator.DeferredDiagnosticKind
public static WarningAggregator.DeferredDiagnosticKind[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ADDITIONAL_IN_FILEback to summary
public static final WarningAggregator.DeferredDiagnosticKind ADDITIONAL_IN_FILE

This kind is used when a single specific file is found to have warnings and when similar warnings have already been reported for the file. It generates a message like: FILE has additional ISSUES

ADDITIONAL_IN_FILESback to summary
public static final WarningAggregator.DeferredDiagnosticKind ADDITIONAL_IN_FILES

This kind is used when multiple files have been found to have warnings, and some of them have had already had specific similar warnings. It generates a message like: Some files have additional ISSUES

IN_FILEback to summary
public static final WarningAggregator.DeferredDiagnosticKind IN_FILE

This kind is used when a single specific file is found to have warnings and no similar warnings have already been given. It generates a message like: FILE has ISSUES

IN_FILESback to summary
public static final WarningAggregator.DeferredDiagnosticKind IN_FILES

This kind is used when multiple files have been found to have warnings, and none of them have had any similar warnings. It generates a message like: Some files have ISSUES

valueback to summary
private final String value

Constructor Detail

DeferredDiagnosticKindback to summary
private DeferredDiagnosticKind(String v)

Method Detail

getKeyback to summary
pack-priv String getKey(String prefix)
valueOfback to summary
public static WarningAggregator.DeferredDiagnosticKind valueOf(String name)
valuesback to summary
public static WarningAggregator.DeferredDiagnosticKind[] values()