public class RegexVisitor extends BaseTypeVisitor<RegexChecker>
MatchResult.start, MatchResult.end
and MatchResult.group to ensure that a valid group number is passed.RegexCheckerBaseTypeVisitor.TypeValidatorannoFactory, annoTypes, checker, options, typeValidator, visitorStateatypeFactory, elements, root, trees, types| Constructor and Description |
|---|
RegexVisitor(RegexChecker checker,
@Nullable CompilationUnitTree root) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
boolean |
isValidUse(AnnotatedTypeMirror.AnnotatedPrimitiveType type)
Tests that the qualifiers present on the primitive type are valid.
|
@Nullable Void |
visitCompoundAssignment(CompoundAssignmentTree node,
@Nullable Void p)
Case 2: Check String compound concatenation for valid Regex use.
|
@Nullable Void |
visitMethodInvocation(MethodInvocationTree node,
@Nullable 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, checkConstructorInvocation, checkDefaultConstructor, checkForAnnotatedJdk, checkMethodInvocability, checkOverride, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, createTypeValidator, enclosingMemberSelect, enclosingStatement, isAccessAllowed, isAssignable, isValidUse, isVectorCopyInto, scan, shouldSkipUses, typeCheckVectorCopyIntoArgument, validateTypeOf, visitAnnotation, visitArrayAccess, visitAssignment, visitClass, visitCompilationUnit, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitMethod, visitNewArray, visitNewClass, visitParameterizedType, visitReturn, visitTypeCast, visitTypeParameter, visitUnary, visitVariablegetCurrentPath, scanreduce, scan, visitAnnotatedType, visitArrayType, visitAssert, visitBinary, visitBlock, visitBreak, visitCase, visitCatch, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExpressionStatement, visitForLoop, visitIf, visitImport, visitLabeledStatement, visitLambdaExpression, visitLiteral, visitMemberReference, visitMemberSelect, visitModifiers, visitOther, visitParenthesized, visitPrimitiveType, visitSwitch, visitSynchronized, visitThrow, visitTry, visitUnionType, visitWhileLoop, visitWildcardpublic RegexVisitor(RegexChecker checker, @Nullable CompilationUnitTree root)
public @Nullable Void visitMethodInvocation(MethodInvocationTree node, @Nullable Void p)
visitMethodInvocation in interface TreeVisitor<@Nullable Void,@Nullable Void>visitMethodInvocation in class BaseTypeVisitor<RegexChecker>public @Nullable Void visitCompoundAssignment(CompoundAssignmentTree node, @Nullable Void p)
visitCompoundAssignment in interface TreeVisitor<@Nullable Void,@Nullable Void>visitCompoundAssignment in class BaseTypeVisitor<RegexChecker>public boolean isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType declarationType, AnnotatedTypeMirror.AnnotatedDeclaredType useType)
BaseTypeVisitor
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
outermost array dimension). BaseTypeVisitor.validateTypeOf(Tree)
would call this for each type argument or array dimension 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.
isValidUse in class BaseTypeVisitor<RegexChecker>declarationType - the type of the class (TypeElement)useType - the use of the class (instance type)public boolean isValidUse(AnnotatedTypeMirror.AnnotatedPrimitiveType type)
BaseTypeVisitorisValidUse in class BaseTypeVisitor<RegexChecker>