Skip to content

Commit

Permalink
Fix VoidUnused findings in EP.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 630020329
  • Loading branch information
graememorgan authored and Error Prone Team committed May 2, 2024
1 parent 9645b6d commit 5e2fdb4
Show file tree
Hide file tree
Showing 51 changed files with 104 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public Void visitIdentifier(IdentifierTree node, Void unused) {
generateConstraintsFromAnnotations(
((JCIdent) node).type, sym, declaredType, node, new ArrayDeque<>());
}
return super.visitIdentifier(node, unused);
return super.visitIdentifier(node, null);
}

private void generateConstraintsFromAnnotations(
Expand Down Expand Up @@ -192,7 +192,7 @@ public Void visitAssignment(AssignmentTree node, Void unused) {
? ((JCArrayAccess) node.getVariable()).getExpression().type
: TreeInfo.symbol((JCTree) node.getVariable()).type;
generateConstraintsForWrite(lhsType, null, node.getExpression(), node);
return super.visitAssignment(node, unused);
return super.visitAssignment(node, null);
}

@Override
Expand All @@ -201,7 +201,7 @@ public Void visitVariable(VariableTree node, Void unused) {
Symbol symbol = TreeInfo.symbolFor((JCTree) node);
generateConstraintsForWrite(symbol.type, symbol, node.getInitializer(), node);
}
return super.visitVariable(node, unused);
return super.visitVariable(node, null);
}

@Override
Expand All @@ -211,7 +211,7 @@ public Void visitReturn(ReturnTree node, Void unused) {
((MethodSymbol) TreeInfo.symbolFor((JCTree) currentMethodOrInitializerOrLambda));
generateConstraintsForWrite(sym.getReturnType(), sym, node.getExpression(), node);
}
return super.visitReturn(node, unused);
return super.visitReturn(node, null);
}

private static ImmutableList<TypeAndSymbol> expandVarargsToArity(
Expand Down Expand Up @@ -319,7 +319,7 @@ public Void visitMethodInvocation(MethodInvocationTree node, Void unused) {
actual,
iv -> qualifierConstraints.putEdge(iv, typeVarIv)));
}
return super.visitMethodInvocation(node, unused);
return super.visitMethodInvocation(node, null);
}

private static void visitTypeVarRefs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ public Void visitMemberReference(MemberReferenceTree tree, Void unused) {
state.getEndPosition(tree),
"::" + replacement);
}
return super.visitMemberReference(tree, unused);
return super.visitMemberReference(tree, null);
}
}.scan(state.getPath().getCompilationUnit(), null);
return fix.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Boolean reduce(Boolean r1, Boolean r2) {

@Override
public Boolean visitClass(ClassTree node, Void v) {
return firstNonNull(super.visitClass(node, v), false);
return firstNonNull(super.visitClass(node, null), false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,7 @@ public Type visitMethod(MethodTree node, Void unused) {

@Override
public Type visitParenthesized(ParenthesizedTree node, Void unused) {
return visit(node.getExpression(), unused);
return visit(node.getExpression(), null);
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ private static TreeScanner<Void, Void> createFindIdentifiersScanner(
return new TreeScanner<Void, Void>() {
@Override
public Void scan(Tree tree, Void unused) {
return Objects.equals(stoppingPoint, tree) ? null : super.scan(tree, unused);
return Objects.equals(stoppingPoint, tree) ? null : super.scan(tree, null);
}

@Override
Expand All @@ -370,7 +370,7 @@ public Void scan(Iterable<? extends Tree> iterable, Void unused) {
}
iterable = builder.build();
}
return super.scan(iterable, unused);
return super.scan(iterable, null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ public Void visitUnary(UnaryTree tree, Void unused) {
default:
break;
}
return super.visitUnary(tree, unused);
return super.visitUnary(tree, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ private void visitNewClassOrMethodInvocation(ExpressionTree tree) {
@Override
public Void visitMethodInvocation(MethodInvocationTree tree, Void unused) {
visitNewClassOrMethodInvocation(tree);
return super.visitMethodInvocation(tree, unused);
return super.visitMethodInvocation(tree, null);
}

@Override
public Void visitNewClass(NewClassTree tree, Void unused) {
visitNewClassOrMethodInvocation(tree);
return super.visitNewClass(tree, unused);
return super.visitNewClass(tree, null);
}
}.scan(new TreePath(state.getPath(), body), null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public IdentifierTree visitIdentifier(IdentifierTree node, Void unused) {
return node;
}
}
return super.visitIdentifier(node, unused);
return super.visitIdentifier(node, null);
}

// We need to move any type annotation inside the qualified usage to preserve semantics,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public Void scan(Tree node, Void unused) {
if (notFirst.get()) {
return null;
}
return super.scan(node, unused);
return super.scan(node, null);
}

@Override
Expand All @@ -308,9 +308,9 @@ public Void visitMethodInvocation(MethodInvocationTree node, Void unused) {
}

sameMethodInvocations.add(node);
return super.visitMethodInvocation(node, unused);
return super.visitMethodInvocation(node, null);
}
return super.visitMethodInvocation(node, unused);
return super.visitMethodInvocation(node, null);
}
}.scan(expressionPath.getLeaf(), null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public Void visitIdentifier(IdentifierTree node, Void unused) {
if (Objects.equals(sym, ASTHelpers.getSymbol(node))) {
found[0] = true;
}
return super.visitIdentifier(node, unused);
return super.visitIdentifier(node, null);
}
},
null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public Void visitMethodInvocation(MethodInvocationTree tree, Void unused) {
firstHit[0] = tree;
}
});
return super.visitMethodInvocation(tree, unused);
return super.visitMethodInvocation(tree, null);
}

