public class RegexVisitor extends BaseTypeVisitor<RegexAnnotatedTypeFactory>
This visitor does the following:
MatchResult.start
, MatchResult.end
and MatchResult.group
to ensure that a valid group number is passed.
RegexChecker
BaseTypeVisitor.OverrideChecker
atypeFactory, checker, contractsUtils, positions, typeValidator, visitorState
elements, root, trees, types
Constructor and Description |
---|
RegexVisitor(BaseTypeChecker checker) |
Modifier and Type | Method and Description |
---|---|
boolean |
isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType declarationType,
AnnotatedTypeMirror.AnnotatedDeclaredType useType,
com.sun.source.tree.Tree tree)
Case 2: Check String compound concatenation for valid Regex use.
|
boolean |
isValidUse(AnnotatedTypeMirror.AnnotatedPrimitiveType type,
com.sun.source.tree.Tree tree)
Tests that the qualifiers present on the primitive type are valid.
|
java.lang.Void |
visitMethodInvocation(com.sun.source.tree.MethodInvocationTree node,
java.lang.Void p)
Case 1: Don't require a Regex annotation on the String argument to Pattern.compile if the
Pattern.LITERAL flag is passed.
|
checkAccess, checkArguments, checkArrayInitialization, checkAssignability, checkConditionalPostcondition, checkConstructorInvocation, checkContract, checkDefaultConstructor, checkExceptionParameter, checkFieldInvariantDeclarations, checkForAnnotatedJdk, checkMethodInvocability, checkMethodReferenceAsOverride, checkOverride, checkOverride, checkPostcondition, checkPreconditions, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, createOverrideChecker, createTypeFactory, createTypeValidator, enclosingMemberSelect, enclosingStatement, getExceptionParameterLowerBoundAnnotations, getThrowUpperBoundAnnotations, getTypeFactory, isAccessAllowed, isAssignable, isValidUse, isVectorCopyInto, processClassTree, reportPurityErrors, scan, setRoot, shouldSkipUses, skipReceiverSubtypeCheck, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateType, validateTypeOf, visitAnnotation, visitArrayAccess, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitMethod, visitNewArray, visitNewClass, visitParameterizedType, visitReturn, visitThrow, visitTry, visitTypeCast, visitTypeParameter, visitUnary, visitVariable
visit
reduce, scan, visitAnnotatedType, visitArrayType, visitAssert, visitBinary, visitBlock, visitBreak, visitCase, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExpressionStatement, visitForLoop, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitMemberSelect, visitModifiers, visitOther, visitParenthesized, visitPrimitiveType, visitSwitch, visitSynchronized, visitUnionType, visitWhileLoop, visitWildcard
public RegexVisitor(BaseTypeChecker checker)
public java.lang.Void visitMethodInvocation(com.sun.source.tree.MethodInvocationTree node, java.lang.Void p)
visitMethodInvocation
in interface com.sun.source.tree.TreeVisitor<java.lang.Void,java.lang.Void>
visitMethodInvocation
in class BaseTypeVisitor<RegexAnnotatedTypeFactory>
public boolean isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType declarationType, AnnotatedTypeMirror.AnnotatedDeclaredType useType, com.sun.source.tree.Tree tree)
isValidUse
in class BaseTypeVisitor<RegexAnnotatedTypeFactory>
declarationType
- the type of the class (TypeElement)useType
- the use of the class (instance type)tree
- the tree where the type is usedpublic boolean isValidUse(AnnotatedTypeMirror.AnnotatedPrimitiveType type, com.sun.source.tree.Tree tree)
BaseTypeVisitor
The default implementation always returns true. Subclasses should override this method to limit what annotations are allowed on primitive types.
isValidUse
in class BaseTypeVisitor<RegexAnnotatedTypeFactory>
type
- the use of the primitive typetree
- the tree where the type is used