Skip to content

Commit ce7852b

Browse files
eaftancushon
authored andcommitted
Remove unused method parameters and private method
and remove unnecessary explicit type argument in constructor call. MOE_MIGRATED_REVID=139846704
1 parent ba12d25 commit ce7852b

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ boolean isYes() {
257257
private final Indent.Const minusFour;
258258
private final Indent.Const plusTwo;
259259
private final Indent.Const plusFour;
260-
private final Indent.Const plusEight;
261260

262261
private static final ImmutableList<Op> breakList(Optional<BreakTag> breakTag) {
263262
return ImmutableList.<Op>of(Doc.Break.make(Doc.FillMode.UNIFIED, " ", ZERO, breakTag));
@@ -294,7 +293,6 @@ public JavaInputAstVisitor(OpsBuilder builder, int indentMultiplier) {
294293
minusFour = Indent.Const.make(-4, indentMultiplier);
295294
plusTwo = Indent.Const.make(+2, indentMultiplier);
296295
plusFour = Indent.Const.make(+4, indentMultiplier);
297-
plusEight = Indent.Const.make(+8, indentMultiplier);
298296
}
299297

300298
/** A record of whether we have visited into an expression. */
@@ -425,7 +423,7 @@ public Void visitNewArray(NewArrayTree node, Void unused) {
425423
TypeWithDims extractedDims = DimensionHelpers.extractDims(node.getType(), SortedDims.YES);
426424
Tree base = extractedDims.node;
427425

428-
Deque<ExpressionTree> dimExpressions = new ArrayDeque<ExpressionTree>(node.getDimensions());
426+
Deque<ExpressionTree> dimExpressions = new ArrayDeque<>(node.getDimensions());
429427

430428
Deque<List<AnnotationTree>> annotations = new ArrayDeque<>();
431429
annotations.addAll((List<List<AnnotationTree>>) node.getDimAnnotations());
@@ -1064,7 +1062,7 @@ public Void visitImport(ImportTree node, Void unused) {
10641062
token("static");
10651063
builder.space();
10661064
}
1067-
visitName(node.getQualifiedIdentifier(), BreakOrNot.NO);
1065+
visitName(node.getQualifiedIdentifier());
10681066
token(";");
10691067
return null;
10701068
}
@@ -1290,9 +1288,7 @@ public Void visitMethod(MethodTree node, Void unused) {
12901288
}
12911289
}
12921290
}
1293-
builder.addAll(
1294-
visitModifiers(
1295-
node.getModifiers(), annotations, Direction.VERTICAL, Optional.<BreakTag>absent()));
1291+
builder.addAll(visitModifiers(annotations, Direction.VERTICAL, Optional.<BreakTag>absent()));
12961292

12971293
Tree baseReturnType = null;
12981294
Deque<List<AnnotationTree>> dims = null;
@@ -1473,7 +1469,7 @@ private void visitPackage(
14731469
builder.open(plusFour);
14741470
token("package");
14751471
builder.space();
1476-
visitName(packageName, BreakOrNot.NO);
1472+
visitName(packageName);
14771473
builder.close();
14781474
token(";");
14791475
}
@@ -1786,13 +1782,6 @@ public Void visitTry(TryTree node, Void unused) {
17861782
return null;
17871783
}
17881784

1789-
private void maybeToken(String token) {
1790-
if (builder.peekToken().equals(Optional.of(token))) {
1791-
token(token);
1792-
builder.breakToFill(" ");
1793-
}
1794-
}
1795-
17961785
public void visitClassDeclaration(ClassTree node) {
17971786
sync(node);
17981787
List<Op> breaks =
@@ -2042,21 +2031,19 @@ private List<Op> visitModifiers(
20422031
Direction annotationsDirection,
20432032
Optional<BreakTag> declarationAnnotationBreak) {
20442033
return visitModifiers(
2045-
modifiersTree,
20462034
modifiersTree.getAnnotations(),
20472035
annotationsDirection,
20482036
declarationAnnotationBreak);
20492037
}
20502038

20512039
private List<Op> visitModifiers(
2052-
ModifiersTree modifiersTree,
20532040
List<? extends AnnotationTree> annotationTrees,
20542041
Direction annotationsDirection,
20552042
Optional<BreakTag> declarationAnnotationBreak) {
20562043
if (annotationTrees.isEmpty() && !nextIsModifier()) {
20572044
return EMPTY_LIST;
20582045
}
2059-
Deque<AnnotationTree> annotations = new ArrayDeque<AnnotationTree>(annotationTrees);
2046+
Deque<AnnotationTree> annotations = new ArrayDeque<>(annotationTrees);
20602047
builder.open(ZERO);
20612048
boolean first = true;
20622049
boolean lastWasAnnotation = false;
@@ -2282,7 +2269,7 @@ public Void visitIdentifier(IdentifierTree node, Void unused) {
22822269
}
22832270

22842271
/** Helper method for import declarations, names, and qualified names. */
2285-
private void visitName(Tree node, BreakOrNot breaks) {
2272+
private void visitName(Tree node) {
22862273
Deque<Name> stack = new ArrayDeque<>();
22872274
for (; node instanceof MemberSelectTree; node = ((MemberSelectTree) node).getExpression()) {
22882275
stack.addFirst(((MemberSelectTree) node).getIdentifier());
@@ -2471,7 +2458,7 @@ void visitDot(ExpressionTree node0) {
24712458
if (prefixIndex > 0) {
24722459
visitDotWithPrefix(items, needDot, prefixIndex);
24732460
} else {
2474-
visitRegularDot(node0, items, needDot);
2461+
visitRegularDot(items, needDot);
24752462
}
24762463

24772464
if (node != null) {
@@ -2482,12 +2469,10 @@ void visitDot(ExpressionTree node0) {
24822469
/**
24832470
* Output a "regular" chain of dereferences, possibly in builder-style. Break before every dot.
24842471
*
2485-
* @param enclosingExpression the parent expression of the dot chain
24862472
* @param items in the chain
24872473
* @param needDot whether a leading dot is needed
24882474
*/
2489-
private void visitRegularDot(
2490-
ExpressionTree enclosingExpression, List<ExpressionTree> items, boolean needDot) {
2475+
private void visitRegularDot(List<ExpressionTree> items, boolean needDot) {
24912476
boolean trailingDereferences = items.size() > 1;
24922477
boolean needDot0 = needDot;
24932478
if (!needDot0) {
@@ -2505,8 +2490,7 @@ private void visitRegularDot(
25052490
token(".");
25062491
length++;
25072492
}
2508-
if (!fillFirstArgument(
2509-
enclosingExpression, e, items, trailingDereferences ? ZERO : minusFour)) {
2493+
if (!fillFirstArgument(e, items, trailingDereferences ? ZERO : minusFour)) {
25102494
BreakTag tyargTag = genSym();
25112495
dotExpressionUpToArgs(e, Optional.of(tyargTag));
25122496
Indent tyargIndent = Indent.If.make(tyargTag, plusFour, ZERO);
@@ -2529,7 +2513,6 @@ private void visitRegularDot(
25292513
// .thenReturn(result);
25302514
//
25312515
private boolean fillFirstArgument(
2532-
ExpressionTree enclosingExpression,
25332516
ExpressionTree e,
25342517
List<ExpressionTree> items,
25352518
Indent indent) {

0 commit comments

Comments
 (0)