public class OptionalVisitor extends BaseTypeVisitor<BaseAnnotatedTypeFactory>
BaseTypeVisitor.OverrideChecker
atypeFactory, checker, contractsUtils, positions, TARGET, targetValueElement, typeValidator, visitorState
elements, root, trees, treesWithSuppressWarnings, types
Constructor and Description |
---|
OptionalVisitor(BaseTypeChecker checker)
Create an OptionalVisitor.
|
Modifier and Type | Method and Description |
---|---|
protected BaseTypeValidator |
createTypeValidator() |
void |
handleConditionalStatementIsPresentGet(IfTree node)
Part of rule #3.
|
void |
handleCreationElimination(MethodInvocationTree node)
Rule #4.
|
void |
handleTernaryIsPresentGet(ConditionalExpressionTree node)
Part of rule #3.
|
static StatementTree |
skipBlocks(StatementTree tree)
If the given tree is a block tree with a single element, return the enclosed non-block
statement.
|
Void |
visitConditionalExpression(ConditionalExpressionTree node,
Void p)
If the computation of the type of the ConditionalExpressionTree in
org.checkerframework.framework.type.TypeFromTree.TypeFromExpression.visitConditionalExpression(ConditionalExpressionTree,
AnnotatedTypeFactory) is correct, the following checks are redundant.
|
Void |
visitIf(IfTree node,
Void p) |
Void |
visitMethodInvocation(MethodInvocationTree node,
Void p)
Performs a method invocation check.
|
Void |
visitVariable(VariableTree node,
Void p)
Rule #6 (partial).
|
checkAccess, checkArguments, checkArrayInitialization, checkConditionalPostcondition, checkConstructorInvocation, checkConstructorResult, checkContract, checkDefaultConstructor, checkExceptionParameter, checkExtendsImplements, checkFieldInvariantDeclarations, checkForAnnotatedJdk, checkMethodInvocability, checkMethodReferenceAsOverride, checkOverride, checkOverride, checkPostcondition, checkPreconditions, checkSuperConstructorCall, checkThisConstructorCall, checkThisOrSuperConstructorCall, checkThrownExpression, checkTypeArguments, checkTypecastRedundancy, checkTypecastSafety, checkVarargs, commonAssignmentCheck, commonAssignmentCheck, commonAssignmentCheck, createOverrideChecker, createTypeFactory, enclosingMemberSelect, enclosingStatement, getExceptionParameterLowerBoundAnnotations, getThrowUpperBoundAnnotations, getTypeFactory, isAccessAllowed, isValidUse, isValidUse, isValidUse, processClassTree, reportPurityErrors, scan, setRoot, shouldSkipUses, skipReceiverSubtypeCheck, testTypevarContainment, typeCheckVectorCopyIntoArgument, validateType, validateTypeOf, visitAnnotation, visitArrayAccess, visitAssignment, visitCatch, visitClass, visitCompilationUnit, visitCompoundAssignment, visitEnhancedForLoop, visitIdentifier, visitInstanceOf, visitLambdaExpression, visitMemberReference, visitMethod, visitNewArray, visitNewClass, visitParameterizedType, visitReturn, visitThrow, visitTypeCast, visitTypeParameter, visitUnary
visit
getCurrentPath, scan
reduce, scan, visitAnnotatedType, visitArrayType, visitAssert, visitBinary, visitBlock, visitBreak, visitCase, visitContinue, visitDoWhileLoop, visitEmptyStatement, visitErroneous, visitExpressionStatement, visitForLoop, visitImport, visitIntersectionType, visitLabeledStatement, visitLiteral, visitMemberSelect, visitModifiers, visitOther, visitParenthesized, visitPrimitiveType, visitSwitch, visitSynchronized, visitTry, visitUnionType, visitWhileLoop, visitWildcard
public OptionalVisitor(BaseTypeChecker checker)
protected BaseTypeValidator createTypeValidator()
createTypeValidator
in class BaseTypeVisitor<BaseAnnotatedTypeFactory>
public Void visitConditionalExpression(ConditionalExpressionTree node, Void p)
BaseTypeVisitor
visitConditionalExpression
in interface TreeVisitor<Void,Void>
visitConditionalExpression
in class BaseTypeVisitor<BaseAnnotatedTypeFactory>
public void handleTernaryIsPresentGet(ConditionalExpressionTree node)
Pattern match for: VAR.isPresent() ? VAR.get().METHOD() : VALUE
Prefer: VAR.map(METHOD).orElse(VALUE);
public Void visitIf(IfTree node, Void p)
visitIf
in interface TreeVisitor<Void,Void>
visitIf
in class TreeScanner<Void,Void>
public void handleConditionalStatementIsPresentGet(IfTree node)
Pattern match for: if (VAR.isPresent()) { METHOD(VAR.get()); }
Prefer: VAR.ifPresent(METHOD);
public Void visitMethodInvocation(MethodInvocationTree node, Void p)
BaseTypeVisitor
An invocation of a method, m, on the receiver, r is valid only if:
visitMethodInvocation
in interface TreeVisitor<Void,Void>
visitMethodInvocation
in class BaseTypeVisitor<BaseAnnotatedTypeFactory>
public void handleCreationElimination(MethodInvocationTree node)
Pattern match for: CREATION().ELIMINATION()
Prefer: VAR.ifPresent(METHOD);
public Void visitVariable(VariableTree node, Void p)
Don't use Optional in fields and method parameters.
visitVariable
in interface TreeVisitor<Void,Void>
visitVariable
in class BaseTypeVisitor<BaseAnnotatedTypeFactory>
public static StatementTree skipBlocks(StatementTree tree)
tree
- a statement tree