checkers.igj
Class IGJChecker

java.lang.Object
  extended by javax.annotation.processing.AbstractProcessor
      extended by checkers.source.SourceChecker
          extended by checkers.basetype.BaseTypeChecker
              extended by checkers.igj.IGJChecker
All Implemented Interfaces:
Processor

@TypeQualifiers(value={AssignsFields.class,I.class,Immutable.class,Mutable.class,ReadOnly.class,checkers.igj.IGJPlaceHolder.class})
@SupportedSourceVersion(value=RELEASE_7)
public class IGJChecker
extends BaseTypeChecker

An annotation processor that checks a program use of IGJ mutability type annotations, (@ReadOnly, @Mutable, and @Immutable).


Field Summary
protected  AnnotationFactory annoFactory
          Annotation factory to create annotation mirrors
protected  AnnotationMirror ASSIGNS_FIELDS
          Supported Annotations for IGJ.
protected  IGJAnnotatedTypeFactory factory
           
protected  AnnotationMirror I
          Supported Annotations for IGJ.
protected static String IMMUTABILITY_KEY
           
protected  AnnotationMirror IMMUTABLE
          Supported Annotations for IGJ.
protected  AnnotationMirror MUTABLE
          Supported Annotations for IGJ.
protected  AnnotationMirror PLACE_HOLDER
          Supported Annotations for IGJ.
protected  AnnotationMirror READONLY
          Supported Annotations for IGJ.
 
Fields inherited from class checkers.basetype.BaseTypeChecker
qualHierarchy
 
Fields inherited from class checkers.source.SourceChecker
currentRoot, env, messager, messages, skipPattern, trees, visitor
 
Fields inherited from class javax.annotation.processing.AbstractProcessor
processingEnv
 
Constructor Summary
IGJChecker()
           
 
Method Summary
 IGJAnnotatedTypeFactory createFactory(CompilationUnitTree root)
          Constructs an instance of the appropriate type factory for the implemented type system.
protected  TypeHierarchy createTypeHierarchy()
          Creates the type subtyping checker using the current type qualifier hierarchy.
 void init(ProcessingEnvironment processingEnv)
          
 boolean isAssignable(AnnotatedTypeMirror varType, Tree varTree)
          Return true if the assignment variable is an assignable field or variable, and returns false otherwise.
 boolean isValidUse(AnnotatedTypeMirror elemType, AnnotatedTypeMirror use)
          Tests whether the one annotated type is a valid use of another, with respect to the annotations on these types, without descending into generic or array types (i.e.
 
Methods inherited from class checkers.basetype.BaseTypeChecker
createQualifierHierarchy, getQualifierHierarchy, getSourceVisitor, getSupportedLintOptions, getSupportedTypeQualifiers, isSubtype
 
Methods inherited from class checkers.source.SourceChecker
getDefaultSkipPattern, getLintOption, getLintOption, getMessages, getProcessingEnvironment, getShouldSkip, getSupportedAnnotationTypes, getSupportedOptions, getSuppressWarningsKey, message, process, report, shouldSkip
 
Methods inherited from class javax.annotation.processing.AbstractProcessor
getCompletions, getSupportedSourceVersion, isInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

annoFactory

protected AnnotationFactory annoFactory
Annotation factory to create annotation mirrors


READONLY

protected AnnotationMirror READONLY
Supported Annotations for IGJ. Used for subtyping rules


MUTABLE

protected AnnotationMirror MUTABLE
Supported Annotations for IGJ. Used for subtyping rules


IMMUTABLE

protected AnnotationMirror IMMUTABLE
Supported Annotations for IGJ. Used for subtyping rules


I

protected AnnotationMirror I
Supported Annotations for IGJ. Used for subtyping rules


PLACE_HOLDER

protected AnnotationMirror PLACE_HOLDER
Supported Annotations for IGJ. Used for subtyping rules


ASSIGNS_FIELDS

protected AnnotationMirror ASSIGNS_FIELDS
Supported Annotations for IGJ. Used for subtyping rules


factory

protected IGJAnnotatedTypeFactory factory

IMMUTABILITY_KEY

protected static final String IMMUTABILITY_KEY
See Also:
Constant Field Values
Constructor Detail

IGJChecker

public IGJChecker()
Method Detail

init

public void init(ProcessingEnvironment processingEnv)
Description copied from class: SourceChecker

Specified by:
init in interface Processor
Overrides:
init in class BaseTypeChecker
See Also:
AbstractProcessor.init(javax.annotation.processing.ProcessingEnvironment)

isValidUse

public boolean isValidUse(AnnotatedTypeMirror elemType,
                          AnnotatedTypeMirror use)
Description copied from class: BaseTypeChecker
Tests whether the one annotated type is a valid use of another, with respect to the annotations on these types, without descending into generic or array types (i.e. only performing the validity check on the raw type or outmost array dimension). In most cases, useType simply needs to be a suptype of elemType.

Overrides:
isValidUse in class BaseTypeChecker
Parameters:
elemType - the type of the class (TypeElement)
use - the use of the class (instance type)
Returns:
if the useType is a valid use of elemType

createTypeHierarchy

protected TypeHierarchy createTypeHierarchy()
Description copied from class: BaseTypeChecker
Creates the type subtyping checker using the current type qualifier hierarchy. Subclasses may override this method to specify new type checking rules beyond the typical java subtyping rules.

Overrides:
createTypeHierarchy in class BaseTypeChecker
Returns:
the type relations class to check type subtyping

isAssignable

public boolean isAssignable(AnnotatedTypeMirror varType,
                            Tree varTree)
Return true if the assignment variable is an assignable field or variable, and returns false otherwise. A field is assignable if it is 1. a static field 2. marked Assignable 3. accessed through a mutable reference 4. reassigned with an AssignsFields method and owned by 'this'

Overrides:
isAssignable in class BaseTypeChecker
Parameters:
varType - the annotated variable type
varTree - tree used to access the variable
Returns:
true iff variable is assignable in the current scope

createFactory

public IGJAnnotatedTypeFactory createFactory(CompilationUnitTree root)
Description copied from class: BaseTypeChecker
Constructs an instance of the appropriate type factory for the implemented type system. The default implementation returns a type factory whose qualified class name is the qualified name of the checker with 'Factory' in place of 'Checker'. If no factory is found, it returns AnnotatedTypeFactory. Subclasses may override this to construct the appropriate factory.

Overrides:
createFactory in class BaseTypeChecker
Parameters:
root - the currently visited compilation unit
Returns:
the appropriate type factory