From e35f60eaf3eae8661e1e3251a573a194cf861ada Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Mon, 11 Nov 2024 12:56:43 -0800 Subject: [PATCH] Reformat the formatter To avoid spurious diffs during other development. PiperOrigin-RevId: 695452895 --- .../java/com/google/googlejavaformat/Newlines.java | 2 +- .../java/com/google/googlejavaformat/OpsBuilder.java | 10 +++++----- .../googlejavaformat/java/JavaCommentsHelper.java | 1 - .../com/google/googlejavaformat/java/JavaOutput.java | 2 +- .../googlejavaformat/java/filer/FormattingFiler.java | 4 +++- .../googlejavaformat/java/javadoc/JavadocWriter.java | 1 + .../googlejavaformat/java/CommandLineFlagsTest.java | 4 +--- .../googlejavaformat/java/JavadocFormattingTest.java | 4 ++-- .../googlejavaformat/java/GoogleJavaFormatter.java | 4 +++- .../intellij/GoogleJavaFormatConfigurable.java | 4 +++- 10 files changed, 20 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/com/google/googlejavaformat/Newlines.java b/core/src/main/java/com/google/googlejavaformat/Newlines.java index dbb82d3c5..86335981b 100644 --- a/core/src/main/java/com/google/googlejavaformat/Newlines.java +++ b/core/src/main/java/com/google/googlejavaformat/Newlines.java @@ -135,7 +135,7 @@ private void advance() { if (idx + 1 < input.length() && input.charAt(idx + 1) == '\n') { idx++; } - // falls through + // falls through case '\n': idx++; curr = idx; diff --git a/core/src/main/java/com/google/googlejavaformat/OpsBuilder.java b/core/src/main/java/com/google/googlejavaformat/OpsBuilder.java index a45e83b9e..7f0fabb34 100644 --- a/core/src/main/java/com/google/googlejavaformat/OpsBuilder.java +++ b/core/src/main/java/com/google/googlejavaformat/OpsBuilder.java @@ -38,7 +38,7 @@ */ public final class OpsBuilder { - /** @return the actual size of the AST node at position, including comments. */ + /** Returns the actual size of the AST node at position, including comments. */ public int actualSize(int position, int length) { Token startToken = input.getPositionTokenMap().get(position); int start = startToken.getTok().getPosition(); @@ -57,7 +57,7 @@ public int actualSize(int position, int length) { return end - start; } - /** @return the start column of the token at {@code position}, including leading comments. */ + /** Returns the start column of the token at {@code position}, including leading comments. */ public Integer actualStartColumn(int position) { Token startToken = input.getPositionTokenMap().get(position); int start = startToken.getTok().getPosition(); @@ -316,7 +316,7 @@ public final void guessToken(String token) { token, Doc.Token.RealOrImaginary.IMAGINARY, ZERO, - /* breakAndIndentTrailingComment= */ Optional.empty()); + /* breakAndIndentTrailingComment= */ Optional.empty()); } public final void token( @@ -359,7 +359,7 @@ public final void op(String op) { op.substring(i, i + 1), Doc.Token.RealOrImaginary.REAL, ZERO, - /* breakAndIndentTrailingComment= */ Optional.empty()); + /* breakAndIndentTrailingComment= */ Optional.empty()); } } @@ -427,7 +427,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, /* optionalTag= */ Optional.empty()); + breakOp(fillMode, flat, plusIndent, /* optionalTag= */ Optional.empty()); } /** diff --git a/core/src/main/java/com/google/googlejavaformat/java/JavaCommentsHelper.java b/core/src/main/java/com/google/googlejavaformat/java/JavaCommentsHelper.java index d54b2317e..9526b892c 100644 --- a/core/src/main/java/com/google/googlejavaformat/java/JavaCommentsHelper.java +++ b/core/src/main/java/com/google/googlejavaformat/java/JavaCommentsHelper.java @@ -185,4 +185,3 @@ private static boolean javadocShaped(List lines) { return true; } } - diff --git a/core/src/main/java/com/google/googlejavaformat/java/JavaOutput.java b/core/src/main/java/com/google/googlejavaformat/java/JavaOutput.java index 656b65c83..ea3731131 100644 --- a/core/src/main/java/com/google/googlejavaformat/java/JavaOutput.java +++ b/core/src/main/java/com/google/googlejavaformat/java/JavaOutput.java @@ -140,7 +140,7 @@ public void append(String text, Range range) { if (i + 1 < text.length() && text.charAt(i + 1) == '\n') { i++; } - // falls through + // falls through case '\n': spacesPending = new StringBuilder(); ++newlinesPending; diff --git a/core/src/main/java/com/google/googlejavaformat/java/filer/FormattingFiler.java b/core/src/main/java/com/google/googlejavaformat/java/filer/FormattingFiler.java index ebdc8dfec..2f2e33cbe 100644 --- a/core/src/main/java/com/google/googlejavaformat/java/filer/FormattingFiler.java +++ b/core/src/main/java/com/google/googlejavaformat/java/filer/FormattingFiler.java @@ -37,7 +37,9 @@ public final class FormattingFiler implements Filer { private final Formatter formatter = new Formatter(); private final Messager messager; - /** @param delegate filer to decorate */ + /** + * @param delegate filer to decorate + */ public FormattingFiler(Filer delegate) { this(delegate, null); } diff --git a/core/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocWriter.java b/core/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocWriter.java index 8a4100e45..5e6af1795 100644 --- a/core/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocWriter.java +++ b/core/src/main/java/com/google/googlejavaformat/java/javadoc/JavadocWriter.java @@ -40,6 +40,7 @@ final class JavadocWriter { private final int blockIndent; private final StringBuilder output = new StringBuilder(); + /** * Whether we are inside an {@code
  • } element, excluding the case in which the {@code
  • } * contains a {@code
      } or {@code
        } that we are also inside -- unless of course we're diff --git a/core/src/test/java/com/google/googlejavaformat/java/CommandLineFlagsTest.java b/core/src/test/java/com/google/googlejavaformat/java/CommandLineFlagsTest.java index e5fbc9f5f..928ce0078 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/CommandLineFlagsTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/CommandLineFlagsTest.java @@ -21,9 +21,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -/** - * Tests for command-line flags. - */ +/** Tests for command-line flags. */ @RunWith(JUnit4.class) public class CommandLineFlagsTest { diff --git a/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java b/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java index aab8ec5d4..39d43c2f9 100644 --- a/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java +++ b/core/src/test/java/com/google/googlejavaformat/java/JavadocFormattingTest.java @@ -1084,7 +1084,7 @@ public void paragraphTag() { @Test public void xhtmlParagraphTag() { String[] input = { - "class Test {", + "class Test {", // " /**", " * hello

        world", " */", @@ -1093,7 +1093,7 @@ public void xhtmlParagraphTag() { "}", }; String[] expected = { - "class Test {", + "class Test {", // " /**", " * hello", " *", diff --git a/eclipse_plugin/src/com/google/googlejavaformat/java/GoogleJavaFormatter.java b/eclipse_plugin/src/com/google/googlejavaformat/java/GoogleJavaFormatter.java index c300514be..68ff908c5 100644 --- a/eclipse_plugin/src/com/google/googlejavaformat/java/GoogleJavaFormatter.java +++ b/eclipse_plugin/src/com/google/googlejavaformat/java/GoogleJavaFormatter.java @@ -106,7 +106,9 @@ private List> rangesFromRegions(IRegion[] regions) { return ranges; } - /** @return {@code true} if input and output texts are equal, else {@code false}. */ + /** + * @return {@code true} if input and output texts are equal, else {@code false}. + */ private boolean idempotent(String source, IRegion[] regions, List replacements) { // This implementation only checks for single replacement. if (replacements.size() == 1) { diff --git a/idea_plugin/src/main/java/com/google/googlejavaformat/intellij/GoogleJavaFormatConfigurable.java b/idea_plugin/src/main/java/com/google/googlejavaformat/intellij/GoogleJavaFormatConfigurable.java index 759decc0f..3a98c2eb9 100644 --- a/idea_plugin/src/main/java/com/google/googlejavaformat/intellij/GoogleJavaFormatConfigurable.java +++ b/idea_plugin/src/main/java/com/google/googlejavaformat/intellij/GoogleJavaFormatConfigurable.java @@ -199,7 +199,9 @@ private void createUIComponents() { false)); } - /** @noinspection ALL */ + /** + * @noinspection ALL + */ public JComponent $$$getRootComponent$$$() { return panel; }