Class AggregateChecker
- java.lang.Object
-
- javax.annotation.processing.AbstractProcessor
-
- org.checkerframework.javacutil.AbstractTypeProcessor
-
- org.checkerframework.framework.source.SourceChecker
-
- org.checkerframework.framework.source.AggregateChecker
-
- All Implemented Interfaces:
javax.annotation.processing.Processor
,OptionConfiguration
- Direct Known Subclasses:
I18nChecker
public abstract class AggregateChecker extends SourceChecker
An aggregate checker that packages multiple checkers together. The resulting checker invokes the component checkers in turn on the processed files.There is no communication, interaction, or cooperation between the component checkers, even to the extent of being able to read one another's qualifiers. An aggregate checker is merely shorthand to invoke a sequence of checkers.
This class delegates
AbstractTypeProcessor
responsibilities to each component checker.Checker writers need to subclass this class and only override
getSupportedCheckers()
to indicate the classes of the checkers to be bundled.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<SourceChecker>
checkers
-
Fields inherited from class org.checkerframework.framework.source.SourceChecker
currentRoot, DETAILS_SEPARATOR, elements, elementsWithSuppressedWarnings, errsOnLastExit, javacErrored, messager, messagesProperties, MSGS_FILE, OPTION_SEPARATOR, parentChecker, SUPPRESS_ALL_MESSAGE_KEY, SUPPRESS_ALL_PREFIX, treePathCacher, trees, types, UNNEEDED_SUPPRESSION_KEY, upstreamCheckerNames, useAllcheckersPrefix, visitor
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AggregateChecker()
Create a new AggregateChecker.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected SourceVisitor<?,?>
createSourceVisitor()
Provides theSourceVisitor
that the checker should use to scan input source trees.java.util.Map<java.lang.String,java.lang.String>
getOptions()
Return all active options for this checker.protected abstract java.util.Collection<java.lang.Class<? extends SourceChecker>>
getSupportedCheckers()
Returns the list of supported checkers to be run together.java.util.Set<java.lang.String>
getSupportedLintOptions()
Returns the lint options recognized by this checker.java.util.Set<java.lang.String>
getSupportedOptions()
Map the Checker Framework version ofSupportedOptions
to the standard annotation provided versionSupportedOptions
.void
initChecker()
Initialize the checker.protected void
setProcessingEnvironment(javax.annotation.processing.ProcessingEnvironment env)
processingEnv
needs to be set on each checker since we are not calling init on the checker, which leaves it null.void
typeProcess(javax.lang.model.element.TypeElement element, com.sun.source.util.TreePath tree)
Type-check the code using this checker's visitor.void
typeProcessingOver()
A method to be called once all the classes are processed.-
Methods inherited from class org.checkerframework.framework.source.SourceChecker
addOptions, createSupportedLintOptions, expandCFOptions, fullMessageOf, getAnnotationProvider, getBooleanOption, getBooleanOption, getElementUtils, getLintOption, getLintOption, getMessagesProperties, getOption, getOption, getOptionConfiguration, getParentChecker, getPathToCompilationUnit, getProcessingEnvironment, getProperties, getStandardSuppressWarningsPrefixes, getStringsOption, getStringsOption, getSupportedAnnotationTypes, getSupportedSourceVersion, getSuppressWarningsPrefixes, getTreePathCacher, getTreeUtils, getTypeUtils, getUpstreamCheckerNames, getVisitor, getWarningMessagePrefix, hasOption, init, message, message, messageKeyMatches, printOrStoreMessage, printOrStoreMessage, printStats, processErrorMessageArg, report, reportError, reportWarning, setLintOption, setParentChecker, setRoot, setSupportedLintOptions, shouldAddShutdownHook, shouldSkipDefs, shouldSkipDefs, shouldSkipUses, shouldSkipUses, shouldSuppressWarnings, shouldSuppressWarnings, shouldSuppressWarnings, shutdownHook, typeProcessingStart, useConservativeDefault, warnUnneededSuppressions, warnUnneededSuppressions
-
Methods inherited from class org.checkerframework.javacutil.AbstractTypeProcessor
getCompilerLog, process
-
Methods inherited from class javax.annotation.processing.AbstractProcessor
getCompletions, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.checkerframework.framework.util.OptionConfiguration
getStringsOption, getStringsOption
-
-
-
-
Field Detail
-
checkers
protected final java.util.List<SourceChecker> checkers
-
-
Method Detail
-
getSupportedCheckers
protected abstract java.util.Collection<java.lang.Class<? extends SourceChecker>> getSupportedCheckers()
Returns the list of supported checkers to be run together. Subclasses need to override this method.- Returns:
- the list of checkers to be run
-
setProcessingEnvironment
protected void setProcessingEnvironment(javax.annotation.processing.ProcessingEnvironment env)
processingEnv
needs to be set on each checker since we are not calling init on the checker, which leaves it null. If one of checkers is an AggregateChecker, its visitors will try use checker's processing env which should not be null.- Overrides:
setProcessingEnvironment
in classSourceChecker
- Parameters:
env
- the new processing environment
-
initChecker
public void initChecker()
Description copied from class:SourceChecker
Initialize the checker.- Overrides:
initChecker
in classSourceChecker
- See Also:
AbstractProcessor.init(ProcessingEnvironment)
-
typeProcess
public final void typeProcess(javax.lang.model.element.TypeElement element, com.sun.source.util.TreePath tree)
Description copied from class:SourceChecker
Type-check the code using this checker's visitor.- Overrides:
typeProcess
in classSourceChecker
- Parameters:
element
- element of the analyzed classtree
- the tree path to the element, with the leaf being aClassTree
- See Also:
Processor.process(Set, RoundEnvironment)
-
typeProcessingOver
public void typeProcessingOver()
Description copied from class:AbstractTypeProcessor
A method to be called once all the classes are processed.Subclasses may override this method to do any aggregate analysis (e.g. generate report, persistence) or resource deallocation.
Method
AbstractTypeProcessor.getCompilerLog()
can be used to access the number of compiler errors.- Overrides:
typeProcessingOver
in classAbstractTypeProcessor
-
getSupportedOptions
public final java.util.Set<java.lang.String> getSupportedOptions()
Description copied from class:SourceChecker
Map the Checker Framework version ofSupportedOptions
to the standard annotation provided versionSupportedOptions
.- Specified by:
getSupportedOptions
in interfaceOptionConfiguration
- Specified by:
getSupportedOptions
in interfacejavax.annotation.processing.Processor
- Overrides:
getSupportedOptions
in classSourceChecker
- Returns:
- the supported options
-
getOptions
public final java.util.Map<java.lang.String,java.lang.String> getOptions()
Description copied from interface:OptionConfiguration
Return all active options for this checker.- Specified by:
getOptions
in interfaceOptionConfiguration
- Overrides:
getOptions
in classSourceChecker
- Returns:
- all active options for this checker
-
getSupportedLintOptions
public final java.util.Set<java.lang.String> getSupportedLintOptions()
Description copied from class:SourceChecker
Returns the lint options recognized by this checker. Lint options are those which can be checked for viaSourceChecker.getLintOption(java.lang.String)
.- Overrides:
getSupportedLintOptions
in classSourceChecker
- Returns:
- an unmodifiable
Set
of the lint options recognized by this checker
-
createSourceVisitor
protected SourceVisitor<?,?> createSourceVisitor()
Description copied from class:SourceChecker
Provides theSourceVisitor
that the checker should use to scan input source trees.- Specified by:
createSourceVisitor
in classSourceChecker
- Returns:
- a
SourceVisitor
to use to scan source trees
-
-