Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions core/src/main/java/com/google/googlejavaformat/Doc.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ public State computeBreaks(CommentsHelper commentsHelper, int maxWidth, State st
private static void splitByBreaks(List<Doc> docs, List<List<Doc>> splits, List<Break> breaks) {
splits.clear();
breaks.clear();
splits.add(new ArrayList<Doc>());
splits.add(new ArrayList<>());
for (Doc doc : docs) {
if (doc instanceof Break) {
breaks.add((Break) doc);
splits.add(new ArrayList<Doc>());
splits.add(new ArrayList<>());
} else {
getLast(splits).add(doc);
}
Expand All @@ -287,8 +287,7 @@ private State computeBroken(CommentsHelper commentsHelper, int maxWidth, State s
splitByBreaks(docs, splits, breaks);

state =
computeBreakAndSplit(
commentsHelper, maxWidth, state, Optional.<Break>absent(), splits.get(0));
computeBreakAndSplit(commentsHelper, maxWidth, state, Optional.absent(), splits.get(0));

// Handle following breaks and split.
for (int i = 0; i < breaks.size(); i++) {
Expand Down Expand Up @@ -576,7 +575,7 @@ private Break(FillMode fillMode, String flat, Indent plusIndent, Optional<BreakT
* @return the new {@code Break}
*/
public static Break make(FillMode fillMode, String flat, Indent plusIndent) {
return new Break(fillMode, flat, plusIndent, Optional.<BreakTag>absent());
return new Break(fillMode, flat, plusIndent, Optional.absent());
}

/**
Expand Down
19 changes: 8 additions & 11 deletions core/src/main/java/com/google/googlejavaformat/OpsBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public abstract static class BlankLineWanted {
* Explicitly preserve blank lines from the input (e.g. before the first member in a class
* declaration). Overrides conditional blank lines.
*/
public static final BlankLineWanted PRESERVE = new SimpleBlankLine(Optional.<Boolean>absent());
public static final BlankLineWanted PRESERVE = new SimpleBlankLine(Optional.absent());

/** Is the blank line wanted? */
public abstract Optional<Boolean> wanted();
Expand Down Expand Up @@ -238,9 +238,7 @@ public final void drain() {
int tokensN = tokens.size();
while (tokenI < tokensN && inputPosition > tokens.get(tokenI).getTok().getPosition()) {
Input.Token token = tokens.get(tokenI++);
add(
Doc.Token.make(
token, Doc.Token.RealOrImaginary.IMAGINARY, ZERO, Optional.<Indent>absent()));
add(Doc.Token.make(token, Doc.Token.RealOrImaginary.IMAGINARY, ZERO, Optional.absent()));
}
}
this.inputPosition = inputPosition;
Expand All @@ -266,7 +264,7 @@ public final Optional<String> peekToken() {
ImmutableList<? extends Input.Token> tokens = input.getTokens();
return tokenI < tokens.size()
? Optional.of(tokens.get(tokenI).getTok().getOriginalText())
: Optional.<String>absent();
: Optional.absent();
}

/**
Expand All @@ -276,7 +274,7 @@ public final Optional<String> peekToken() {
* @param token the optional token
*/
public final void guessToken(String token) {
token(token, Doc.Token.RealOrImaginary.IMAGINARY, ZERO, Optional.<Indent>absent());
token(token, Doc.Token.RealOrImaginary.IMAGINARY, ZERO, Optional.absent());
}

public final void token(
Expand Down Expand Up @@ -314,8 +312,7 @@ public final void token(
public final void op(String op) {
int opN = op.length();
for (int i = 0; i < opN; i++) {
token(
op.substring(i, i + 1), Doc.Token.RealOrImaginary.REAL, ZERO, Optional.<Indent>absent());
token(op.substring(i, i + 1), Doc.Token.RealOrImaginary.REAL, ZERO, Optional.absent());
}
}

Expand Down Expand Up @@ -383,7 +380,7 @@ public final void breakToFill(String flat) {
* @param plusIndent extra indent if taken
*/
public final void breakOp(Doc.FillMode fillMode, String flat, Indent plusIndent) {
breakOp(fillMode, flat, plusIndent, Optional.<BreakTag>absent());
breakOp(fillMode, flat, plusIndent, Optional.absent());
}

/**
Expand Down Expand Up @@ -586,8 +583,8 @@ private static boolean isForcedBreak(Op op) {

private static List<Op> makeComment(Input.Tok comment) {
return comment.isSlashStarComment()
? ImmutableList.<Op>of(Doc.Tok.make(comment))
: ImmutableList.<Op>of(Doc.Tok.make(comment), Doc.Break.makeForced());
? ImmutableList.of(Doc.Tok.make(comment))
: ImmutableList.of(Doc.Tok.make(comment), Doc.Break.makeForced());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private static Tree extractDims(Deque<List<AnnotationTree>> dims, Tree node) {
return node;
}
node = extractDims(dims, annotatedTypeTree.getUnderlyingType());
dims.addFirst(ImmutableList.<AnnotationTree>copyOf(annotatedTypeTree.getAnnotations()));
dims.addFirst(ImmutableList.copyOf(annotatedTypeTree.getAnnotations()));
return node;
default:
return node;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.google.googlejavaformat.Newlines;
import com.google.googlejavaformat.Op;
import com.google.googlejavaformat.OpsBuilder;
import java.io.File;
import java.io.IOError;
import java.io.IOException;
import java.net.URI;
Expand Down Expand Up @@ -138,7 +137,7 @@ static void format(
JCCompilationUnit unit;
JavacFileManager fileManager = new JavacFileManager(context, true, UTF_8);
try {
fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, ImmutableList.<File>of());
fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, ImmutableList.of());
} catch (IOException e) {
// impossible
throw new IOError(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public ImmutableMap<Integer, Integer> getPositionToColumnMap() {

/** Lex the input and build the list of toks. */
private ImmutableList<Tok> buildToks(String text) throws FormatterException {
ImmutableList<Tok> toks = buildToks(text, ImmutableSet.<TokenKind>of());
ImmutableList<Tok> toks = buildToks(text, ImmutableSet.of());
kN = getLast(toks).getIndex();
computeRanges(toks);
return toks;
Expand Down
Loading