Class InterningVisitor
java.lang.Object
com.sun.source.util.TreeScanner<R,P>
 
com.sun.source.util.TreePathScanner<R,P>
 
org.checkerframework.framework.source.SourceVisitor<Void,Void>
 
org.checkerframework.common.basetype.BaseTypeVisitor<InterningAnnotatedTypeFactory>
org.checkerframework.checker.interning.InterningVisitor
- All Implemented Interfaces:
- TreeVisitor<Void,- Void> 
Typechecks source code for interning violations. A type is considered interned if its primary
 annotation is 
Interned or InternedDistinct. This visitor reports errors or
 warnings for violations for the following cases:
 - either argument to a "==" or "!=" comparison is not Interned (error "not.interned"). As a special case, the comparison is permitted if either argument is InternedDistinct.
- the receiver and argument for a call to an equals method are both Interned (optional warning "unnecessary.equals")
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from class org.checkerframework.common.basetype.BaseTypeVisitorBaseTypeVisitor.OverrideChecker
- 
Field SummaryFields inherited from class org.checkerframework.common.basetype.BaseTypeVisitorassumePureGetters, atypeFactory, checker, DETERMINISTIC, IMPURE, methodTree, positions, PURE, qualHierarchy, showchecks, SIDE_EFFECT_FREE, TARGET, targetValueElement, typeHierarchy, typeValidator, unusedWhenElement, warnRedundantAnnotationsFields inherited from class org.checkerframework.framework.source.SourceVisitorelements, root, trees, treesWithSuppressWarnings, types
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidcheckConstructorResult(AnnotatedTypeMirror.AnnotatedExecutableType constructorType, ExecutableElement constructorElement) Issue a warning if the result type of the constructor declaration is not top.static booleanTests whether a method invocation is an invocation ofObject.equals(java.lang.Object)with one argument.protected booleanisTypeCastSafe(AnnotatedTypeMirror castType, AnnotatedTypeMirror exprType) Returns true if the cast is safe.voidprocessClassTree(ClassTree classTree) Method to implement the @UsesObjectEquals functionality.voidprocessMethodTree(String className, MethodTree tree) Type-check methodTree.booleanvalidateTypeOf(Tree tree) Tests whether the tree expressed by the passed type tree is a valid type, and emits an error if that is not the case (e.g.visitBinary(BinaryTree tree, Void p) Checks comparison operators, == and !=, for INTERNING violations.If lint option "dotequals" is specified, warn if the .equals method is used where reference equality is safe.Methods inherited from class org.checkerframework.common.basetype.BaseTypeVisitorcheckAccess, checkAccessAllowed, checkArguments, checkArrayInitialization, checkConditionalPostcondition, checkConstructorInvocation, checkContract, checkDefaultConstructor, checkExceptionParameter, checkExplicitAnnotationsOnIntersectionBounds, checkExtendsAndImplements, checkExtendsOrImplements, checkFieldInvariantDeclarations, checkMethodInvocability, checkMethodReferenceAsOverride, checkOverride, checkOverride, checkPostcondition, checkPreconditions, checkPurityAnnotations, checkQualifierParameter, checkSuperConstructorCall, checkThisConstructorCall, checkThisOrSuperConstructorCall, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckEndDiagnostic, commonAssignmentCheckStartDiagnostic, contractExpressionAndType, createOverrideChecker, createTypeFactory, createTypeFactoryPublic, createTypeValidator, enclosingMemberSelect, enclosingStatement, getExceptionParameterLowerBoundAnnotations, getThrowUpperBoundAnnotations, getTypeFactory, isValidUse, isValidUse, isValidUse, reportMethodInvocabilityError, reportPurityErrors, scan, setRoot, shouldPerformContractInference, shouldSkipUses, shouldWarnAboutIrrelevantJavaTypes, skipReceiverSubtypeCheck, testAnnotationInsertion, testJointJavacJavaParserVisitor, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateType, visitAnnotatedType, visitAnnotatedType, visitAnnotation, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitConditionalExpression, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitMethod, visitNewArray, visitNewClass, visitReturn, visitSwitchExpression17, visitThrow, visitTypeCast, visitTypeParameter, visitUnary, visitVariable, warnAboutIrrelevantJavaTypes, warnInvalidPolymorphicQualifier, warnInvalidPolymorphicQualifier, warnRedundantAnnotationsMethods inherited from class org.checkerframework.framework.source.SourceVisitorvisitMethods inherited from class com.sun.source.util.TreePathScannergetCurrentPath, scanMethods inherited from class com.sun.source.util.TreeScannerreduce, scan, visitArrayAccess, visitArrayType, visitAssert, visitBindingPattern, visitBlock, visitBreak, visitCase, visitContinue, visitDefaultCaseLabel, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExports, visitExpressionStatement, visitForLoop, visitGuardedPattern, visitIf, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitMemberSelect, visitModifiers, visitModule, visitOpens, visitOther, visitPackage, visitParameterizedType, visitParenthesized, visitParenthesizedPattern, visitPrimitiveType, visitProvides, visitRequires, visitSwitch, visitSwitchExpression, visitSynchronized, visitTry, visitUnionType, visitUses, visitWhileLoop, visitWildcard, visitYield
- 
Constructor Details- 
InterningVisitorCreate an InterningVisitor.
 
- 
- 
Method Details- 
visitBinaryChecks comparison operators, == and !=, for INTERNING violations.- Specified by:
- visitBinaryin interface- TreeVisitor<Void,- Void> 
- Overrides:
- visitBinaryin class- TreeScanner<Void,- Void> 
 
- 
visitMethodInvocationIf lint option "dotequals" is specified, warn if the .equals method is used where reference equality is safe.- Specified by:
- visitMethodInvocationin interface- TreeVisitor<Void,- Void> 
- Overrides:
- visitMethodInvocationin class- BaseTypeVisitor<InterningAnnotatedTypeFactory>
 
- 
processMethodTreeDescription copied from class:BaseTypeVisitorType-check methodTree. Subclasses should override this method instead ofBaseTypeVisitor.visitMethod(MethodTree, Void).- Overrides:
- processMethodTreein class- BaseTypeVisitor<InterningAnnotatedTypeFactory>
- Parameters:
- className- the class that contains the method, for diagnostics only
- tree- the method to type-check
 
- 
processClassTreeMethod to implement the @UsesObjectEquals functionality. If a class is annotated with @UsesObjectEquals, it must:- not override .equals(Object) and be a subclass of a class annotated with @UsesObjectEquals, or
- override equals(Object) with body "this == arg"
 - not have a superclass annotated with @UsesObjectEquals
 - Overrides:
- processClassTreein class- BaseTypeVisitor<InterningAnnotatedTypeFactory>
- Parameters:
- classTree- class to check
- See Also:
 
- 
checkConstructorResultprotected void checkConstructorResult(AnnotatedTypeMirror.AnnotatedExecutableType constructorType, ExecutableElement constructorElement) Description copied from class:BaseTypeVisitorIssue a warning if the result type of the constructor declaration is not top. If it is a supertype of the class, then a conflicting.annos error will also be issued byBaseTypeVisitor.isValidUse(AnnotatedTypeMirror.AnnotatedDeclaredType,AnnotatedTypeMirror.AnnotatedDeclaredType,Tree).- Overrides:
- checkConstructorResultin class- BaseTypeVisitor<InterningAnnotatedTypeFactory>
- Parameters:
- constructorType- the AnnotatedExecutableType for the constructor
- constructorElement- the element that declares the constructor
 
- 
validateTypeOfDescription copied from class:BaseTypeVisitorTests whether the tree expressed by the passed type tree is a valid type, and emits an error if that is not the case (e.g. '@Mutable String'). If the tree is a method or constructor, check the return type.- Overrides:
- validateTypeOfin class- BaseTypeVisitor<InterningAnnotatedTypeFactory>
- Parameters:
- tree- the AST type supplied by the user
- Returns:
- true if the tree is a valid type
 
- 
isInvocationOfEqualsTests whether a method invocation is an invocation ofObject.equals(java.lang.Object)with one argument.Returns true even if a method overloads Object.equals(Object), because of the common idiom of writing an equals method with a non-Object parameter, in addition to the equals method that overridesObject.equals(Object).- Parameters:
- tree- a method invocation tree
- Returns:
- true iff treeis a invocation ofequals()
 
- 
isTypeCastSafeDescription copied from class:BaseTypeVisitorReturns true if the cast is safe.Only primary qualifiers are checked unless the command line option "checkCastElementType" is supplied. - Overrides:
- isTypeCastSafein class- BaseTypeVisitor<InterningAnnotatedTypeFactory>
- Parameters:
- castType- annotated type of the cast
- exprType- annotated type of the casted expression
- Returns:
- true if the type cast is safe, false otherwise
 
 
-