Skip to content

Commit 2ec27b5

Browse files
jbduncancushon
authored andcommitted
Remove redundant type arguments
and add parameter commands in places where the parameters aren't very self-documenting. Fixes #130 MOE_MIGRATED_REVID=172167200
1 parent 598f248 commit 2ec27b5

File tree

7 files changed

+95
-77
lines changed

7 files changed

+95
-77
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,11 @@ public State computeBreaks(CommentsHelper commentsHelper, int maxWidth, State st
271271
private static void splitByBreaks(List<Doc> docs, List<List<Doc>> splits, List<Break> breaks) {
272272
splits.clear();
273273
breaks.clear();
274-
splits.add(new ArrayList<Doc>());
274+
splits.add(new ArrayList<>());
275275
for (Doc doc : docs) {
276276
if (doc instanceof Break) {
277277
breaks.add((Break) doc);
278-
splits.add(new ArrayList<Doc>());
278+
splits.add(new ArrayList<>());
279279
} else {
280280
getLast(splits).add(doc);
281281
}
@@ -288,7 +288,7 @@ private State computeBroken(CommentsHelper commentsHelper, int maxWidth, State s
288288

289289
state =
290290
computeBreakAndSplit(
291-
commentsHelper, maxWidth, state, Optional.<Break>absent(), splits.get(0));
291+
commentsHelper, maxWidth, state, /* optBreakDoc= */ Optional.absent(), splits.get(0));
292292

293293
// Handle following breaks and split.
294294
for (int i = 0; i < breaks.size(); i++) {
@@ -571,19 +571,19 @@ private Break(FillMode fillMode, String flat, Indent plusIndent, Optional<BreakT
571571
* Make a {@code Break}.
572572
*
573573
* @param fillMode the {@link FillMode}
574-
* @param flat the the text when not broken
574+
* @param flat the text when not broken
575575
* @param plusIndent extra indent if taken
576576
* @return the new {@code Break}
577577
*/
578578
public static Break make(FillMode fillMode, String flat, Indent plusIndent) {
579-
return new Break(fillMode, flat, plusIndent, Optional.<BreakTag>absent());
579+
return new Break(fillMode, flat, plusIndent, /* optTag= */ Optional.absent());
580580
}
581581

582582
/**
583583
* Make a {@code Break}.
584584
*
585585
* @param fillMode the {@link FillMode}
586-
* @param flat the the text when not broken
586+
* @param flat the text when not broken
587587
* @param plusIndent extra indent if taken
588588
* @param optTag an optional tag for remembering whether the break was taken
589589
* @return the new {@code Break}

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ public abstract static class BlankLineWanted {
8181
* Explicitly preserve blank lines from the input (e.g. before the first member in a class
8282
* declaration). Overrides conditional blank lines.
8383
*/
84-
public static final BlankLineWanted PRESERVE = new SimpleBlankLine(Optional.<Boolean>absent());
84+
public static final BlankLineWanted PRESERVE =
85+
new SimpleBlankLine(/* wanted= */ Optional.absent());
8586

8687
/** Is the blank line wanted? */
8788
public abstract Optional<Boolean> wanted();
@@ -239,7 +240,10 @@ public final void drain() {
239240
Input.Token token = tokens.get(tokenI++);
240241
add(
241242
Doc.Token.make(
242-
token, Doc.Token.RealOrImaginary.IMAGINARY, ZERO, Optional.<Indent>absent()));
243+
token,
244+
Doc.Token.RealOrImaginary.IMAGINARY,
245+
ZERO,
246+
/* breakAndIndentTrailingComment= */ Optional.absent()));
243247
}
244248
}
245249
this.inputPosition = inputPosition;
@@ -265,7 +269,7 @@ public final Optional<String> peekToken() {
265269
ImmutableList<? extends Input.Token> tokens = input.getTokens();
266270
return tokenI < tokens.size()
267271
? Optional.of(tokens.get(tokenI).getTok().getOriginalText())
268-
: Optional.<String>absent();
272+
: Optional.absent();
269273
}
270274

271275
/**
@@ -275,7 +279,11 @@ public final Optional<String> peekToken() {
275279
* @param token the optional token
276280
*/
277281
public final void guessToken(String token) {
278-
token(token, Doc.Token.RealOrImaginary.IMAGINARY, ZERO, Optional.<Indent>absent());
282+
token(
283+
token,
284+
Doc.Token.RealOrImaginary.IMAGINARY,
285+
ZERO,
286+
/* breakAndIndentTrailingComment= */ Optional.absent());
279287
}
280288

281289
public final void token(
@@ -314,7 +322,10 @@ public final void op(String op) {
314322
int opN = op.length();
315323
for (int i = 0; i < opN; i++) {
316324
token(
317-
op.substring(i, i + 1), Doc.Token.RealOrImaginary.REAL, ZERO, Optional.<Indent>absent());
325+
op.substring(i, i + 1),
326+
Doc.Token.RealOrImaginary.REAL,
327+
ZERO,
328+
/* breakAndIndentTrailingComment= */ Optional.absent());
318329
}
319330
}
320331

@@ -382,7 +393,7 @@ public final void breakToFill(String flat) {
382393
* @param plusIndent extra indent if taken
383394
*/
384395
public final void breakOp(Doc.FillMode fillMode, String flat, Indent plusIndent) {
385-
breakOp(fillMode, flat, plusIndent, Optional.<BreakTag>absent());
396+
breakOp(fillMode, flat, plusIndent, /* optionalTag= */ Optional.absent());
386397
}
387398

388399
/**
@@ -596,8 +607,8 @@ private static boolean isForcedBreak(Op op) {
596607

597608
private static List<Op> makeComment(Input.Tok comment) {
598609
return comment.isSlashStarComment()
599-
? ImmutableList.<Op>of(Doc.Tok.make(comment))
600-
: ImmutableList.<Op>of(Doc.Tok.make(comment), Doc.Break.makeForced());
610+
? ImmutableList.of(Doc.Tok.make(comment))
611+
: ImmutableList.of(Doc.Tok.make(comment), Doc.Break.makeForced());
601612
}
602613

603614
@Override

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private static Tree extractDims(Deque<List<AnnotationTree>> dims, Tree node) {
115115
return node;
116116
}
117117
node = extractDims(dims, annotatedTypeTree.getUnderlyingType());
118-
dims.addFirst(ImmutableList.<AnnotationTree>copyOf(annotatedTypeTree.getAnnotations()));
118+
dims.addFirst(ImmutableList.copyOf(annotatedTypeTree.getAnnotations()));
119119
return node;
120120
default:
121121
return node;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import com.google.googlejavaformat.Newlines;
3232
import com.google.googlejavaformat.Op;
3333
import com.google.googlejavaformat.OpsBuilder;
34-
import java.io.File;
3534
import java.io.IOError;
3635
import java.io.IOException;
3736
import java.net.URI;
@@ -122,7 +121,7 @@ static void format(
122121
JCCompilationUnit unit;
123122
JavacFileManager fileManager = new JavacFileManager(context, true, UTF_8);
124123
try {
125-
fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, ImmutableList.<File>of());
124+
fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, ImmutableList.of());
126125
} catch (IOException e) {
127126
// impossible
128127
throw new IOError(e);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
package com.google.googlejavaformat.java;
1616

1717
public class GoogleJavaFormatVersion {
18-
public static final String VERSION = "1.5-SNAPSHOT";
18+
public static final String VERSION = "1.0";
1919
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ public ImmutableMap<Integer, Integer> getPositionToColumnMap() {
328328

329329
/** Lex the input and build the list of toks. */
330330
private ImmutableList<Tok> buildToks(String text) throws FormatterException {
331-
ImmutableList<Tok> toks = buildToks(text, ImmutableSet.<TokenKind>of());
331+
ImmutableList<Tok> toks = buildToks(text, ImmutableSet.of());
332332
kN = getLast(toks).getIndex();
333333
computeRanges(toks);
334334
return toks;

0 commit comments

Comments
 (0)