Class GuiEffectVisitor

  • All Implemented Interfaces:
    com.sun.source.tree.TreeVisitor<java.lang.Void,​java.lang.Void>

    public class GuiEffectVisitor
    extends BaseTypeVisitor<GuiEffectTypeFactory>
    Require that only UI code invokes code with the UI effect.
    • Field Detail

      • debugSpew

        protected final boolean debugSpew
        Whether or not to display debugging information.
      • effStack

        protected final java.util.ArrayDeque<Effect> effStack
      • currentMethods

        protected final java.util.ArrayDeque<com.sun.source.tree.MethodTree> currentMethods
    • Constructor Detail

    • Method Detail

      • createTypeFactory

        protected GuiEffectTypeFactory createTypeFactory()
        Description copied from class: BaseTypeVisitor
        Constructs an instance of the appropriate type factory for the implemented type system.

        The default implementation uses the checker naming convention to create the appropriate type factory. If no factory is found, it returns BaseAnnotatedTypeFactory. It reflectively invokes the constructor that accepts this checker and 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.

        Overrides:
        createTypeFactory in class BaseTypeVisitor<GuiEffectTypeFactory>
        Returns:
        the appropriate type factory
      • checkMethodInvocability

        protected void checkMethodInvocability​(AnnotatedTypeMirror.AnnotatedExecutableType method,
                                               com.sun.source.tree.MethodInvocationTree tree)
        Description copied from class: BaseTypeVisitor
        Tests whether the method can be invoked using the receiver of the 'tree' method invocation, and issues a "method.invocation.invalid" if the invocation is invalid.

        This implementation tests whether the receiver in the method invocation is a subtype of the method receiver type. This behavior can be specialized by overriding skipReceiverSubtypeCheck.

        Overrides:
        checkMethodInvocability in class BaseTypeVisitor<GuiEffectTypeFactory>
        Parameters:
        method - the type of the invoked method
        tree - the method invocation tree
      • visitLambdaExpression

        public java.lang.Void visitLambdaExpression​(com.sun.source.tree.LambdaExpressionTree tree,
                                                    java.lang.Void p)
        Specified by:
        visitLambdaExpression in interface com.sun.source.tree.TreeVisitor<java.lang.Void,​java.lang.Void>
        Overrides:
        visitLambdaExpression in class BaseTypeVisitor<GuiEffectTypeFactory>
      • checkExtendsAndImplements

        protected void checkExtendsAndImplements​(com.sun.source.tree.ClassTree classTree)
        Description copied from class: BaseTypeVisitor
        In @A class X extends @B Y implements @C Z {}, enforce that @A must be a subtype of @B and @C.

        Also validate the types of the extends and implements clauses.

        Overrides:
        checkExtendsAndImplements in class BaseTypeVisitor<GuiEffectTypeFactory>
        Parameters:
        classTree - class tree to check
      • checkForPolymorphicQualifiers

        protected void checkForPolymorphicQualifiers​(com.sun.source.tree.ClassTree classTree)
        Description copied from class: BaseTypeVisitor
        Issues an "invalid.polymorphic.qualifier" error for all polymorphic annotations written on the class declaration.
        Overrides:
        checkForPolymorphicQualifiers in class BaseTypeVisitor<GuiEffectTypeFactory>
        Parameters:
        classTree - the class to check
      • visitMethodInvocation

        public java.lang.Void visitMethodInvocation​(com.sun.source.tree.MethodInvocationTree tree,
                                                    java.lang.Void p)
        Description copied from class: BaseTypeVisitor
        Performs a method invocation check.

        An invocation of a method, m, on the receiver, r is valid only if:

        • passed arguments are subtypes of corresponding m parameters
        • r is a subtype of m receiver type
        • if m is generic, passed type arguments are subtypes of m type variables
        Specified by:
        visitMethodInvocation in interface com.sun.source.tree.TreeVisitor<java.lang.Void,​java.lang.Void>
        Overrides:
        visitMethodInvocation in class BaseTypeVisitor<GuiEffectTypeFactory>
      • visitMethod

        public java.lang.Void visitMethod​(com.sun.source.tree.MethodTree tree,
                                          java.lang.Void p)
        Description copied from class: BaseTypeVisitor
        Checks that the method obeys override and subtype rules to all overridden methods. (Uses the pseudo-assignment logic to do so.)

        The override rule specifies that a method, m1, may override a method m2 only if:

        • m1 return type is a subtype of m2
        • m1 receiver type is a supertype of m2
        • m1 parameters are supertypes of corresponding m2 parameters
        Also, it issues a "missing.this" error for static method annotated receivers.
        Specified by:
        visitMethod in interface com.sun.source.tree.TreeVisitor<java.lang.Void,​java.lang.Void>
        Overrides:
        visitMethod in class BaseTypeVisitor<GuiEffectTypeFactory>
      • visitNewClass

        public java.lang.Void visitNewClass​(com.sun.source.tree.NewClassTree tree,
                                            java.lang.Void p)
        Description copied from class: BaseTypeVisitor
        Performs a new class invocation check.

        An invocation of a constructor, c, is valid only if:

        • passed arguments are subtypes of corresponding c parameters
        • if c is generic, passed type arguments are subtypes of c type variables
        Specified by:
        visitNewClass in interface com.sun.source.tree.TreeVisitor<java.lang.Void,​java.lang.Void>
        Overrides:
        visitNewClass in class BaseTypeVisitor<GuiEffectTypeFactory>