Class RegexVisitor

java.lang.Object
com.sun.source.util.TreeScanner<R,P>
com.sun.source.util.TreePathScanner<R,P>
All Implemented Interfaces:
com.sun.source.tree.TreeVisitor<Void,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 compound String concatenation to ensure correct usage of Regex Strings.
  3. Checks calls to MatchResult.start, MatchResult.end and MatchResult.group to ensure that a valid group number is passed.
See Also:
  • Constructor Details

    • RegexVisitor

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

    • visitMethodInvocation

      public Void visitMethodInvocation(com.sun.source.tree.MethodInvocationTree node, Void p)
      Case 1: Don't require a Regex annotation on the String argument to Pattern.compile if the Pattern.LITERAL flag is passed.
      Specified by:
      visitMethodInvocation in interface com.sun.source.tree.TreeVisitor<Void,Void>
      Overrides:
      visitMethodInvocation in class BaseTypeVisitor<RegexAnnotatedTypeFactory>