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
AbstractTypeProcessorresponsibilities 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 protectedAggregateChecker()Create a new AggregateChecker.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected SourceVisitor<?,?>createSourceVisitor()Provides theSourceVisitorthat 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 ofSupportedOptionsto the standard annotation provided versionSupportedOptions.voidinitChecker()Initialize the checker.protected voidsetProcessingEnvironment(javax.annotation.processing.ProcessingEnvironment env)processingEnvneeds to be set on each checker since we are not calling init on the checker, which leaves it null.voidtypeProcess(javax.lang.model.element.TypeElement element, com.sun.source.util.TreePath tree)Type-check the code using this checker's visitor.voidtypeProcessingOver()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)
processingEnvneeds 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:
setProcessingEnvironmentin classSourceChecker- Parameters:
env- the new processing environment
-
initChecker
public void initChecker()
Description copied from class:SourceCheckerInitialize the checker.- Overrides:
initCheckerin 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:SourceCheckerType-check the code using this checker's visitor.- Overrides:
typeProcessin 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:AbstractTypeProcessorA 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:
typeProcessingOverin classAbstractTypeProcessor
-
getSupportedOptions
public final java.util.Set<java.lang.String> getSupportedOptions()
Description copied from class:SourceCheckerMap the Checker Framework version ofSupportedOptionsto the standard annotation provided versionSupportedOptions.- Specified by:
getSupportedOptionsin interfaceOptionConfiguration- Specified by:
getSupportedOptionsin interfacejavax.annotation.processing.Processor- Overrides:
getSupportedOptionsin classSourceChecker- Returns:
- the supported options
-
getOptions
public final java.util.Map<java.lang.String,java.lang.String> getOptions()
Description copied from interface:OptionConfigurationReturn all active options for this checker.- Specified by:
getOptionsin interfaceOptionConfiguration- Overrides:
getOptionsin classSourceChecker- Returns:
- all active options for this checker
-
getSupportedLintOptions
public final java.util.Set<java.lang.String> getSupportedLintOptions()
Description copied from class:SourceCheckerReturns the lint options recognized by this checker. Lint options are those which can be checked for viaSourceChecker.getLintOption(java.lang.String).- Overrides:
getSupportedLintOptionsin classSourceChecker- Returns:
- an unmodifiable
Setof the lint options recognized by this checker
-
createSourceVisitor
protected SourceVisitor<?,?> createSourceVisitor()
Description copied from class:SourceCheckerProvides theSourceVisitorthat the checker should use to scan input source trees.- Specified by:
createSourceVisitorin classSourceChecker- Returns:
- a
SourceVisitorto use to scan source trees
-
-