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)
.-
Field Summary
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
Fields inherited from class javax.annotation.processing.AbstractProcessor
processingEnv
-
Constructor Summary
-
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.void
Initialize the checker.Methods inherited from class org.checkerframework.common.basetype.BaseTypeChecker
createSourceVisitorPublic, getAnnotationProvider, getExtraStubFiles, getImmediateSubcheckerClasses, getOptions, getOptionsNoSubcheckers, getRelatedClassName, getSubchecker, getSubcheckers, getSupportedLintOptions, getSupportedOptions, getSuppressWarningsPrefixesOfSubcheckers, getTypeFactory, getTypeFactoryOfSubcheckerOrNull, getUltimateParentChecker, getVisitor, hasOptionNoSubcheckers, invokeConstructorFor, printOrStoreMessage, processErrorMessageArg, setRoot, shouldAddShutdownHook, shouldResolveReflection, shutdownHook, typeProcess, typeProcessingOver, warnUnneededSuppressions
Methods inherited from class org.checkerframework.framework.source.SourceChecker
addOptions, createSupportedLintOptions, expandCFOptions, fullMessageOf, getBooleanOption, getBooleanOption, getElementUtils, getLintOption, getLintOption, getOption, getOption, getOptionConfiguration, getParentChecker, getPathToCompilationUnit, getProcessingEnvironment, getProperties, getStandardSuppressWarningsPrefixes, getStringsOption, getStringsOption, getSupportedAnnotationTypes, getSupportedSourceVersion, getSuppressWarningsPrefixes, getTreePathCacher, getTreeUtils, getTypeUtils, getUpstreamCheckerNames, getWarningMessagePrefix, hasOption, init, message, message, messageKeyMatches, printOrStoreMessage, printStats, report, reportError, reportWarning, setLintOption, setParentChecker, setProcessingEnvironment, setSupportedLintOptions, shouldSkipDefs, shouldSkipDefs, shouldSkipUses, shouldSkipUses, shouldSuppressWarnings, shouldSuppressWarnings, shouldSuppressWarnings, suppressWarningsString, typeProcessingStart, useConservativeDefault, 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
-
Constructor Details
-
FactoryTestChecker
public FactoryTestChecker()
-
-
Method Details
-
initChecker
public void initChecker()Description copied from class:SourceChecker
Initialize the checker.- Overrides:
initChecker
in classBaseTypeChecker
- See Also:
-
getMessagesProperties
Description copied from class:SourceChecker
Provides a mapping of error keys to custom error messages.As a default, this implementation builds a
Properties
out 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:
getMessagesProperties
in classSourceChecker
- Returns:
- a
Properties
that maps error keys to error message text
-
createSourceVisitor
Description copied from class:BaseTypeChecker
Returns 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:
createSourceVisitor
in classBaseTypeChecker
- Returns:
- the type-checking visitor
-