private Optional<SuggestedFix> tryFix(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public Void visitBlock(BlockTree block, Void unused) {
if (description != NO_MATCH) {
state.reportMatch(description);
}
return super.visitBlock(block, unused);
return super.visitBlock(block, null);
}
},
null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public Void visitMethodInvocation(MethodInvocationTree tree, Void unused) {
String assertType = ASTHelpers.getSymbol(tree).getSimpleName().toString();
fix.addStaticImport("org.junit.Assert." + assertType);
}
return super.visitMethodInvocation(tree, unused);
return super.visitMethodInvocation(tree, null);
}
},
null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public Void visitClass(ClassTree classTree, Void unused) {
return null;
}
inMethod = false;
return super.visitClass(classTree, unused);
return super.visitClass(classTree, null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ private NullComparisonScanner(VisitorState state) {

@Override
public Void visitMethod(MethodTree method, Void unused) {
return isSuppressed(method, state) ? null : super.visitMethod(method, unused);
return isSuppressed(method, state) ? null : super.visitMethod(method, null);
}

@Override
public Void visitClass(ClassTree clazz, Void unused) {
return isSuppressed(clazz, state) ? null : super.visitClass(clazz, unused);
return isSuppressed(clazz, state) ? null : super.visitClass(clazz, null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public Void visitVariable(VariableTree tree, Void unused) {
&& ASTHelpers.enclosingClass(symbol).equals(classSymbol)) {
fields.add(symbol);
}
return super.visitVariable(tree, unused);
return super.visitVariable(tree, null);
}
}

Expand Down Expand Up @@ -209,7 +209,7 @@ public Void visitMethod(MethodTree tree, Void unused) {
public Void visitVariable(VariableTree tree, Void unused) {
Symbol symbol = ASTHelpers.getSymbol(tree);
if (!symbol.getKind().equals(ElementKind.PARAMETER)) {
return super.visitVariable(tree, unused);
return super.visitVariable(tree, null);
}
String variableName = symbol.toString();
Symbol matchedField = fields.get(Ascii.toLowerCase(variableName));
Expand All @@ -219,7 +219,7 @@ public Void visitVariable(VariableTree tree, Void unused) {
matchedParameters.put(getCurrentPath(), matchedField);
}
}
return super.visitVariable(tree, unused);
return super.visitVariable(tree, null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public Void visitClass(ClassTree classTree, Void unused) {
.build()));
}
}
return super.visitClass(classTree, unused);
return super.visitClass(classTree, null);
}
}.scan(tree, null);
return Description.NO_MATCH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public Void visitMethodInvocation(MethodInvocationTree callTree, Void unused) {
callTree.getMethodSelect(), receiverSym.name + "." + apply);
}
}
return super.visitMethodInvocation(callTree, unused);
return super.visitMethodInvocation(callTree, null);
}
},
null);
Expand Down Expand Up @@ -250,7 +250,7 @@ public Void visitMethodInvocation(MethodInvocationTree callTree, Void unused) {
if (sym.equals(methodSymbol)) {
methodMap.put(methodSymbol.toString(), callTree);
}
return super.visitMethodInvocation(callTree, unused);
return super.visitMethodInvocation(callTree, null);
}
},
null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public Void visitSynchronized(SynchronizedTree node, Void aVoid) {
if (lock.equals(getSymbol(expression))) {
fix.replace(expression, lockName);
}
return super.visitSynchronized(node, aVoid);
return super.visitSynchronized(node, null);
}
}.scan(state.getPath().getCompilationUnit(), null);
return fix.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,25 +169,25 @@ public Void visitUnary(UnaryTree tree, Void unused) {
break;
default: // fall out
}
return super.visitUnary(tree, unused);
return super.visitUnary(tree, null);
}

