checkers.fenum
Class FenumChecker

java.lang.Object
  extended by javax.annotation.processing.AbstractProcessor
      extended by com.sun.source.util.AbstractTypeProcessor
          extended by checkers.source.SourceChecker
              extended by checkers.basetype.BaseTypeChecker
                  extended by checkers.fenum.FenumChecker
All Implemented Interfaces:
Processor

@SupportedOptions(value="qual")
public class FenumChecker
extends BaseTypeChecker

The main checker class for the fake enum checker. There are two options to distinguish different enumerators:

  1. @Fenum("Name"): introduces a fake enumerator with the name "Name". Enumerators with different names are distinct. The default name is empty, but you are encouraged to use a unique name for your purpose.
  2. Alternatively, you can specify the annotation to use with the -Aqual command line argument.
  3. Author:
    wmdietl

    Field Summary
    Modifier and Type Field and Description
     
    Fields inherited from class checkers.source.SourceChecker
    currentPath, currentRoot, env, messager, messages, trees
     
    Fields inherited from class javax.annotation.processing.AbstractProcessor
    processingEnv
     
    Constructor Summary
    Constructor and Description
    FenumChecker()
               
     
    Method Summary
    Modifier and Type Method and Description
    protected  Set<Class<? extends Annotation>> createSupportedTypeQualifiers()
              Copied from BasicChecker.
     Collection<String> getSuppressWarningsKey()
              Copied from BasicChecker; cannot reuse it, because BasicChecker is final.
     boolean isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType declarationType, AnnotatedTypeMirror.AnnotatedDeclaredType useType)
              Tests that the qualifiers present on the useType are valid qualifiers, given the qualifiers on the declaration of the type, declarationType.
     
    Methods inherited from class checkers.basetype.BaseTypeChecker
    createFactory, createQualifierHierarchy, createSourceVisitor, createTypeHierarchy, getQualifierHierarchy, getSupportedLintOptions, getSupportedTypeQualifiers, init, isAssignable, isSubtype
     
    Methods inherited from class checkers.source.SourceChecker
    fullMessageOf, getLintOption, getLintOption, getMessages, getProcessingEnvironment, getShouldSkip, getSupportedAnnotationTypes, getSupportedOptions, getSupportedSourceVersion, message, report, typeProcess
     
    Methods inherited from class com.sun.source.util.AbstractTypeProcessor
    process, typeProcessingOver
     
    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

    FenumChecker

    public FenumChecker()
    Method Detail

    createSupportedTypeQualifiers

    protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers()
    Copied from BasicChecker. Instead of returning an empty set if no "quals" option is given, we return Fenum as the only qualifier.

    Overrides:
    createSupportedTypeQualifiers in class BaseTypeChecker
    Returns:
    the type qualifiers supported this processor, or an empty set if none
    See Also:
    TypeQualifiers

    getSuppressWarningsKey

    public Collection<String> getSuppressWarningsKey()
    Copied from BasicChecker; cannot reuse it, because BasicChecker is final.

    Overrides:
    getSuppressWarningsKey in class SourceChecker
    Returns:
    String keys that a checker honors for suppressing warnings and errors that it issues
    See Also:
    SuppressWarningsKey

    isValidUse

    public boolean isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType declarationType,
                              AnnotatedTypeMirror.AnnotatedDeclaredType useType)
    Description copied from class: BaseTypeChecker
    Tests that the qualifiers present on the useType are valid qualifiers, given the qualifiers on the declaration of the type, declarationType.

    The check is shallow, as it does not descend into generic or array types (i.e. only performing the validity check on the raw type or outmost array dimension). BaseTypeVisitor.validateTypeOf(Tree) would call this for each type argument or array dimention separately.

    For instance, in the IGJ type system, a @Mutable is an invalid qualifier for String, as String is declared as @Immutable String.

    In most cases, useType simply needs to be a subtype of declarationType, but there are exceptions. In IGJ, a variable may be declared @ReadOnly String, even though String is @Immutable String; ReadOnly is not a subtype of Immutable.

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