Class RegexVisitor

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

    public class RegexVisitor
    extends BaseTypeVisitor<RegexAnnotatedTypeFactory>
    A type-checking visitor for the Regex type system.

    This visitor does the following:

    1. Allows any String to be passed to Pattern.compile if the Pattern.LITERAL flag is passed.
    2. Checks calls to MatchResult.start, MatchResult.end and MatchResult.group to ensure that a valid group number is passed.
    See Also:
    RegexChecker
    • Constructor Detail

      • RegexVisitor

        public RegexVisitor​(BaseTypeChecker checker)
        Create a RegexVisitor.
        Parameters:
        checker - the associated RegexChecker
    • Method Detail

      • 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<RegexAnnotatedTypeFactory>