@Override
public Void visitMethodInvocation(MethodInvocationTree tree, Void unused) {
check(ASTHelpers.getReceiver(tree));
return super.visitMethodInvocation(tree, unused);
return super.visitMethodInvocation(tree, null);
}

@Override
public Void visitAssignment(AssignmentTree tree, Void unused) {
check(tree.getVariable());
return super.visitAssignment(tree, unused);
return super.visitAssignment(tree, null);
}

@Override
public Void visitCompoundAssignment(CompoundAssignmentTree tree, Void unused) {
check(tree.getVariable());
return super.visitCompoundAssignment(tree, unused);
return super.visitCompoundAssignment(tree, null);
}

private void check(ExpressionTree expression) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Void visitIdentifier(IdentifierTree node, Void unused) {
if (node.getName().contentEquals("i")) {
result[0] = true;
}
return super.visitIdentifier(node, unused);
return super.visitIdentifier(node, null);
}
}.scan(tree, null);
return result[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ private SuggestedFix fixQualifiers(VisitorState state, MethodSymbol sym, Suggest
@Override
public Void visitMemberSelect(MemberSelectTree tree, Void unused) {
fixQualifier(tree, tree.getExpression());
return super.visitMemberSelect(tree, unused);
return super.visitMemberSelect(tree, null);
}

@Override
public Void visitMemberReference(MemberReferenceTree tree, Void unused) {
fixQualifier(tree, tree.getQualifierExpression());
return super.visitMemberReference(tree, unused);
return super.visitMemberReference(tree, null);
}

private void fixQualifier(Tree tree, ExpressionTree qualifierExpression) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public Boolean visitMethodInvocation(MethodInvocationTree tree, Void unused) {
ASTHelpers.isSuper(memberSelect.getExpression())
&& memberSelect.getIdentifier().contentEquals(overridingMethodName);
}
return result || super.visitMethodInvocation(tree, unused);
return result || super.visitMethodInvocation(tree, null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ && getType(initializer).getKind() != TypeKind.NULL
mutable.add(symbol);
}
}
return super.visitVariable(variableTree, unused);
return super.visitVariable(variableTree, null);
}
}

Expand All @@ -202,7 +202,7 @@ private ReturnTypesScanner(
@Override
public Void visitMethod(MethodTree methodTree, Void unused) {
if (!RETURNS_COLLECTION.matches(methodTree.getReturnType(), state)) {
return super.visitMethod(methodTree, unused);
return super.visitMethod(methodTree, null);
}
MethodScanner scanner = new MethodScanner();
scanner.scan(getCurrentPath(), null);
Expand All @@ -219,7 +219,7 @@ public Void visitMethod(MethodTree methodTree, Void unused) {
state))
.build());
}
return super.visitMethod(methodTree, unused);
return super.visitMethod(methodTree, null);
}

private final class MethodScanner extends TreePathScanner<Void, Void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public Void visitAssignment(AssignmentTree node, Void unused) {
if (symbol.equals(getSymbol(node.getVariable()))) {
initializers.add(new TreePath(getCurrentPath(), node.getExpression()));
}
return super.visitAssignment(node, unused);
return super.visitAssignment(node, null);
}
}.scan(state.getPath().getParentPath(), null);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ public Void visitReturn(ReturnTree node, Void unused) {
if (method != null) {
symbolsToType.put(method, getType(node.getExpression()));
}
return super.visitReturn(node, unused);
return super.visitReturn(node, null);
}

@Override
public Void visitLambdaExpression(LambdaExpressionTree node, Void unused) {
currentMethod.addLast(null);
super.visitLambdaExpression(node, unused);
super.visitLambdaExpression(node, null);
currentMethod.removeLast();
return null;
}
Expand Down

0 comments on commit 5e2fdb4

Please sign in to comment.