public abstract class BaseTypeChecker extends SourceChecker
SourceChecker
that provides a simple SourceVisitor
implementation for typical assignment and
pseudo-assignment checking of annotated types. Pseudo-assignment checks
include method overriding checks, parameter passing, and method invocation.
Most type-checker plug-ins will want to extend this class, instead of
SourceChecker
. Checkers that require annotated types but not
subtype checking (e.g. for testing purposes)
should extend SourceChecker
.
Non-type checkers (e.g. checkers to enforce coding
styles) should extend SourceChecker
or AbstractTypeProcessor
directly; the Checker Framework is not designed for such checkers.
It is a convention that, for a type system Foo, the checker, the visitor, and the annotated type factory are named as FooChecker, FooVisitor, and FooAnnotatedTypeFactory. Some factory methods uses this convention to construct the appropriate classes reflectively.
BaseTypeChecker
encapsulates a group for factories for various
representations/classes related the type system, mainly:
QualifierHierarchy
:
to represent the supported qualifiers in addition to their hierarchy,
mainly, subtyping rulesTypeHierarchy
:
to check subtyping rules between annotated types rather than qualifiersAnnotatedTypeFactory
:
to construct qualified types enriched with implicit qualifiers
according to the type system rulesBaseTypeVisitor
:
to visit the compiled Java files and check for violations of the type
system rules
Subclasses must specify the set of type qualifiers they support either by
annotating the subclass with TypeQualifiers
or by overriding the
AnnotatedTypeFactory.getSupportedTypeQualifiers()
method.
If the specified type qualifiers are meta-annotated with SubtypeOf
,
this implementation will automatically construct the type qualifier
hierarchy. Otherwise, or if this behavior must be overridden, the subclass
may override the AnnotatedTypeFactory.createQualifierHierarchy()
method.
org.checkerframework.framework.qual
SourceChecker.CheckerError
currentPath, currentRoot, DETAILS_SEPARATOR, messager, messages, MSGS_FILE, trees, visitor
Constructor and Description |
---|
BaseTypeChecker() |
Modifier and Type | Method and Description |
---|---|
protected BaseTypeVisitor<?> |
createSourceVisitor()
Returns the appropriate visitor that type-checks the compilation unit
according to the type system rules.
|
java.util.Set<java.lang.String> |
getSupportedLintOptions()
Specify supported lint options for all type-checkers.
|
static <T> T |
invokeConstructorFor(java.lang.String name,
java.lang.Class<?>[] paramTypes,
java.lang.Object[] args)
Invokes the constructor belonging to the class
named by
name having the given parameter types on the given
arguments. |
addOptions, createSupportedLintOptions, errorAbort, errorAbort, expandCFOptions, formatStackTrace, fullMessageOf, getLintOption, getLintOption, getMessages, getOption, getOption, getOptions, getProcessingEnvironment, getProperties, getStandardSuppressWarningsKeys, getSupportedAnnotationTypes, getSupportedOptions, getSupportedSourceVersion, getSuppressWarningsKeys, hasOption, initChecker, message, printStats, report, setLintOption, setSupportedLintOptions, shouldAddShutdownHook, shouldSkipDefs, shouldSkipDefs, shouldSkipUses, shouldSkipUses, shutdownHook, treeToFilePositionString, typeProcess, typeProcessingStart
init, process, typeProcessingOver
protected BaseTypeVisitor<?> createSourceVisitor()
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.createSourceVisitor
in class SourceChecker
public java.util.Set<java.lang.String> getSupportedLintOptions()
getSupportedLintOptions
in class SourceChecker
Set
of the lint options recognized by
this checkerpublic static <T> T invokeConstructorFor(java.lang.String name, java.lang.Class<?>[] paramTypes, java.lang.Object[] args)
name
having the given parameter types on the given
arguments. Returns null
if the class cannot be found, or the
constructor does not exist or cannot be invoked on the given arguments.T
- the type to which the constructor belongsname
- the name of the class to which the constructor belongsparamTypes
- the types of the constructor's parametersargs
- the arguments on which to invoke the constructorargs
, or
null if the constructor does not exist or could not be invoked