Class Locations

  extended by javax.annotation.processing.AbstractProcessor
      extended by checkers.source.SourceChecker
          extended by checkers.util.count.Locations
All Implemented Interfaces:

public class Locations
extends SourceChecker

A utility class for counting the potential locations of annotations.

The class is actually an annotation processor; in order to use it, invoke the compiler on the source file(s) for which you wish to count annotations locations. You may also wish to use the -proc:only javac option to stop compilation after annotation processing.

Counting the number of lines of the processor's output yields the annotation location count (e.g., by piping the output to wc). Because the processor outputs a single line of text describing type of each annotation location it encounters, you can obtain the count for specific annotation location types (i.e., possible local variable annotations, or possible method receiver annotations) by filtering the output accordingly (e.g., with grep).

By default, this utility displays annotation locations only. The following two options may be used to adjust the output:

Field Summary
Fields inherited from class checkers.source.SourceChecker
currentRoot, env, messager, messages, skipPattern, trees
Fields inherited from class javax.annotation.processing.AbstractProcessor
Constructor Summary
Method Summary
protected  boolean attribute(Set<? extends TypeElement> elements)
          No need for type-checking.
protected  SourceVisitor<?,?> createSourceVisitor(CompilationUnitTree root)
          Provides the SourceVisitor that the checker should use to scan input source trees.
Methods inherited from class checkers.source.SourceChecker
createFactory, getLintOption, getLintOption, getMessages, getProcessingEnvironment, getShouldSkip, getSupportedAnnotationTypes, getSupportedLintOptions, getSupportedOptions, getSupportedSourceVersion, getSuppressWarningsKey, init, message, process, report, shouldSkip
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

Constructor Detail


public Locations()
Method Detail


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
root - the AST root
a SourceVisitor to use to scan source trees


protected boolean attribute(Set<? extends TypeElement> elements)
No need for type-checking. Elemenates need for setting all classpaths

attribute in class SourceChecker
true iff if the code type-checks with Java Specification