Class FactoryTestChecker
- All Implemented Interfaces:
Processor,OptionConfiguration
The expected type is written in a stylized comment (starting with "///") in the same Java source file. The comment appears either on the same line as the expression, or else by itself on the line preceding the expression.
The comments are of two forms:
/// <expected type>: to specify the type of the expression in the expression statement/// <subtree> -:- <expected type>: to specify the type of the given subexpression within the line.
List<String>), instead of
fully qualified names (e.g., java.util.List<java.lang.String>).
Example:
void test() {
// Comments in the same line
Collections.<@NonNull String>emptyList(); /// List<@NonNull String>
List<@NonNull String> l = Collections.emptyList(); /// Collections.emptyList() -:- List<@NonNull String>
// Comments in the previous lines
/// List<@NonNull String>
Collections.<@NonNull String>emptyList();
/// Collections.emptyList() -:- List<@NonNull String>
List<@NonNull String> l = Collections.emptyList();
}
The fully qualified name of the custom AnnotatedTypeFactory is specified through an
-Afactory command-line argument (e.g.
-Afactory=checkers.nullness.NullnessAnnotatedTypeFactory). The factory needs to have a
constructor of the form <init>(ProcessingEnvironment, CompilationUnitTree).-
Nested Class Summary
Nested classes/interfaces inherited from class org.checkerframework.framework.source.SourceChecker
SourceChecker.CheckerMessage -
Field Summary
Fields inherited from class org.checkerframework.common.basetype.BaseTypeChecker
baseTypeCheckerClassArray, ultimateParentCheckerFields inherited from class org.checkerframework.framework.source.SourceChecker
activeOptions, currentRoot, DETAILS_SEPARATOR, elements, elementsWithSuppressedWarnings, immediateSubcheckers, javacErrored, messager, messagesProperties, messageStore, MSGS_FILE, OPTION_SEPARATOR, parentChecker, subcheckers, supportedOptions, SUPPRESS_ALL_MESSAGE_KEY, SUPPRESS_ALL_PREFIX, suppressWarningsPrefixesOfSubcheckers, treePathCacher, trees, types, UNNEEDED_SUPPRESSION_KEY, upstreamCheckerNames, useAllcheckersPrefix, visitorFields inherited from class javax.annotation.processing.AbstractProcessor
processingEnv -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected BaseTypeVisitor<?> Returns the appropriate visitor that type-checks the compilation unit according to the type system rules.Provides a mapping of error keys to custom error messages.voidInitialize the checker.Methods inherited from class org.checkerframework.common.basetype.BaseTypeChecker
createSourceVisitorPublic, createSupportedLintOptions, getAnnotationProvider, getTypeFactory, getTypeFactoryOfSubcheckerOrNull, getUltimateParentChecker, getVisitor, invokeConstructorFor, processErrorMessageArg, shouldAddShutdownHook, shutdownHookMethods inherited from class org.checkerframework.framework.source.SourceChecker
expandCFOptions, fullMessageOf, getBooleanOption, getBooleanOption, getElementUtils, getExtraStubFiles, getImmediateSubcheckerClasses, getLintOption, getLintOption, getOption, getOption, getOptionConfiguration, getOptions, getOptionsNoSubcheckers, getParentChecker, getPathToCompilationUnit, getProcessingEnvironment, getProperties, getRelatedClassName, getStandardSuppressWarningsPrefixes, getStringsOption, getStringsOption, getSubchecker, getSubCheckerIndex, getSubcheckers, getSupportedAnnotationTypes, getSupportedLintOptions, getSupportedOptions, getSupportedSourceVersion, getSuppressWarningsPrefixes, getSuppressWarningsPrefixesOfSubcheckers, getTreePathCacher, getTreeUtils, getTypeUtils, getUpstreamCheckerNames, getWarningMessagePrefix, hasOption, hasOptionNoSubcheckers, init, instantiateSubcheckers, message, message, messageKeyMatches, printOrStoreMessage, printOrStoreMessage, printStats, printStoredMessages, report, reportError, reportWarning, setLintOption, setParentChecker, setRoot, shouldResolveReflection, shouldSkipDefs, shouldSkipDefs, shouldSkipDefs, shouldSkipFiles, shouldSkipUses, shouldSkipUses, shouldSuppressWarnings, shouldSuppressWarnings, shouldSuppressWarnings, suppressWarningsString, typeProcess, typeProcessingOver, typeProcessingStart, useConservativeDefault, warnUnneededSuppressions, warnUnneededSuppressionsMethods inherited from class org.checkerframework.javacutil.AbstractTypeProcessor
getCompilerLog, processMethods inherited from class javax.annotation.processing.AbstractProcessor
getCompletions, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.checkerframework.framework.util.OptionConfiguration
getStringsOption, getStringsOption
-
Constructor Details
-
FactoryTestChecker
public FactoryTestChecker()
-
-
Method Details
-
initChecker
public void initChecker()Description copied from class:SourceCheckerInitialize the checker.- Overrides:
initCheckerin classSourceChecker- See Also:
-
getMessagesProperties
Description copied from class:SourceCheckerProvides a mapping of error keys to custom error messages.As a default, this implementation builds a
Propertiesout of filemessages.properties. It accumulates all the properties files in the Java class hierarchy from the checker up toSourceChecker. This permits subclasses to inherit default messages while being able to override them.- Overrides:
getMessagesPropertiesin classSourceChecker- Returns:
- a
Propertiesthat maps error keys to error message text
-
createSourceVisitor
Description copied from class:BaseTypeCheckerReturns the appropriate visitor that type-checks the compilation unit according to the type system rules.This implementation uses the checker naming convention to create the appropriate visitor. If no visitor is found, it returns an instance of
BaseTypeVisitor. It reflectively invokes the constructor that accepts this checker and the compilation unit tree (in that order) as arguments.Subclasses have to override this method to create the appropriate visitor if they do not follow the checker naming convention.
- Overrides:
createSourceVisitorin classBaseTypeChecker- Returns:
- the type-checking visitor
-