Skip to content
Merged
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
28 changes: 22 additions & 6 deletions core/src/main/java/com/google/googlejavaformat/Doc.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public enum RealOrImaginary {
REAL,
IMAGINARY;

boolean isReal() {
public boolean isReal() {
return this == REAL;
}
}
Expand Down Expand Up @@ -395,12 +395,12 @@ private Token(
*
* @return the extra indent
*/
Indent getPlusIndentCommentsBefore() {
public Indent getPlusIndentCommentsBefore() {
return plusIndentCommentsBefore;
}

/** Force a line break and indent trailing javadoc or block comments. */
Optional<Indent> breakAndIndentTrailingComment() {
public Optional<Indent> breakAndIndentTrailingComment() {
return breakAndIndentTrailingComment;
}

Expand All @@ -427,7 +427,7 @@ static Op make(
*
* @return the {@link Input.Token}
*/
Input.Token getToken() {
public Input.Token getToken() {
return token;
}

Expand All @@ -436,7 +436,7 @@ Input.Token getToken() {
*
* @return whether the @code Token} is good
*/
RealOrImaginary realOrImaginary() {
public RealOrImaginary realOrImaginary() {
return realOrImaginary;
}

Expand Down Expand Up @@ -483,7 +483,7 @@ public String toString() {
}

/** A Leaf node in a {@link Doc} for a non-breaking space. */
static final class Space extends Doc implements Op {
public static final class Space extends Doc implements Op {
private static final Space SPACE = new Space();

private Space() {}
Expand Down Expand Up @@ -600,6 +600,22 @@ boolean isForced() {
return fillMode == FillMode.FORCED;
}

public FillMode fillMode() {
return fillMode;
}

public String flat() {
return flat;
}

public Indent plusIndent() {
return plusIndent;
}

public Optional<BreakTag> optTag() {
return optTag;
}

@Override
public void add(DocBuilder builder) {
builder.breakDoc(this);
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/com/google/googlejavaformat/Indent.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public abstract class Indent {

abstract int eval();
public abstract int eval();

/** A constant function, returning a constant indent. */
public static final class Const extends Indent {
Expand All @@ -41,7 +41,7 @@ public static Const make(int n, int indentMultiplier) {
}

@Override
int eval() {
public int eval() {
return n;
}

Expand All @@ -68,7 +68,7 @@ public static If make(BreakTag condition, Indent thenIndent, Indent elseIndent)
}

@Override
int eval() {
public int eval() {
return (condition.wasBreakTaken() ? thenIndent : elseIndent).eval();
}

Expand Down
15 changes: 15 additions & 0 deletions core/src/main/java/com/google/googlejavaformat/Newlines.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ public static int firstBreak(String input) {
return it.hasNext() ? it.next() : -1;
}

/**
* Returns the offset of the start of the last line in the input, or {@code 0} if the input
* contains no line breaks. Unlike iterating over {@link #lineOffsetIterator}, this only scans the
* last line.
*/
public static int lastLineStart(String input) {
for (int i = input.length() - 1; i >= 0; i--) {
char c = input.charAt(i);
if (c == '\n' || c == '\r') {
return i + 1;
}
}
return 0;
}

private static final ImmutableSet<String> BREAKS = ImmutableSet.of("\r\n", "\n", "\r");

/** Returns true if the entire input string is a recognized line break. */
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/com/google/googlejavaformat/OpenOp.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public void add(DocBuilder builder) {
builder.open(plusIndent);
}

public Indent plusIndent() {
return plusIndent;
}

@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("plusIndent", plusIndent).toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
import com.google.errorprone.annotations.Immutable;
import com.google.googlejavaformat.CommentsHelper;
import com.google.googlejavaformat.Doc;
import com.google.googlejavaformat.DocBuilder;
import com.google.googlejavaformat.FormattingError;
import com.google.googlejavaformat.Newlines;
import com.google.googlejavaformat.Op;
import com.google.googlejavaformat.OpsBuilder;
import com.google.googlejavaformat.layout.LayoutBuilder;
import com.google.googlejavaformat.layout.LayoutSolver;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.util.Context;
import java.io.IOException;
Expand Down Expand Up @@ -113,22 +113,21 @@ static void format(final JavaInput javaInput, JavaOutput javaOutput, JavaFormatt
if (!errorDiagnostics.isEmpty()) {
throw FormatterException.fromJavacDiagnostics(errorDiagnostics);
}
OpsBuilder builder = new OpsBuilder(javaInput, javaOutput);
LayoutBuilder builder = new LayoutBuilder(javaInput, javaOutput);
ImmutableSet.Builder<Integer> markdownJavadocPositions = ImmutableSet.builder();
// Output the compilation unit.
JavaInputAstVisitor visitor =
new JavaInputAstVisitor(builder, options.indentationMultiplier(), markdownJavadocPositions);
visitor.scan(unit, null);
builder.sync(javaInput.getText().length());
builder.drain();
Doc doc = new DocBuilder().withOps(builder.build()).build();
var doc = builder.build();
CommentsHelper commentsHelper =
new JavaCommentsHelper(
Newlines.guessLineSeparator(javaInput.getText()),
options,
markdownJavadocPositions.build());
doc.computeBreaks(commentsHelper, options.maxLineLength(), new Doc.State(+0, 0));
doc.write(javaOutput);
LayoutSolver.format(doc, options.maxLineLength(), javaOutput, commentsHelper);
javaOutput.flush();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@
import com.google.googlejavaformat.Newlines;
import com.google.googlejavaformat.Op;
import com.google.googlejavaformat.OpenOp;
import com.google.googlejavaformat.OpsBuilder;
import com.google.googlejavaformat.OpsBuilder.BlankLineWanted;
import com.google.googlejavaformat.Output.BreakTag;
import com.google.googlejavaformat.java.DimensionHelpers.SortedDims;
import com.google.googlejavaformat.java.DimensionHelpers.TypeWithDims;
import com.google.googlejavaformat.layout.LayoutBuilder;
import com.sun.source.tree.AnnotatedTypeTree;
import com.sun.source.tree.AnnotationTree;
import com.sun.source.tree.ArrayAccessTree;
Expand Down Expand Up @@ -272,7 +272,7 @@
return result.build();
}

private final OpsBuilder builder;
private final LayoutBuilder builder;
private final ImmutableSet.Builder<Integer> markdownJavadocPositions;

private static final Indent.Const ZERO = Indent.Const.ZERO;
Expand Down Expand Up @@ -308,10 +308,10 @@
/**
* The {@code Visitor} constructor.
*
* @param builder the {@link OpsBuilder}
* @param builder the {@link LayoutBuilder}
*/
JavaInputAstVisitor(
OpsBuilder builder,
LayoutBuilder builder,
int indentMultiplier,
ImmutableSet.Builder<Integer> markdownJavadocPositions) {
this.builder = builder;
Expand Down Expand Up @@ -529,7 +529,7 @@
if (afterFirstToken) {
builder.forcedBreak();
}
builder.open(row.iterator().next().getKind() == NEW_ARRAY || cols == 1 ? ZERO : plusFour);

Check warning on line 532 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 532 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 532 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 532 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 532 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 532 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 532 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 532 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 532 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 532 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 532 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 532 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 532 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / Publish snapshot

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs
boolean firstInRow = true;
for (ExpressionTree item : row) {
if (!firstInRow) {
Expand Down Expand Up @@ -769,7 +769,7 @@
CollapseEmptyOrNot.YES,
AllowLeadingBlankLine.YES,
AllowTrailingBlankLine.YES);
if (node.getStatement().getKind() == BLOCK) {

Check warning on line 772 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 772 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 772 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 772 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 772 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 772 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 772 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 772 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 772 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 772 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 772 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 772 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 772 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / Publish snapshot

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs
builder.space();
} else {
builder.breakOp(" ");
Expand Down Expand Up @@ -1085,11 +1085,11 @@
builder.open(plusFour);
builder.open(
node.getInitializer().size() > 1
&& node.getInitializer().get(0).getKind() == Tree.Kind.EXPRESSION_STATEMENT

Check warning on line 1088 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1088 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1088 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1088 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1088 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1088 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1088 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1088 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1088 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1088 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1088 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1088 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1088 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / Publish snapshot

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs
? plusFour
: ZERO);
if (!node.getInitializer().isEmpty()) {
if (node.getInitializer().get(0).getKind() == VARIABLE) {

Check warning on line 1092 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1092 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1092 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1092 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1092 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1092 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1092 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1092 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1092 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1092 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1092 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1092 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1092 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / Publish snapshot

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs
PeekingIterator<StatementTree> it =
Iterators.peekingIterator(node.getInitializer().iterator());
visitVariables(
Expand Down Expand Up @@ -1153,7 +1153,7 @@
while (true) {
expressions.add(node.getCondition());
statements.add(node.getThenStatement());
if (node.getElseStatement() != null && node.getElseStatement().getKind() == IF) {

Check warning on line 1156 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1156 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1156 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1156 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1156 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1156 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1156 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1156 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1156 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1156 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1156 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1156 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs

Check warning on line 1156 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / Publish snapshot

[PreferInstanceofOverGetKind] Prefer instanceof over getKind() checks where possible, as these work well with pattern matching instanceofs
node = (IfTree) node.getElseStatement();
} else {
break;
Expand Down Expand Up @@ -2998,7 +2998,7 @@
builder.close();
}

/** Collapse chains of {@code .} operators, across multiple {@link ASTNode} types. */

Check warning on line 3001 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[NotJavadoc] This element has multiple Javadoc comments; only the last one will be used.

Check warning on line 3001 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[NotJavadoc] This element has multiple Javadoc comments; only the last one will be used.

Check warning on line 3001 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[NotJavadoc] This element has multiple Javadoc comments; only the last one will be used.

Check warning on line 3001 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[NotJavadoc] This element has multiple Javadoc comments; only the last one will be used.

Check warning on line 3001 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[NotJavadoc] This element has multiple Javadoc comments; only the last one will be used.

Check warning on line 3001 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[NotJavadoc] This element has multiple Javadoc comments; only the last one will be used.

Check warning on line 3001 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[NotJavadoc] This element has multiple Javadoc comments; only the last one will be used.

Check warning on line 3001 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on ubuntu-latest

[NotJavadoc] This element has multiple Javadoc comments; only the last one will be used.

Check warning on line 3001 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[NotJavadoc] This element has multiple Javadoc comments; only the last one will be used.

Check warning on line 3001 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 21 on ubuntu-latest

[NotJavadoc] This element has multiple Javadoc comments; only the last one will be used.

Check warning on line 3001 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[NotJavadoc] This element has multiple Javadoc comments; only the last one will be used.

Check warning on line 3001 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / JDK 25 on macos-latest

[NotJavadoc] This element has multiple Javadoc comments; only the last one will be used.

Check warning on line 3001 in core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

View workflow job for this annotation

GitHub Actions / Publish snapshot

[NotJavadoc] This element has multiple Javadoc comments; only the last one will be used.

/**
* Output a "." node.
Expand Down
Loading
Loading