checkers.util.test
Class TypeOutputtingChecker
java.lang.Object
javax.annotation.processing.AbstractProcessor
checkers.source.SourceChecker
checkers.util.test.TypeOutputtingChecker
- All Implemented Interfaces:
- Processor
public class TypeOutputtingChecker
- extends SourceChecker
A testing class that can be used to test TypeElement
. In particular
it tests that the types read from classfiles are the same to the ones
from java files.
For testing, you need to do the following:
1. Run the Checker on the source file like any checker:
java -processor checkers.util.test.TypeOutputtingChecker [source-file]
2. Run the Checker on the bytecode, by simply running the main and passing
the qualified name, e.g.
java checkers.util.test.TypeOutputtingChecker [qualified-name]
3. Apply a simple diff on the two outputs
Nested Class Summary |
static class |
TypeOutputtingChecker.Visitor
Prints the types of the class and all of its enclosing
fields, methods, and inner classes |
Methods inherited from class checkers.source.SourceChecker |
attribute, createFactory, getLintOption, getLintOption, getMessages, getProcessingEnvironment, getShouldSkip, getSupportedAnnotationTypes, getSupportedLintOptions, getSupportedOptions, getSupportedSourceVersion, getSuppressWarningsKey, init, message, report, shouldSkip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TypeOutputtingChecker
public TypeOutputtingChecker()
process
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv)
- Description copied from class:
SourceChecker
- Type-check the code with Java specifications and then runs the Checker
Rule Checking visitor on the processed source.
The
Processor
is invoked in the annotation processing phase,
before the code is type-checked by the compiler. This method ensures
that only Java valid code is processed by the Rule Checking visitor.
- Specified by:
process
in interface Processor
- Overrides:
process
in class SourceChecker
- See Also:
Processor.process(Set, RoundEnvironment)
createSourceVisitor
protected SourceVisitor<?,?> createSourceVisitor(CompilationUnitTree root)
- Description copied from class:
SourceChecker
- Provides the
SourceVisitor
that the checker should use to scan
input source trees.
- Specified by:
createSourceVisitor
in class SourceChecker
- Parameters:
root
- the AST root
- Returns:
- a
SourceVisitor
to use to scan source trees
main
public static void main(String[] args)
printClassType
protected static void printClassType(TypeElement typeElt,
AnnotatedTypeFactory atypeFactory)
- Prints the types of the class and all of its enclosing
fields, methods, and inner classes