├── core └── src │ ├── test │ └── resources │ │ └── com │ │ └── google │ │ └── googlejavaformat │ │ └── java │ │ ├── testdata │ │ ├── M2.output │ │ ├── M2.input │ │ ├── B20524742.input │ │ ├── B23626035.input │ │ ├── B21327412.input │ │ ├── B28786284.input │ │ ├── B28786284.output │ │ ├── B20524742.output │ │ ├── B21327412.output │ │ ├── B23626035.output │ │ ├── B22424362.output │ │ ├── B32729600.input │ │ ├── B32729600.output │ │ ├── Fields.output │ │ ├── UnaryMinus.input │ │ ├── UnaryMinus.output │ │ ├── B19950468.input │ │ ├── B19950468.output │ │ ├── B21585653.output │ │ ├── EnumAnnotation.input │ │ ├── Fields.input │ │ ├── i101.input │ │ ├── i101.output │ │ ├── i95.input │ │ ├── i95.output │ │ ├── B25811323.input │ │ ├── B21585653.input │ │ ├── B25749989.input │ │ ├── B28774859.output │ │ ├── B35797074.input │ │ ├── B22424362.input │ │ ├── B25811323.output │ │ ├── B28774859.input │ │ ├── B28788559.input │ │ ├── B35797074.output │ │ ├── EnumAnnotation.output │ │ ├── B21185365.input │ │ ├── B21185365.output │ │ ├── B24494875.input │ │ ├── B24494875.output │ │ ├── B28788559.output │ │ ├── ForMany.input │ │ ├── ForMany.output │ │ ├── B38352414.input │ │ ├── i155.input │ │ ├── i155.output │ │ ├── B25749989.output │ │ ├── B30789352.input │ │ ├── B30789352.output │ │ ├── B38203081.input │ │ ├── B38352414.output │ │ ├── I13.output │ │ ├── B36194204.input │ │ ├── B36194204.output │ │ ├── B38203081.output │ │ ├── WildBound.input │ │ ├── B26159561.input │ │ ├── B32284705.input │ │ ├── B32284705.output │ │ ├── WildBound.output │ │ ├── I202.input │ │ ├── I202.output │ │ ├── M3.input │ │ ├── M3.output │ │ ├── CL240367479.input │ │ ├── B26159561.output │ │ ├── CL240367479.output │ │ ├── I13.input │ │ ├── B27246427.input │ │ ├── B29705613.input │ │ ├── i176.input │ │ ├── MarkerAnnotation.input │ │ ├── MarkerAnnotation.output │ │ ├── i65.input │ │ ├── i65.output │ │ ├── B22469536.input │ │ ├── B22469536.output │ │ ├── B29705613.output │ │ ├── SingleMemberAnnotation.input │ │ ├── SingleMemberAnnotation.output │ │ ├── i176.output │ │ ├── i98.output │ │ ├── B21105569.input │ │ ├── I12.output │ │ ├── B32397217.input │ │ ├── LocalAnnotations.input │ │ ├── i66.output │ │ ├── i100.input │ │ ├── i281.input │ │ ├── i66.input │ │ ├── i98.input │ │ ├── B20128921.input │ │ ├── B27246427.output │ │ ├── i100.output │ │ ├── B20128921.output │ │ ├── B32397217.output │ │ ├── java11.input │ │ ├── java11.output │ │ ├── B21031147.input │ │ ├── B21105569.output │ │ ├── B23514513.input │ │ ├── I365.output │ │ ├── LocalAnnotations.output │ │ ├── B38241237.input │ │ ├── B23514513.output │ │ ├── i221.input │ │ ├── i221.output │ │ ├── B21647014.input │ │ ├── i71.output │ │ ├── B19950219.input │ │ ├── B20128174.input │ │ ├── B29618429.input │ │ ├── B38241237.output │ │ ├── B21031147.output │ │ ├── I12.input │ │ ├── i60.output │ │ ├── B19950219.output │ │ ├── B29618429.output │ │ ├── B30764810.input │ │ ├── B19996259.input │ │ ├── B22913048.input │ │ ├── B24862959.output │ │ ├── B72507902.input │ │ ├── I365.input │ │ ├── i60.input │ │ ├── B154342628.input │ │ ├── B154342628.output │ │ ├── B22610221.output │ │ ├── B22913048.output │ │ ├── B32114928.output │ │ ├── B126411718.output │ │ ├── B27602933.input │ │ ├── Unformatted3.input │ │ ├── B24862959.input │ │ ├── B26275739.output │ │ ├── B27602933.output │ │ ├── B72507902.output │ │ ├── Unformatted3.output │ │ ├── B30764810.output │ │ ├── I374.input │ │ ├── B21647014.output │ │ ├── B22488373.output │ │ ├── B20577626.output │ │ ├── Pair.input │ │ ├── Pair.output │ │ ├── i59.input │ │ ├── B32114928.input │ │ ├── I374.output │ │ ├── B19996259.output │ │ ├── B21329312.input │ │ ├── B22848286.input │ │ ├── L.input │ │ ├── i55.output │ │ ├── i59.output │ │ ├── L.output │ │ ├── i281.output │ │ ├── i55.input │ │ ├── B124394008.input │ │ ├── B126411718.input │ │ ├── B20577626.input │ │ ├── B21329312.output │ │ ├── i282.input │ │ ├── W.input │ │ ├── B22610221.input │ │ ├── B26928842.input │ │ ├── W.output │ │ ├── V.input │ │ ├── V.output │ │ ├── B22848286.output │ │ ├── B26928842.output │ │ ├── B20915776.input │ │ ├── B20915776.output │ │ ├── B24988078.input │ │ ├── B26275739.input │ │ ├── i282.output │ │ ├── B22169269.output │ │ ├── i71.input │ │ ├── B124394008.output │ │ ├── B24988078.output │ │ ├── B21465477.input │ │ ├── B22169269.input │ │ ├── B21465477.output │ │ ├── B22488373.input │ │ ├── B30153869.input │ │ ├── R.input │ │ ├── R.output │ │ ├── B20128174.output │ │ ├── B30153869.output │ │ ├── Q.input │ │ ├── B112853497.output │ │ ├── Q.output │ │ ├── B.output │ │ ├── B37895033.output │ │ ├── TabularMixedSignInitializer.input │ │ ├── TabularMixedSignInitializer.output │ │ ├── B142553964.input │ │ ├── B142553964.output │ │ ├── B112853497.input │ │ ├── B.input │ │ ├── B23708487.input │ │ ├── B19950815.input │ │ ├── B37895033.input │ │ ├── B20578077.output │ │ ├── B33358723.input │ │ ├── B20578077.input │ │ ├── B20531711.input │ │ ├── B23708487.output │ │ ├── B27078833.output │ │ ├── B27078833.input │ │ ├── B21465217.input │ │ ├── B19950815.output │ │ ├── Multivariables.output │ │ ├── B20531711.output │ │ ├── B21465217.output │ │ ├── Multivariables.input │ │ ├── B21331232.output │ │ ├── B33358723.output │ │ ├── B21331232.input │ │ ├── B20567842.input │ │ ├── B20580212.input │ │ ├── B21278211.output │ │ ├── B64493529.input │ │ ├── B64493529.output │ │ ├── B65214682.input │ │ ├── B65214682.output │ │ ├── B22873322.input │ │ ├── T.input │ │ ├── T.output │ │ ├── B20580212.output │ │ ├── N.input │ │ ├── B20567842.output │ │ ├── B20529113.input │ │ ├── B23349153.input │ │ ├── SuperQualifier.input │ │ ├── P.input │ │ ├── SuperQualifier.output │ │ ├── Unformatted2.input │ │ ├── Unformatted2.output │ │ ├── B23349153.output │ │ ├── B21278211.input │ │ ├── B37629610.output │ │ ├── B37629610.input │ │ ├── B20529113.output │ │ ├── B26694550.output │ │ ├── B35644813.output │ │ ├── B21192435.input │ │ ├── B26694550.input │ │ ├── B35644813.input │ │ ├── NormalAnnotation.input │ │ ├── NormalAnnotation.output │ │ ├── TryWithResources.input │ │ ├── TryWithResources.output │ │ ├── B18479811.input │ │ ├── B22873322.output │ │ ├── M1.input │ │ ├── B21192435.output │ │ ├── B22166687.input │ │ ├── P.output │ │ ├── B28066276.input │ │ ├── B22166687.output │ │ ├── B20569245.output │ │ ├── N.output │ │ ├── D.input │ │ ├── D.output │ │ ├── B20569245.input │ │ ├── B20844369.input │ │ ├── B30223986.output │ │ ├── B29368546.output │ │ ├── M1.output │ │ ├── B29368546.input │ │ ├── B30223986.input │ │ ├── B20844369.output │ │ ├── java14.output │ │ ├── java14.input │ │ ├── B26952926.input │ │ ├── B24202287.output │ │ ├── B25787055.output │ │ ├── B28066276.output │ │ ├── B25372815.input │ │ ├── B25372815.output │ │ ├── B26293162.input │ │ ├── B18479811.output │ │ ├── B26952926.output │ │ ├── B24202287.input │ │ ├── B26293162.output │ │ ├── B25787055.input │ │ ├── S.input │ │ ├── S.output │ │ ├── B24702438.input │ │ ├── I1.input │ │ ├── I1.output │ │ ├── B24702438.output │ │ ├── B23804934.input │ │ ├── B22815364.input │ │ ├── B21305044.input │ │ ├── U.input │ │ ├── B23804934.output │ │ ├── U.output │ │ ├── B21954779.input │ │ ├── B23749160.output │ │ ├── B26884608.output │ │ ├── B24543625.output │ │ ├── B21954779.output │ │ ├── B26884608.input │ │ ├── B23749160.input │ │ ├── B22815364.output │ │ ├── I.input │ │ └── I.output │ │ ├── testjavadoc │ │ ├── B31404367.input │ │ └── B31404367.output │ │ └── testimports │ │ ├── A.imports-only │ │ ├── A.imports-and-formatting │ │ ├── A.formatting-only │ │ ├── A.input │ │ ├── A.formatting-and-unused-import-removal │ │ └── A.formatting-and-import-sorting │ └── main │ └── java │ └── com │ └── google │ └── googlejavaformat │ ├── java │ ├── GoogleJavaFormatVersion.java.template │ └── javadoc │ │ └── NestingCounter.java │ ├── CommentsHelper.java │ ├── Op.java │ ├── FormattingError.java │ ├── CloseOp.java │ └── OpenOp.java ├── .gitignore ├── util ├── settings.xml └── publish-snapshot-on-commit.sh ├── eclipse_plugin ├── build.properties ├── plugin.xml ├── META-INF │ └── MANIFEST.MF └── README.md ├── scripts └── mvn-deploy.sh ├── appveyor.yml ├── idea_plugin ├── google-java-format.iml ├── build.gradle └── src │ └── com │ └── google │ └── googlejavaformat │ └── intellij │ └── UiFormatterStyle.java └── CONTRIBUTING.md /core/src/test/resources/com/google/googlejavaformat/java/testdata/M2.output: -------------------------------------------------------------------------------- 1 | open module com.google.m {} 2 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/M2.input: -------------------------------------------------------------------------------- 1 | open module com.google.m { 2 | } 3 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20524742.input: -------------------------------------------------------------------------------- 1 | class Test {{ 2 | int x; 3 | }} 4 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B23626035.input: -------------------------------------------------------------------------------- 1 | class Test2 { void f(Test2... xs) {} } 2 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21327412.input: -------------------------------------------------------------------------------- 1 | class B21327412 { 2 | int i = Data._ID; 3 | } 4 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B28786284.input: -------------------------------------------------------------------------------- 1 | enum E { 2 | ONE, 3 | TWO; 4 | ; 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B28786284.output: -------------------------------------------------------------------------------- 1 | enum E { 2 | ONE, 3 | TWO; 4 | ; 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20524742.output: -------------------------------------------------------------------------------- 1 | class Test { 2 | { 3 | int x; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21327412.output: -------------------------------------------------------------------------------- 1 | class B21327412 { 2 | int i = Data._ID; 3 | } 4 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B23626035.output: -------------------------------------------------------------------------------- 1 | class Test2 { 2 | void f(Test2... xs) {} 3 | } 4 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22424362.output: -------------------------------------------------------------------------------- 1 | class Test { 2 | { 3 | int x = 1 + 2; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B32729600.input: -------------------------------------------------------------------------------- 1 | class B32729600 { 2 | { 3 | f(() -> {}); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B32729600.output: -------------------------------------------------------------------------------- 1 | class B32729600 { 2 | { 3 | f(() -> {}); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/Fields.output: -------------------------------------------------------------------------------- 1 | class Fields { 2 | 3 | int x = 1; 4 | 5 | int y = 1; 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/UnaryMinus.input: -------------------------------------------------------------------------------- 1 | class UnaryMinus { 2 | { 3 | int b = - 1; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/UnaryMinus.output: -------------------------------------------------------------------------------- 1 | class UnaryMinus { 2 | { 3 | int b = -1; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B19950468.input: -------------------------------------------------------------------------------- 1 | class B19950468 { 2 | int code() {} 3 | 4 | // comment 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B19950468.output: -------------------------------------------------------------------------------- 1 | class B19950468 { 2 | int code() {} 3 | 4 | // comment 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21585653.output: -------------------------------------------------------------------------------- 1 | class B21585653 { 2 | { 3 | try (X x = x; ) {} 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/EnumAnnotation.input: -------------------------------------------------------------------------------- 1 | enum E { 2 | @A ONE, 3 | TWO, 4 | @B @C THREE; 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/Fields.input: -------------------------------------------------------------------------------- 1 | class Fields { 2 | 3 | int x = 1; 4 | 5 | int y = 1; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i101.input: -------------------------------------------------------------------------------- 1 | public @interface kHz {} // No prefix defined in the annotation itself 2 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i101.output: -------------------------------------------------------------------------------- 1 | public @interface kHz {} // No prefix defined in the annotation itself 2 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i95.input: -------------------------------------------------------------------------------- 1 | class I95 { 2 | public void format2(Object @Nullable ... a2) {} 3 | } 4 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i95.output: -------------------------------------------------------------------------------- 1 | class I95 { 2 | public void format2(Object @Nullable ... a2) {} 3 | } 4 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B25811323.input: -------------------------------------------------------------------------------- 1 | class B25811323 { 2 | void f() { 3 | class Inner {}; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21585653.input: -------------------------------------------------------------------------------- 1 | class B21585653 { 2 | { 3 | try (X x = x;) { 4 | } 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B25749989.input: -------------------------------------------------------------------------------- 1 | class Dummy { 2 | /** 3 | */private static void method(){MISSING();} 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B28774859.output: -------------------------------------------------------------------------------- 1 | class B28774859 { 2 | java.util./*comment*/ Map./*comment*/ Entry e; 3 | } 4 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B35797074.input: -------------------------------------------------------------------------------- 1 | class B35797074 { 2 | /** javadoc */ 3 | /* package */ final int x; 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22424362.input: -------------------------------------------------------------------------------- 1 | class Test { 2 | { 3 | int x = 4 | 1 5 | 6 | + 2; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B25811323.output: -------------------------------------------------------------------------------- 1 | class B25811323 { 2 | void f() { 3 | class Inner {} 4 | ; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B28774859.input: -------------------------------------------------------------------------------- 1 | class B28774859 { 2 | java.util. /*comment*/ Map. /*comment*/ Entry e; 3 | } 4 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B28788559.input: -------------------------------------------------------------------------------- 1 | import a.A;; 2 | import b.B; 3 | 4 | class Test { 5 | A a; 6 | B b; 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B35797074.output: -------------------------------------------------------------------------------- 1 | class B35797074 { 2 | /** javadoc */ 3 | /* package */ final int x; 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/EnumAnnotation.output: -------------------------------------------------------------------------------- 1 | enum E { 2 | @A 3 | ONE, 4 | TWO, 5 | @B 6 | @C 7 | THREE; 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21185365.input: -------------------------------------------------------------------------------- 1 | class B21185365 { 2 | { 3 | for (int i = 0; i < s.length();) {} 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21185365.output: -------------------------------------------------------------------------------- 1 | class B21185365 { 2 | { 3 | for (int i = 0; i < s.length(); ) {} 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B24494875.input: -------------------------------------------------------------------------------- 1 | public enum B24494875 { 2 | ; 3 | public static final String ONE = "ONE"; 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B24494875.output: -------------------------------------------------------------------------------- 1 | public enum B24494875 { 2 | ; 3 | public static final String ONE = "ONE"; 4 | } 5 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B28788559.output: -------------------------------------------------------------------------------- 1 | import a.A; 2 | ; 3 | import b.B; 4 | 5 | class Test { 6 | A a; 7 | B b; 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/ForMany.input: -------------------------------------------------------------------------------- 1 | class ForMany { 2 | { 3 | A a; 4 | for (b = B; c != C; d = D) {} 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/ForMany.output: -------------------------------------------------------------------------------- 1 | class ForMany { 2 | { 3 | A a; 4 | for (b = B; c != C; d = D) {} 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B38352414.input: -------------------------------------------------------------------------------- 1 | @Redacted(Redacted.REDACTED + "/redacted", redacted = Redacted.class) 2 | class B38352414 {} 3 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i155.input: -------------------------------------------------------------------------------- 1 | class I155 { 2 | void walkAndClose(Stream stream) { 3 | try (stream) {} 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i155.output: -------------------------------------------------------------------------------- 1 | class I155 { 2 | void walkAndClose(Stream stream) { 3 | try (stream) {} 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testjavadoc/B31404367.input: -------------------------------------------------------------------------------- 1 | /** 2 | * Foo. 3 | * 4 | * 7 | */ 8 | class Foo {} 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testjavadoc/B31404367.output: -------------------------------------------------------------------------------- 1 | /** 2 | * Foo. 3 | * 4 | * 7 | */ 8 | class Foo {} 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B25749989.output: -------------------------------------------------------------------------------- 1 | class Dummy { 2 | /** */ 3 | private static void method() { 4 | MISSING(); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B30789352.input: -------------------------------------------------------------------------------- 1 | /** 2 | * Body. 3 | * 4 | * @param

the protobuf type 5 | */ 6 | class B30789352

{} 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B30789352.output: -------------------------------------------------------------------------------- 1 | /** 2 | * Body. 3 | * 4 | * @param

the protobuf type 5 | */ 6 | class B30789352

{} 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B38203081.input: -------------------------------------------------------------------------------- 1 | class B38203081 { 2 | void f(int @A []... xs) {} 3 | 4 | void g(int @A [] @B... xs) {} 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B38352414.output: -------------------------------------------------------------------------------- 1 | @Redacted(Redacted.REDACTED + "/redacted", redacted = Redacted.class) 2 | class B38352414 {} 3 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/I13.output: -------------------------------------------------------------------------------- 1 | class I13 { 2 | 3 | @Nullable public int f; 4 | 5 | @Override 6 | public void m() {} 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B36194204.input: -------------------------------------------------------------------------------- 1 | class B36194204 { 2 | { 3 | Function f = (String... s) -> s[0]; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B36194204.output: -------------------------------------------------------------------------------- 1 | class B36194204 { 2 | { 3 | Function f = (String... s) -> s[0]; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B38203081.output: -------------------------------------------------------------------------------- 1 | class B38203081 { 2 | void f(int @A []... xs) {} 3 | 4 | void g(int @A [] @B ... xs) {} 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/WildBound.input: -------------------------------------------------------------------------------- 1 | class WildBound { 2 | T f() { 3 | return (T) X.class.newInstance((F) f, t); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B26159561.input: -------------------------------------------------------------------------------- 1 | class B26159561 { 2 | { 3 | try (A a = a(); B b = b()) {} 4 | try (A a = a();) {} 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B32284705.input: -------------------------------------------------------------------------------- 1 | /** 2 | * Foo 3 | *

4 |  * bar
5 |  * 
6 | * 7 | */ 8 | class B32284705 {} 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B32284705.output: -------------------------------------------------------------------------------- 1 | /** 2 | * Foo 3 | *
4 |  * bar
5 |  * 
6 | *
7 | */ 8 | class B32284705 {} 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/WildBound.output: -------------------------------------------------------------------------------- 1 | class WildBound { 2 | T f() { 3 | return (T) X.class.newInstance((F) f, t); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/I202.input: -------------------------------------------------------------------------------- 1 | class I202 { 2 | { 3 | //noinspection CheckResult 4 | methodWhoseResultShouldBeChecked(); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/I202.output: -------------------------------------------------------------------------------- 1 | class I202 { 2 | { 3 | //noinspection CheckResult 4 | methodWhoseResultShouldBeChecked(); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/M3.input: -------------------------------------------------------------------------------- 1 | @Deprecated 2 | module moduletags { 3 | requires transitive static moduleA; 4 | 5 | exports testpkgmdltags; 6 | } -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/M3.output: -------------------------------------------------------------------------------- 1 | @Deprecated 2 | module moduletags { 3 | requires transitive static moduleA; 4 | 5 | exports testpkgmdltags; 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/CL240367479.input: -------------------------------------------------------------------------------- 1 | package foo;; 2 | 3 | import com.google.second.Foo; 4 | import com.google.first.Bar; 5 | 6 | public class Blim {} 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.ims 3 | *.iml 4 | 5 | .classpath 6 | .project 7 | .factorypath 8 | .settings/ 9 | .apt_generated/ 10 | 11 | target/ 12 | 13 | bin/ 14 | out/ 15 | eclipse_plugin/lib/ 16 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B26159561.output: -------------------------------------------------------------------------------- 1 | class B26159561 { 2 | { 3 | try (A a = a(); 4 | B b = b()) {} 5 | try (A a = a(); ) {} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/CL240367479.output: -------------------------------------------------------------------------------- 1 | package foo; 2 | ; 3 | import com.google.second.Foo; 4 | import com.google.first.Bar; 5 | 6 | public class Blim {} 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/I13.input: -------------------------------------------------------------------------------- 1 | class I13 { 2 | 3 | @Nullable 4 | 5 | public int f; 6 | 7 | @Override 8 | 9 | public void m() {} 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B27246427.input: -------------------------------------------------------------------------------- 1 | enum TrailingComment { 2 | /** foo */ FOO, /** bar */ 3 | BAR; 4 | 5 | /** a */ Object a; /** b */ 6 | Object b; 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B29705613.input: -------------------------------------------------------------------------------- 1 | class B29705613 { 2 | /** 3 | * This tag isn't closed: {@link Foo 4 | * 5 | *

A paragraph 6 | */ 7 | int x; 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i176.input: -------------------------------------------------------------------------------- 1 | interface 2 | InterfaceWithPrivateStaticMethod 3 | { 4 | private static void bar() { } 5 | default void foo() { bar(); } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/MarkerAnnotation.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** JavaDoc comment. */ 4 | public @interface MarkerAnnotation {} 5 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/MarkerAnnotation.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** JavaDoc comment. */ 4 | public @interface MarkerAnnotation {} 5 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i65.input: -------------------------------------------------------------------------------- 1 | import org.checkerframework.checker.nullness.qual.*; 2 | 3 | class UnannoPrimitives { 4 | Object ar = new @Nullable byte[] {4}; 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i65.output: -------------------------------------------------------------------------------- 1 | import org.checkerframework.checker.nullness.qual.*; 2 | 3 | class UnannoPrimitives { 4 | Object ar = new @Nullable byte[] {4}; 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22469536.input: -------------------------------------------------------------------------------- 1 | public class Test { 2 | public static void foo() { 3 | long x = -9223372036854775808L; 4 | int y = -2147483648; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22469536.output: -------------------------------------------------------------------------------- 1 | public class Test { 2 | public static void foo() { 3 | long x = -9223372036854775808L; 4 | int y = -2147483648; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B29705613.output: -------------------------------------------------------------------------------- 1 | class B29705613 { 2 | /** 3 | * This tag isn't closed: {@link Foo 4 | * 5 | *

A paragraph 6 | */ 7 | int x; 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/SingleMemberAnnotation.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | public @interface SingleMemberAnnotation { 4 | int value(); 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/SingleMemberAnnotation.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | public @interface SingleMemberAnnotation { 4 | int value(); 5 | } 6 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i176.output: -------------------------------------------------------------------------------- 1 | interface InterfaceWithPrivateStaticMethod { 2 | private static void bar() {} 3 | 4 | default void foo() { 5 | bar(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i98.output: -------------------------------------------------------------------------------- 1 | public class AnonInnerDefaults { 2 | 3 | public void tryStuff(final UIElement e) { 4 | PolyIface p = new @UI PolyIface() {}; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21105569.input: -------------------------------------------------------------------------------- 1 | class B21105569 { 2 | void f() { 3 | // asd 4 | } 5 | void g() { 6 | /* asd */ 7 | } 8 | void h() { /* asd */ } 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/I12.output: -------------------------------------------------------------------------------- 1 | public class Test {} 2 | 3 | public class Test {} 4 | 5 | public class Test {} 6 | 7 | public class Test {} 8 | 9 | public class Test {} 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B32397217.input: -------------------------------------------------------------------------------- 1 | class T { 2 | { 3 | f( 4 | 1 /* 1 */, 2 /* 2 */); 5 | } 6 | } -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/LocalAnnotations.input: -------------------------------------------------------------------------------- 1 | class LocalAnnotations { 2 | { 3 | @Foo final Object x; 4 | @Foo(1) final Object y; 5 | @Foo(x=1) final Object y; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i66.output: -------------------------------------------------------------------------------- 1 | public class AnnotatedCast { 2 | 3 | public static @Sibling1 int convertSibling2ToSibling1(@Sibling2 int a) { 4 | return (@Sibling1 int) 1; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i100.input: -------------------------------------------------------------------------------- 1 | public class I100 { 2 | void f() { 3 | Object o; 4 | o = new String @A [] {"foo", "bar"}; 5 | o = new String @A @B [] @C [] {"foo", "bar"}; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i281.input: -------------------------------------------------------------------------------- 1 | public enum Empty {} 2 | public enum Empty {;} 3 | public enum Empty {;;;} 4 | public enum Empty {; // comment 5 | ;;} 6 | public enum Empty {; 7 | ;; // comment 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i66.input: -------------------------------------------------------------------------------- 1 | public class AnnotatedCast { 2 | 3 | public static @Sibling1 int convertSibling2ToSibling1(@Sibling2 int a) { 4 | return (@Sibling1 int) 1; 5 | } 6 | 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i98.input: -------------------------------------------------------------------------------- 1 | public class AnonInnerDefaults { 2 | 3 | public void tryStuff(final UIElement e) { 4 | PolyIface p = 5 | new @UI PolyIface() { 6 | }; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20128921.input: -------------------------------------------------------------------------------- 1 | public class B20128921 { 2 | 3 | void m(Iterable ax) { 4 | 5 | for (T a : ax) { 6 | 7 | System.err.println(x); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B27246427.output: -------------------------------------------------------------------------------- 1 | enum TrailingComment { 2 | /** foo */ 3 | FOO, 4 | /** bar */ 5 | BAR; 6 | 7 | /** a */ 8 | Object a; 9 | /** b */ 10 | Object b; 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i100.output: -------------------------------------------------------------------------------- 1 | public class I100 { 2 | void f() { 3 | Object o; 4 | o = new String @A [] {"foo", "bar"}; 5 | o = new String @A @B [] @C [] {"foo", "bar"}; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20128921.output: -------------------------------------------------------------------------------- 1 | public class B20128921 { 2 | 3 | void m(Iterable ax) { 4 | 5 | for (T a : ax) { 6 | 7 | System.err.println(x); 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B32397217.output: -------------------------------------------------------------------------------- 1 | class T { 2 | { 3 | f( 4 | 1 /* 1 */, 5 | 2 /* 2 */); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/java11.input: -------------------------------------------------------------------------------- 1 | class Java11 { 2 | interface I { 3 | private default void f() {} 4 | } 5 | 6 | public static void main(String[] args) { 7 | var x = 42; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/java11.output: -------------------------------------------------------------------------------- 1 | class Java11 { 2 | interface I { 3 | private default void f() {} 4 | } 5 | 6 | public static void main(String[] args) { 7 | var x = 42; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21031147.input: -------------------------------------------------------------------------------- 1 | public class B21031147 { 2 | { 3 | return new StringBuilder(maxLength) 4 | .append(seq, 0, truncationLength).append(truncationIndicator).toString(); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21105569.output: -------------------------------------------------------------------------------- 1 | class B21105569 { 2 | void f() { 3 | // asd 4 | } 5 | 6 | void g() { 7 | /* asd */ 8 | } 9 | 10 | void h() { 11 | /* asd */ 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B23514513.input: -------------------------------------------------------------------------------- 1 | class Test { 2 | { 3 | f( 4 | rrr.kkkkk.uuuuuuuu, rrr.iiiiii.ggggggggggggggggg, 5 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/I365.output: -------------------------------------------------------------------------------- 1 | class I365 { 2 | { 3 | return foo____________.bar__________().baz____________().parallelStream() 4 | .map(Baz::getId) 5 | .collect(toList()); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/LocalAnnotations.output: -------------------------------------------------------------------------------- 1 | class LocalAnnotations { 2 | { 3 | @Foo final Object x; 4 | @Foo(1) 5 | final Object y; 6 | @Foo(x = 1) 7 | final Object y; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B38241237.input: -------------------------------------------------------------------------------- 1 | class B38241237 { 2 | //foo 3 | //bar 4 | //one long incredibly unbroken sentence moving from topic to topic so that no-one had a chance to interrupt 5 | ///baz 6 | //// 7 | } -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B23514513.output: -------------------------------------------------------------------------------- 1 | class Test { 2 | { 3 | f( 4 | rrr.kkkkk.uuuuuuuu, 5 | rrr.iiiiii.ggggggggggggggggg, 6 | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i221.input: -------------------------------------------------------------------------------- 1 | class I221 { 2 | { 3 | logger.log( 4 | Level.WARNING, 5 | "Unable to obtain jst.web facet version from selected project", //$NON-NLS-1$ 6 | ex); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i221.output: -------------------------------------------------------------------------------- 1 | class I221 { 2 | { 3 | logger.log( 4 | Level.WARNING, 5 | "Unable to obtain jst.web facet version from selected project", //$NON-NLS-1$ 6 | ex); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21647014.input: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | import java.util.List;; 4 | 5 | ; 6 | class Test { 7 | ; 8 | public int x = 42;; 9 | ;;; 10 | { 11 | int x = 1;;; 12 | } 13 | ; 14 | } 15 | ; 16 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i71.output: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | 3 | class Test { 4 | Wrapper w = new Wrapper(Arrays.asList("a", "b", "c", "d", "e"), 2); 5 | Wrapper w = new Wrapper(Arrays.asList("a", "b", "c", "d", "e")); 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B19950219.input: -------------------------------------------------------------------------------- 1 | class B19950219 { 2 | @Override 3 | String normalizeWord(String word) { 4 | return Ascii.toLowerCase(word); 5 | } 6 | @Override 7 | String convert(CaseFormat format, String s) { 8 | }} 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20128174.input: -------------------------------------------------------------------------------- 1 | class B20128174 { 2 | 3 | enum Suit { DIAMONDS, HEARTS, CLUBS, SPADES }; 4 | 5 | enum Suit { DIAMONDS, HEARTS, CLUBS, SPADES; }; 6 | 7 | enum Suit { DIAMONDS, HEARTS, CLUBS, SPADES,; }; 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B29618429.input: -------------------------------------------------------------------------------- 1 | class B29618429 { 2 | /** 3 | * Hello 4 | * 5 | *

World 6 | *

 7 |    * @LooksLikeATag(
 8 |    *   foo = "bar"
 9 |    * )
10 |    * 
11 | */ 12 | int x; 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B38241237.output: -------------------------------------------------------------------------------- 1 | class B38241237 { 2 | // foo 3 | // bar 4 | // one long incredibly unbroken sentence moving from topic to topic so that no-one had a chance to 5 | // interrupt 6 | /// baz 7 | //// 8 | } 9 | -------------------------------------------------------------------------------- /util/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | sonatype-nexus-snapshots 5 | ${env.CI_DEPLOY_USERNAME} 6 | ${env.CI_DEPLOY_PASSWORD} 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21031147.output: -------------------------------------------------------------------------------- 1 | public class B21031147 { 2 | { 3 | return new StringBuilder(maxLength) 4 | .append(seq, 0, truncationLength) 5 | .append(truncationIndicator) 6 | .toString(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/I12.input: -------------------------------------------------------------------------------- 1 | public class Test { 2 | 3 | 4 | 5 | } 6 | 7 | public class Test { 8 | 9 | 10 | } 11 | 12 | public class Test { 13 | 14 | } 15 | 16 | public class Test { 17 | } 18 | 19 | public class Test {} 20 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i60.output: -------------------------------------------------------------------------------- 1 | import org.checkerframework.checker.nullness.qual.*; 2 | 3 | public class FullyQualified { 4 | 5 | public void format1(java.lang.String a1, java.lang.@Nullable Object... a2) { 6 | // body 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B19950219.output: -------------------------------------------------------------------------------- 1 | class B19950219 { 2 | @Override 3 | String normalizeWord(String word) { 4 | return Ascii.toLowerCase(word); 5 | } 6 | 7 | @Override 8 | String convert(CaseFormat format, String s) {} 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B29618429.output: -------------------------------------------------------------------------------- 1 | class B29618429 { 2 | /** 3 | * Hello 4 | * 5 | *

World 6 | * 7 | *

 8 |    * @LooksLikeATag(
 9 |    *   foo = "bar"
10 |    * )
11 |    * 
12 | */ 13 | int x; 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B30764810.input: -------------------------------------------------------------------------------- 1 | class B30764810 { 2 | @Foo( 3 | x = {0}, 4 | y = 0 5 | // comment 6 | ) 7 | int a; 8 | 9 | @Foo( 10 | x = {0}, 11 | y = 0 12 | /* comment 13 | */ 14 | ) 15 | int b; 16 | } -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B19996259.input: -------------------------------------------------------------------------------- 1 | class B19996259 { 2 | void g( // line comment 3 | int x) {} 4 | 5 | void // 6 | g // 7 | ( // 8 | int // 9 | x // 10 | , // 11 | int // 12 | y // 13 | ) // 14 | { // 15 | } // 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22913048.input: -------------------------------------------------------------------------------- 1 | private class Yellow extends Red.Orange { 2 | Yellow(Red red) { 3 | red.super(); 4 | } 5 | 6 | Class getClassB() { 7 | return new TypeToken(getClass()) {}.getRawType(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B24862959.output: -------------------------------------------------------------------------------- 1 | public enum XxxxxxxXxxx implements XxxxxxXxxxxxxXxxx { 2 | XXXXXXXXX_XXXX_XXX_XXXXXXXX( 3 | " ", Xxxxxx.XXXXXXX, XxxxXxxxxxxXxxxxxxx.XXXXX), 4 | // 5 | // 6 | // 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B72507902.input: -------------------------------------------------------------------------------- 1 | class B72507902 { 2 | private static class Xxxxxxxxxxxxxxxxxxxx 3 | extends Xxxxxxxxxxx< 4 | Pair>, Xxxxxxxxxxxxxxxxxxxx, 5 | List> {} 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/I365.input: -------------------------------------------------------------------------------- 1 | class I365 { 2 | { 3 | return foo____________ 4 | .bar__________() 5 | .baz____________() 6 | .parallelStream() 7 | .map(Baz::getId) 8 | .collect(toList()); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i60.input: -------------------------------------------------------------------------------- 1 | import org.checkerframework.checker.nullness.qual.*; 2 | 3 | public class FullyQualified { 4 | 5 | public void format1(java.lang.String a1, java.lang. @Nullable Object... a2) { 6 | // body 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B154342628.input: -------------------------------------------------------------------------------- 1 | class B154342628 { 2 | void f() { 3 | var var = 42; 4 | return writtenVariables.stream() 5 | .filter(var -> deletedVariableIds.contains(var.getId())) 6 | .collect(toImmutableList()); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B154342628.output: -------------------------------------------------------------------------------- 1 | class B154342628 { 2 | void f() { 3 | var var = 42; 4 | return writtenVariables.stream() 5 | .filter(var -> deletedVariableIds.contains(var.getId())) 6 | .collect(toImmutableList()); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22610221.output: -------------------------------------------------------------------------------- 1 | class B22610221 { 2 | { 3 | for (Map.Entry, Object> entry : 4 | FOO.bar().bazs().thing(someThing).entrySet()) { 5 | output.put(entry.getKey(), entry.getValue()); 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22913048.output: -------------------------------------------------------------------------------- 1 | private class Yellow extends Red.Orange { 2 | Yellow(Red red) { 3 | red.super(); 4 | } 5 | 6 | Class getClassB() { 7 | return new TypeToken(getClass()) {}.getRawType(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B32114928.output: -------------------------------------------------------------------------------- 1 | class B32114928 { 2 | { 3 | Class tClass = 4 | (Class) 5 | verifyNotNull((ParameterizedType) getClass().getGenericSuperclass()) 6 | .getActualTypeArguments()[0]; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /eclipse_plugin/build.properties: -------------------------------------------------------------------------------- 1 | source.. = src/ 2 | output.. = target/classes 3 | bin.includes = META-INF/,\ 4 | .,\ 5 | plugin.xml,\ 6 | lib/javac-shaded-9+181-r4173-1.jar,\ 7 | lib/guava-22.0.jar,\ 8 | lib/google-java-format-1.6.jar 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B126411718.output: -------------------------------------------------------------------------------- 1 | class B126411718 { 2 | { 3 | logger.atDebug().log( 4 | "Scratch Session Cleaner exiting. Number of deleted sessions: %d, names: %s", 5 | deletedPersistentNames.size(), deletedPersistentNames); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B27602933.input: -------------------------------------------------------------------------------- 1 | class B27602933 { 2 | { 3 | try { 4 | } catch (final A | B x) { 5 | } 6 | 7 | try { 8 | } catch (@SuppressWarnings("unused") IllegalArgumentException | RuntimeException e) { 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/Unformatted3.input: -------------------------------------------------------------------------------- 1 | package com . google . googlejavaformat ; 2 | 3 | class Unformatted3 { 4 | /** 5 | * This comment is not reflowed 6 | * because it contains
preformatted
7 | * content. 8 | */ 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B24862959.input: -------------------------------------------------------------------------------- 1 | public enum XxxxxxxXxxx implements XxxxxxXxxxxxxXxxx { 2 | XXXXXXXXX_XXXX_XXX_XXXXXXXX( 3 | " ", Xxxxxx.XXXXXXX, XxxxXxxxxxxXxxxxxxx.XXXXX), 4 | // 5 | // 6 | // 7 | } 8 | 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B26275739.output: -------------------------------------------------------------------------------- 1 | public class B26275739 { 2 | { 3 | f(/* x */ 1, /* xx */ 2, /* x */ 3, /* xx */ 4); 4 | f( 5 | 1, 2, 6 | 3, 4); 7 | f( 8 | /* asd */ 9 | 1, 2, 10 | 3, 4); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B27602933.output: -------------------------------------------------------------------------------- 1 | class B27602933 { 2 | { 3 | try { 4 | } catch (final A | B x) { 5 | } 6 | 7 | try { 8 | } catch (@SuppressWarnings("unused") IllegalArgumentException | RuntimeException e) { 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B72507902.output: -------------------------------------------------------------------------------- 1 | class B72507902 { 2 | private static class Xxxxxxxxxxxxxxxxxxxx 3 | extends Xxxxxxxxxxx< 4 | Pair>, 5 | Xxxxxxxxxxxxxxxxxxxx, 6 | List> {} 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/Unformatted3.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat; 2 | 3 | class Unformatted3 { 4 | /** 5 | * This comment is not reflowed because it contains 6 | * 7 | *
preformatted
8 | * 9 | * content. 10 | */ 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B30764810.output: -------------------------------------------------------------------------------- 1 | class B30764810 { 2 | @Foo( 3 | x = {0}, 4 | y = 0 5 | // comment 6 | ) 7 | int a; 8 | 9 | @Foo( 10 | x = {0}, 11 | y = 0 12 | /* comment 13 | */ 14 | ) 15 | int b; 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/I374.input: -------------------------------------------------------------------------------- 1 | import java.lang.annotation.ElementType; 2 | import java.lang.annotation.Target; 3 | 4 | @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) 5 | @interface MyTypeAnno {} 6 | 7 | public class GjfFailure { 8 | void m(int a @MyTypeAnno []) {} 9 | } -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21647014.output: -------------------------------------------------------------------------------- 1 | package test; 2 | 3 | import java.util.List; 4 | ; 5 | ; 6 | 7 | class Test { 8 | ; 9 | public int x = 42; 10 | ; 11 | ; 12 | ; 13 | ; 14 | 15 | { 16 | int x = 1; 17 | ; 18 | ; 19 | } 20 | ; 21 | } 22 | ; 23 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22488373.output: -------------------------------------------------------------------------------- 1 | class B22488373 { 2 | { 3 | if (enumBindingKeys.contains(bindingKey) 4 | && (bindingKey.key().type().getKind().equals(DECLARED) 5 | && !((DeclaredType) bindingKey.key().type()).getTypeArguments().isEmpty())) {} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20577626.output: -------------------------------------------------------------------------------- 1 | class B20577626 { 2 | private @Mock GsaConfigFlags mGsaConfig; 3 | 4 | @Foo @Bar private @Mock GsaConfigFlags mGsaConfig; 5 | 6 | @Foo 7 | abstract @Bar void m() {} 8 | 9 | @Foo 10 | @Baz 11 | abstract @Bar void m() {} 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/Pair.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** JavaDoc comment. */ 4 | public class Pair { 5 | public final T1 x; 6 | public final T2 y; 7 | 8 | Pair(T1 x, T2 y) { 9 | this.x = x; 10 | this.y = y; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/Pair.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** JavaDoc comment. */ 4 | public class Pair { 5 | public final T1 x; 6 | public final T2 y; 7 | 8 | Pair(T1 x, T2 y) { 9 | this.x = x; 10 | this.y = y; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i59.input: -------------------------------------------------------------------------------- 1 | import org.checkerframework.checker.tainting.qual.*; 2 | class Outer { 3 | class Nested { 4 | class InnerMost { 5 | @A Outer context(@B Outer.@C Nested.@D InnerMost this) { 6 | return Outer.this; 7 | } 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B32114928.input: -------------------------------------------------------------------------------- 1 | class B32114928 { 2 | { 3 | Class tClass = 4 | (Class) 5 | verifyNotNull((ParameterizedType) getClass().getGenericSuperclass()) 6 | .getActualTypeArguments()[ 7 | 0]; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/I374.output: -------------------------------------------------------------------------------- 1 | import java.lang.annotation.ElementType; 2 | import java.lang.annotation.Target; 3 | 4 | @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) 5 | @interface MyTypeAnno {} 6 | 7 | public class GjfFailure { 8 | void m(int a @MyTypeAnno []) {} 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B19996259.output: -------------------------------------------------------------------------------- 1 | class B19996259 { 2 | void g( // line comment 3 | int x) {} 4 | 5 | void // 6 | g // 7 | ( // 8 | int // 9 | x // 10 | , // 11 | int // 12 | y // 13 | ) // 14 | { // 15 | } // 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21329312.input: -------------------------------------------------------------------------------- 1 | public class B21329312 { 2 | boolean test() { 3 | return wasEdited || didContactsChange || medicalInfoManager.getTemporaryProfilePicture() != null 4 | || inMemoryAccessMedicalProfileAboveKeyguard != originalAccessMedicalProfileAboveKeyguard; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22848286.input: -------------------------------------------------------------------------------- 1 | class B22848286 { 2 | 3 | @FxxxSxxx(xxxx = "xxxxxx_xxxxxxx_xxxxxxxxx_xxxx", xxxx = "Xxxxx xxxx xx xxxxxx xxxxxxx xxxxxxxxx.") 4 | int x; 5 | 6 | @FxxxGxxxxxxxx(xxxx = "Xxx xxxxxx xxxxxxxxy xxx xxx xxxxxxxxx, x.x. xxx xxxxxx xxxxxxxx xxxxxxxxy") 7 | int y; 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/L.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for LabeledStatements and LambdaExpressions. */ 4 | class L { 5 | // TODO(jdd): Include high language-level tests. 6 | 7 | void f() { 8 | LABEL: 9 | for (int i = 0; i < 10; i++) {} 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i55.output: -------------------------------------------------------------------------------- 1 | import java.lang.annotation.*; 2 | 3 | @Target(ElementType.TYPE_USE) 4 | @interface Interned {} 5 | 6 | public class GjfTypeAnnotationOnArrayTest { 7 | 8 | public static void test() { 9 | String @Interned [] iarray1 = new String @Interned [2]; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i59.output: -------------------------------------------------------------------------------- 1 | import org.checkerframework.checker.tainting.qual.*; 2 | 3 | class Outer { 4 | class Nested { 5 | class InnerMost { 6 | @A 7 | Outer context(@B Outer.@C Nested.@D InnerMost this) { 8 | return Outer.this; 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/L.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for LabeledStatements and LambdaExpressions. */ 4 | class L { 5 | // TODO(jdd): Include high language-level tests. 6 | 7 | void f() { 8 | LABEL: 9 | for (int i = 0; i < 10; i++) {} 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i281.output: -------------------------------------------------------------------------------- 1 | public enum Empty {} 2 | 3 | public enum Empty { 4 | ; 5 | } 6 | 7 | public enum Empty { 8 | ; 9 | ; 10 | ; 11 | } 12 | 13 | public enum Empty { 14 | ; // comment 15 | ; 16 | ; 17 | } 18 | 19 | public enum Empty { 20 | ; 21 | ; 22 | ; // comment 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i55.input: -------------------------------------------------------------------------------- 1 | import java.lang.annotation.*; 2 | 3 | @Target(ElementType.TYPE_USE) 4 | @interface Interned {} 5 | 6 | public class GjfTypeAnnotationOnArrayTest { 7 | 8 | public static void test() { 9 | String @Interned [] iarray1 = new String @Interned [2]; 10 | } 11 | 12 | } 13 | 14 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B124394008.input: -------------------------------------------------------------------------------- 1 | class B124394008 { 2 | { 3 | LocalReviewProto.Builder newReview = 4 | readProfileResponse.flatMap(authorExtractor::extract) 5 | .map(luReviewsExtractor::toLocalReviewProto) 6 | .orElse(LocalReviewProto.getDefaultInstance()).toBuilder(); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B126411718.input: -------------------------------------------------------------------------------- 1 | class B126411718 { 2 | { 3 | logger 4 | .atDebug() 5 | .log( 6 | "Scratch Session Cleaner exiting. Number of deleted sessions: %d, names: %s", 7 | deletedPersistentNames.size(), 8 | deletedPersistentNames); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20577626.input: -------------------------------------------------------------------------------- 1 | class B20577626 { 2 | private @Mock 3 | GsaConfigFlags mGsaConfig; 4 | 5 | @Foo 6 | @Bar 7 | private @Mock 8 | GsaConfigFlags mGsaConfig; 9 | 10 | @Foo 11 | abstract @Bar 12 | void m() {} 13 | 14 | @Foo 15 | @Baz 16 | abstract @Bar 17 | void m() {} 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21329312.output: -------------------------------------------------------------------------------- 1 | public class B21329312 { 2 | boolean test() { 3 | return wasEdited 4 | || didContactsChange 5 | || medicalInfoManager.getTemporaryProfilePicture() != null 6 | || inMemoryAccessMedicalProfileAboveKeyguard != originalAccessMedicalProfileAboveKeyguard; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i282.input: -------------------------------------------------------------------------------- 1 | public class ArrayVsVarargs { 2 | 3 | void f(String[] arg) {} 4 | void g(String... arg) {} 5 | void h(String @A [] arg) {} 6 | void i(String @B... arg) {} 7 | void j(String @C [] @D [] arg) {} 8 | void k(String @E [] @F... arg) {} 9 | 10 | Class c = byte[].class; 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/W.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for WhileStatements and WildcardTypes. */ 4 | class W { 5 | T f() { 6 | while (true == true == true == true == true == true == true == true == true == true == true 7 | == true == true) {} 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22610221.input: -------------------------------------------------------------------------------- 1 | class B22610221 { 2 | { 3 | for (Map.Entry, Object> entry : 4 | FOO 5 | .bar() 6 | .bazs() 7 | .thing(someThing) 8 | .entrySet()) { 9 | output.put(entry.getKey(), entry.getValue()); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B26928842.input: -------------------------------------------------------------------------------- 1 | class B26928842 { 2 | { 3 | curr.setData(curr.getData().toBuilder() 4 | .setPushCertificate( // New 5 | curr.getData().getPushCertficate()) // Old, misspelled 6 | .clearPushCertficate() // Old, misspelled 7 | .build()); 8 | } 9 | } -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/W.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for WhileStatements and WildcardTypes. */ 4 | class W { 5 | T f() { 6 | while (true == true == true == true == true == true == true == true == true == true == true 7 | == true == true) {} 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/V.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** 4 | * Tests for VariableDeclarationExpressions, VariableDeclarationFragments, and 5 | * VariableDeclarationStatements. 6 | */ 7 | class V { 8 | int x = 0, y = 1; 9 | 10 | void f() { 11 | for (int a = 0, b = 1; a < b;) {} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/V.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** 4 | * Tests for VariableDeclarationExpressions, VariableDeclarationFragments, and 5 | * VariableDeclarationStatements. 6 | */ 7 | class V { 8 | int x = 0, y = 1; 9 | 10 | void f() { 11 | for (int a = 0, b = 1; a < b; ) {} 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22848286.output: -------------------------------------------------------------------------------- 1 | class B22848286 { 2 | 3 | @FxxxSxxx( 4 | xxxx = "xxxxxx_xxxxxxx_xxxxxxxxx_xxxx", 5 | xxxx = "Xxxxx xxxx xx xxxxxx xxxxxxx xxxxxxxxx.") 6 | int x; 7 | 8 | @FxxxGxxxxxxxx( 9 | xxxx = "Xxx xxxxxx xxxxxxxxy xxx xxx xxxxxxxxx, x.x. xxx xxxxxx xxxxxxxx xxxxxxxxy") 10 | int y; 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B26928842.output: -------------------------------------------------------------------------------- 1 | class B26928842 { 2 | { 3 | curr.setData( 4 | curr.getData().toBuilder() 5 | .setPushCertificate( // New 6 | curr.getData().getPushCertficate()) // Old, misspelled 7 | .clearPushCertficate() // Old, misspelled 8 | .build()); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20915776.input: -------------------------------------------------------------------------------- 1 | class B20915776 { 2 | @Inject 3 | void ChunkAnalysis( 4 | // TODO(user) ... 5 | @Parent DatasetSource supporters, 6 | @Child DatasetSource children, 7 | @Parent Provider parentSupportsDecider, 8 | @Child Provider childSupportsDecider) { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20915776.output: -------------------------------------------------------------------------------- 1 | class B20915776 { 2 | @Inject 3 | void ChunkAnalysis( 4 | // TODO(user) ... 5 | @Parent DatasetSource supporters, 6 | @Child DatasetSource children, 7 | @Parent Provider parentSupportsDecider, 8 | @Child Provider childSupportsDecider) {} 9 | } 10 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B24988078.input: -------------------------------------------------------------------------------- 1 | class B24988078 { 2 | public static Optional fromNullable(@Nullable T nullableReference) {} 3 | 4 | public static Optional fromNullable(@Nullable T nullableReference) {} 5 | 6 | Table< /*@Nullable*/ Object, /*@Nullable*/ Object, /*@Nullable*/ Object > foo; 7 | } 8 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B26275739.input: -------------------------------------------------------------------------------- 1 | public class B26275739 { 2 | { 3 | f( 4 | /* x */ 1, 5 | /* xx */ 2, 6 | /* x */ 3, 7 | /* xx */ 4); 8 | f( 9 | 1, 10 | 2, 11 | 3, 12 | 4); 13 | f( 14 | /* asd */ 15 | 1, 2, 16 | 3, 4); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i282.output: -------------------------------------------------------------------------------- 1 | public class ArrayVsVarargs { 2 | 3 | void f(String[] arg) {} 4 | 5 | void g(String... arg) {} 6 | 7 | void h(String @A [] arg) {} 8 | 9 | void i(String @B ... arg) {} 10 | 11 | void j(String @C [] @D [] arg) {} 12 | 13 | void k(String @E [] @F ... arg) {} 14 | 15 | Class c = byte[].class; 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22169269.output: -------------------------------------------------------------------------------- 1 | class B22169269 { 2 | { 3 | try { 4 | } catch (ClassNotFoundException 5 | | NoSuchMethodException 6 | | InvocationTargetException 7 | | IllegalAccessException e) { 8 | } 9 | try { 10 | } catch (ClassNotFoundException | NoSuchMethodException e) { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/i71.input: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | 3 | class Test { 4 | Wrapper w = new Wrapper( 5 | Arrays.asList( 6 | "a", "b", 7 | "c", "d", 8 | "e" 9 | ), 2); 10 | Wrapper w = new Wrapper( 11 | Arrays.asList( 12 | "a", "b", 13 | "c", "d", 14 | "e" 15 | )); 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B124394008.output: -------------------------------------------------------------------------------- 1 | class B124394008 { 2 | { 3 | LocalReviewProto.Builder newReview = 4 | readProfileResponse 5 | .flatMap(authorExtractor::extract) 6 | .map(luReviewsExtractor::toLocalReviewProto) 7 | .orElse(LocalReviewProto.getDefaultInstance()) 8 | .toBuilder(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B24988078.output: -------------------------------------------------------------------------------- 1 | class B24988078 { 2 | public static Optional fromNullable(@Nullable T nullableReference) {} 3 | 4 | public static Optional fromNullable( 5 | @Nullable T nullableReference) {} 6 | 7 | Table foo; 8 | } 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21465477.input: -------------------------------------------------------------------------------- 1 | class B21465477 { 2 | 3 | @Nullable private final String simpleFieldName; 4 | @Nullable private final String shortFlagName; 5 | private final String containerClassName; 6 | private final String type; 7 | private final String doc; 8 | private final DocLevel docLevel; 9 | @Nullable private final String altName; 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22169269.input: -------------------------------------------------------------------------------- 1 | class B22169269 { 2 | { 3 | try { 4 | } catch ( 5 | ClassNotFoundException 6 | | NoSuchMethodException 7 | | InvocationTargetException 8 | | IllegalAccessException e) { 9 | } 10 | try { 11 | } catch (ClassNotFoundException | NoSuchMethodException e) { 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21465477.output: -------------------------------------------------------------------------------- 1 | class B21465477 { 2 | 3 | @Nullable private final String simpleFieldName; 4 | @Nullable private final String shortFlagName; 5 | private final String containerClassName; 6 | private final String type; 7 | private final String doc; 8 | private final DocLevel docLevel; 9 | @Nullable private final String altName; 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22488373.input: -------------------------------------------------------------------------------- 1 | class B22488373 { 2 | { 3 | if (enumBindingKeys.contains(bindingKey) 4 | && (bindingKey 5 | .key() 6 | .type() 7 | .getKind() 8 | .equals(DECLARED) 9 | && !((DeclaredType) bindingKey.key().type()).getTypeArguments().isEmpty())) {} 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B30153869.input: -------------------------------------------------------------------------------- 1 | /** 2 | * one 3 | * 4 | *
    5 | *
  1. two 6 | *
7 | * 8 | *

9 | *

  • four 10 | */ 11 | class T { 12 | 13 | /** 14 | * One 15 | * 16 | *
      17 | *
    • a 18 | *
        19 | *
      • b 20 | *
      • c 21 | *
      22 | *
    • e 23 | *
    24 | */ 25 | int x; 26 | } 27 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/R.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for ReturnStatements. */ 4 | class R { 5 | void f() { 6 | return; 7 | } 8 | 9 | int f(int x) { 10 | return x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x 11 | + x + x + x + x + x + x + x + x + x; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/R.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for ReturnStatements. */ 4 | class R { 5 | void f() { 6 | return; 7 | } 8 | 9 | int f(int x) { 10 | return x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x + x 11 | + x + x + x + x + x + x + x + x + x; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20128174.output: -------------------------------------------------------------------------------- 1 | class B20128174 { 2 | 3 | enum Suit { 4 | DIAMONDS, 5 | HEARTS, 6 | CLUBS, 7 | SPADES 8 | }; 9 | 10 | enum Suit { 11 | DIAMONDS, 12 | HEARTS, 13 | CLUBS, 14 | SPADES; 15 | }; 16 | 17 | enum Suit { 18 | DIAMONDS, 19 | HEARTS, 20 | CLUBS, 21 | SPADES, 22 | ; 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B30153869.output: -------------------------------------------------------------------------------- 1 | /** 2 | * one 3 | * 4 | *
      5 | *
    1. two 6 | *
    7 | * 8 | *

    9 | *

  • four 10 | */ 11 | class T { 12 | 13 | /** 14 | * One 15 | * 16 | *
      17 | *
    • a 18 | *
        19 | *
      • b 20 | *
      • c 21 | *
      22 | *
    • e 23 | *
    24 | */ 25 | int x; 26 | } 27 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/Q.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for QualifiedNames and QualifiedTypes. */ 4 | class Q { 5 | static final int zero = 0; 6 | 7 | class T {} 8 | 9 | static void f() { 10 | Q. /* @MarkerAnnotation */T t; 11 | int zero = Q.zero; 12 | java.lang. /* @MarkerAnnotation */String s = null; 13 | Q.f(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /eclipse_plugin/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B112853497.output: -------------------------------------------------------------------------------- 1 | class B112853497 { 2 | { 3 | XxxxxxxxxxXxxx xxxXxxxx = 4 | xxxXxxxx.xxxxXxXxxxx(xxxxXxxx, XXXXXX_XXXX_XXXXXXXX_XX_XXXXXXXX).toBuilder() 5 | .xxxXxxxxXxxxXx(xxxxxXx.xxxXxxxxXxxxXx()) 6 | .xxxXxxxxXxxxXx(xxxxxXx.xxxXxxxxXxxxXx()) 7 | .xxxXxxxxx(xxxxxx.xxxXxxxxxXxxx()) 8 | .xxxxx(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/Q.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for QualifiedNames and QualifiedTypes. */ 4 | class Q { 5 | static final int zero = 0; 6 | 7 | class T {} 8 | 9 | static void f() { 10 | Q./* @MarkerAnnotation */ T t; 11 | int zero = Q.zero; 12 | java.lang./* @MarkerAnnotation */ String s = null; 13 | Q.f(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for Blocks, BodyDeclarations, BooleanLiterals, and BreakStatements. */ 4 | class B { 5 | int x; 6 | private int y; 7 | public int z; 8 | 9 | void f() { 10 | LABEL: 11 | while (true != false) { 12 | if (false == true) break; 13 | if (false == false) break LABEL; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B37895033.output: -------------------------------------------------------------------------------- 1 | class B37895033 { 2 | String[][] xs = 3 | new String[][] { 4 | {"B3", "C3", "D3"}, 5 | {"B4", "C4", "D4"}, 6 | {"B5", "C5", "D5"} 7 | }; 8 | String[] ys = 9 | new String[] { 10 | "B3", "B4", "B5", 11 | }; 12 | String[][] zs = 13 | new String[][] { 14 | {"B3"}, {"B4"}, {"B5"}, 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/TabularMixedSignInitializer.input: -------------------------------------------------------------------------------- 1 | public class T { 2 | private static final double[] f = { 3 | 95.0, 75.0, -95.0, 75.0, 4 | -95.0, 75.0, +95.0, 75.0 5 | }; 6 | 7 | private static final int[] g = { 8 | x++, y, ++z, 9 | x, y, ~z, 10 | --x, ++y, z-- 11 | }; 12 | 13 | private static final bool[] h = { 14 | a, b, c, d, 15 | !e, a, b, c 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/TabularMixedSignInitializer.output: -------------------------------------------------------------------------------- 1 | public class T { 2 | private static final double[] f = { 3 | 95.0, 75.0, -95.0, 75.0, 4 | -95.0, 75.0, +95.0, 75.0 5 | }; 6 | 7 | private static final int[] g = { 8 | x++, y, ++z, 9 | x, y, ~z, 10 | --x, ++y, z-- 11 | }; 12 | 13 | private static final bool[] h = { 14 | a, b, c, d, 15 | !e, a, b, c 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B142553964.input: -------------------------------------------------------------------------------- 1 | /************************************************************************************************************************************************************* 2 | * Copyright 3 | * 4 | * Some 5 | * 6 | * Company 7 | *************************************************************************************************************************************************************/ 8 | class T {} -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B142553964.output: -------------------------------------------------------------------------------- 1 | /************************************************************************************************************************************************************* 2 | * Copyright 3 | * 4 | * Some 5 | * 6 | * Company 7 | *************************************************************************************************************************************************************/ 8 | class T {} 9 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B112853497.input: -------------------------------------------------------------------------------- 1 | class B112853497 { 2 | { 3 | XxxxxxxxxxXxxx xxxXxxxx = 4 | xxxXxxxx 5 | .xxxxXxXxxxx(xxxxXxxx, XXXXXX_XXXX_XXXXXXXX_XX_XXXXXXXX) 6 | .toBuilder() 7 | .xxxXxxxxXxxxXx(xxxxxXx.xxxXxxxxXxxxXx()) 8 | .xxxXxxxxXxxxXx(xxxxxXx.xxxXxxxxXxxxXx()) 9 | .xxxXxxxxx(xxxxxx.xxxXxxxxxXxxx()) 10 | .xxxxx(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for Blocks, BodyDeclarations, BooleanLiterals, and BreakStatements. */ 4 | class B { 5 | int x; 6 | private int y; 7 | public int z; 8 | 9 | void f() { 10 | LABEL: 11 | while (true != false) { 12 | if (false == true) 13 | break; 14 | if (false == false) 15 | break LABEL; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B23708487.input: -------------------------------------------------------------------------------- 1 | class B23708487 { 2 | static { 3 | TASK_AS_OWNER = 4 | com.google.security.acl.proto2api.ACL.Entry.newBuilder() 5 | .setRole(com.google.security.acl.proto2api.ACL.Entry.ROLE.OWNER.getNumber()) 6 | .setScope(com.google.security.acl.proto2api.ACL.Scope.newBuilder() 7 | .setMdbUser(BorgTaskInfo.getMdbUser().getMdbUserName())) 8 | .build(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B19950815.input: -------------------------------------------------------------------------------- 1 | class B19950815 { 2 | void m() { 3 | checkArgument( 4 | truncationLength >= 0, "maxLength (%s) must be >= length of the truncation indicator (%s)", 5 | maxLength, truncationIndicator.length()); 6 | } 7 | 8 | private String finishCollapseFrom( 9 | CharSequence sequence, int start, int end, char replacement, StringBuilder builder, 10 | boolean inMatchingGroup) { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B37895033.input: -------------------------------------------------------------------------------- 1 | class B37895033 { 2 | String[][] xs = 3 | new String[][] { 4 | {"B3", "C3", "D3"}, 5 | {"B4", "C4", "D4"}, 6 | {"B5", "C5", "D5"} 7 | }; 8 | String[] ys = 9 | new String[] { 10 | "B3", 11 | "B4", 12 | "B5", 13 | }; 14 | String[][] zs = 15 | new String[][] { 16 | {"B3"}, 17 | {"B4"}, 18 | {"B5"}, 19 | }; 20 | } 21 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20578077.output: -------------------------------------------------------------------------------- 1 | class B20578077 { 2 | { 3 | new IteratorTester( 4 | 4, MODIFIABLE, newArrayList(1, 2), IteratorTester.KnownOrder.KNOWN_ORDER) { 5 | @Override 6 | protected Iterator newTargetIterator() { 7 | Iterator iterator = Lists.newArrayList(1, 2).iterator(); 8 | return new IteratorWithSunJavaBug6529795(iterator); 9 | } 10 | }.test(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B33358723.input: -------------------------------------------------------------------------------- 1 | class B33358723 { 2 | { 3 | f( 4 | // 5 | x -> 6 | System.err.println( 7 | // 8 | "hello")); 9 | f( 10 | // 11 | ( // 12 | x) -> 13 | System.err.println( 14 | // 15 | "hello")); 16 | f( 17 | // 18 | (int // 19 | x) -> 20 | System.err.println( 21 | // 22 | "hello")); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20578077.input: -------------------------------------------------------------------------------- 1 | class B20578077 { 2 | { 3 | new IteratorTester( 4 | 4, MODIFIABLE, newArrayList(1, 2), IteratorTester.KnownOrder.KNOWN_ORDER) { 5 | @Override 6 | protected Iterator newTargetIterator() { 7 | Iterator iterator = Lists.newArrayList(1, 2).iterator(); 8 | return new IteratorWithSunJavaBug6529795(iterator); 9 | } 10 | } 11 | .test(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20531711.input: -------------------------------------------------------------------------------- 1 | class B20531711 { 2 | void m() { 3 | when(mLoginHelper.getAllAccounts()).thenReturn( 4 | new Account[] { 5 | new Account("test1", "test1"), 6 | new Account("test2", "test2"), 7 | }); 8 | 9 | when(mLoginHelper.getAllAccounts()).thenReturn( 10 | new Account[] { 11 | new Account("test1", "test1"), 12 | new Account("test2", "test2"), 13 | // asd 14 | }); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B23708487.output: -------------------------------------------------------------------------------- 1 | class B23708487 { 2 | static { 3 | TASK_AS_OWNER = 4 | com.google.security.acl.proto2api.ACL.Entry.newBuilder() 5 | .setRole(com.google.security.acl.proto2api.ACL.Entry.ROLE.OWNER.getNumber()) 6 | .setScope( 7 | com.google.security.acl.proto2api.ACL.Scope.newBuilder() 8 | .setMdbUser(BorgTaskInfo.getMdbUser().getMdbUserName())) 9 | .build(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B27078833.output: -------------------------------------------------------------------------------- 1 | enum OpKind { 2 | POST_INCR(Precedence.POSTFIX), 3 | POST_DECR(Precedence.POSTFIX), 4 | 5 | PRE_INCR(Precedence.UNARY), 6 | PRE_DECR(Precedence.UNARY), 7 | PLUS(Precedence.UNARY), 8 | NEG(Precedence.UNARY), 9 | COMP(Precedence.UNARY), 10 | NOT(Precedence.UNARY), 11 | 12 | MULT(Precedence.MULTIPLICATIVE), 13 | DIVIDE(Precedence.MULTIPLICATIVE), 14 | MODULO(Precedence.MULTIPLICATIVE), 15 | ; 16 | 17 | // ... 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B27078833.input: -------------------------------------------------------------------------------- 1 | enum OpKind { 2 | 3 | POST_INCR(Precedence.POSTFIX), 4 | POST_DECR(Precedence.POSTFIX), 5 | 6 | PRE_INCR(Precedence.UNARY), 7 | PRE_DECR(Precedence.UNARY), 8 | PLUS(Precedence.UNARY), 9 | NEG(Precedence.UNARY), 10 | COMP(Precedence.UNARY), 11 | NOT(Precedence.UNARY), 12 | 13 | MULT(Precedence.MULTIPLICATIVE), 14 | DIVIDE(Precedence.MULTIPLICATIVE), 15 | MODULO(Precedence.MULTIPLICATIVE), 16 | ; 17 | 18 | // ... 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21465217.input: -------------------------------------------------------------------------------- 1 | class B21465217 { 2 | void m() { 3 | try (JimfsOutputStream out2 = newOutputStream(false); 4 | BufferedOutputStream bout = new BufferedOutputStream(out2); 5 | OutputStreamWriter writer = new OutputStreamWriter(bout, UTF_8___________________________)) { 6 | } 7 | 8 | try (Writer sourceWriter = env.getFiler().createSourceFile(qualifiedNamezzzzzzzz).openWriter()) { 9 | sourceWriter.append(fileContents); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /scripts/mvn-deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ $# -lt 1 ]; then 3 | echo "usage $0 [ ...]" 4 | exit 1; 5 | fi 6 | key=${1} 7 | shift 8 | params=${@} 9 | 10 | #validate key 11 | keystatus=$(gpg --list-keys | grep ${key} | awk '{print $1}') 12 | if [ "${keystatus}" != "pub" ]; then 13 | echo "Could not find public key with label ${key}" 14 | echo -n "Available keys from: " 15 | gpg --list-keys | grep --invert-match '^sub' 16 | 17 | exit 1 18 | fi 19 | 20 | mvn ${params} -P sonatype-oss-release -Dgpg.keyname=${key} deploy 21 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B19950815.output: -------------------------------------------------------------------------------- 1 | class B19950815 { 2 | void m() { 3 | checkArgument( 4 | truncationLength >= 0, 5 | "maxLength (%s) must be >= length of the truncation indicator (%s)", 6 | maxLength, 7 | truncationIndicator.length()); 8 | } 9 | 10 | private String finishCollapseFrom( 11 | CharSequence sequence, 12 | int start, 13 | int end, 14 | char replacement, 15 | StringBuilder builder, 16 | boolean inMatchingGroup) {} 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/Multivariables.output: -------------------------------------------------------------------------------- 1 | class Multivariables { 2 | int xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, 3 | yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy, 4 | zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz; 5 | 6 | // Horizontal and veritcal paddings used for most cells in the standings table. 7 | private final int hpad, vpad; 8 | 9 | { 10 | { 11 | for (c = cx.iterator(), m = mx.iterator(); c.hasNext() && m.hasNext(); ) { 12 | f(c, m); 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20531711.output: -------------------------------------------------------------------------------- 1 | class B20531711 { 2 | void m() { 3 | when(mLoginHelper.getAllAccounts()) 4 | .thenReturn( 5 | new Account[] { 6 | new Account("test1", "test1"), new Account("test2", "test2"), 7 | }); 8 | 9 | when(mLoginHelper.getAllAccounts()) 10 | .thenReturn( 11 | new Account[] { 12 | new Account("test1", "test1"), new Account("test2", "test2"), 13 | // asd 14 | }); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21465217.output: -------------------------------------------------------------------------------- 1 | class B21465217 { 2 | void m() { 3 | try (JimfsOutputStream out2 = newOutputStream(false); 4 | BufferedOutputStream bout = new BufferedOutputStream(out2); 5 | OutputStreamWriter writer = 6 | new OutputStreamWriter(bout, UTF_8___________________________)) {} 7 | 8 | try (Writer sourceWriter = 9 | env.getFiler().createSourceFile(qualifiedNamezzzzzzzz).openWriter()) { 10 | sourceWriter.append(fileContents); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /util/publish-snapshot-on-commit.sh: -------------------------------------------------------------------------------- 1 | # https://github.com/google/dagger/blob/master/util/publish-snapshot-on-commit.sh 2 | 3 | if [ "$TRAVIS_REPO_SLUG" == "google/google-java-format" ] && \ 4 | [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ] && \ 5 | [ "$TRAVIS_PULL_REQUEST" == "false" ] && \ 6 | [ "$TRAVIS_BRANCH" == "master" ]; then 7 | echo -e "Publishing maven snapshot...\n" 8 | 9 | mvn clean source:jar deploy --settings="util/settings.xml" -DskipTests=true -Dinvoker.skip=true -Dmaven.javadoc.skip=true 10 | 11 | echo -e "Published maven snapshot" 12 | fi 13 | -------------------------------------------------------------------------------- /eclipse_plugin/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Bundle-ManifestVersion: 2 3 | Bundle-Name: google-java-format 4 | Bundle-SymbolicName: google-java-format-eclipse-plugin;singleton:=true 5 | Bundle-Version: 1.6.0 6 | Bundle-RequiredExecutionEnvironment: JavaSE-1.8 7 | Require-Bundle: org.eclipse.jdt.core;bundle-version="3.10.0", 8 | org.eclipse.jface, 9 | org.eclipse.text, 10 | org.eclipse.ui, 11 | org.eclipse.equinox.common 12 | Bundle-ClassPath: ., 13 | lib/guava-22.0.jar, 14 | lib/javac-shaded-9+181-r4173-1.jar, 15 | lib/google-java-format-1.6.jar 16 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/Multivariables.input: -------------------------------------------------------------------------------- 1 | class Multivariables { 2 | int xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx, 3 | yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy, 4 | zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz; 5 | 6 | // Horizontal and veritcal paddings used for most cells in the standings table. 7 | private final int hpad, vpad; 8 | 9 | { 10 | { 11 | for (c = cx.iterator(), m = mx.iterator(); 12 | c.hasNext() && m.hasNext(); ) { 13 | f(c, m); 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21331232.output: -------------------------------------------------------------------------------- 1 | class B21331232 { 2 | private S instantiate( 3 | Class wrapperType, Type t, FailureStrategy fs, SF factory, Iterable data) {} 4 | 5 | public > IterableSubject, T, C> that( 6 | @Nullable Iterable target) { 7 | return IterableSubject.create(getFailureStrategy(), target); 8 | } 9 | 10 | boolean mightContain( 11 | T object, Funnel funnels, int numHashFunctions, BitArray bits); 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B33358723.output: -------------------------------------------------------------------------------- 1 | class B33358723 { 2 | { 3 | f( 4 | // 5 | x -> 6 | System.err.println( 7 | // 8 | "hello")); 9 | f( 10 | // 11 | ( // 12 | x) -> 13 | System.err.println( 14 | // 15 | "hello")); 16 | f( 17 | // 18 | (int // 19 | x) -> 20 | System.err.println( 21 | // 22 | "hello")); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21331232.input: -------------------------------------------------------------------------------- 1 | class B21331232 { 2 | private 3 | S instantiate( 4 | Class wrapperType, Type t, FailureStrategy fs, SF factory, Iterable data) { 5 | } 6 | 7 | public > 8 | IterableSubject, T, C> that(@Nullable Iterable target) { 9 | return IterableSubject.create(getFailureStrategy(), target); 10 | } 11 | 12 | boolean mightContain(T object, Funnel funnels, int numHashFunctions, BitArray bits); 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20567842.input: -------------------------------------------------------------------------------- 1 | public class B20567842 { 2 | // don't try to wrap the rhs as '{1, 2, 3}', go to block-like initializer style: 3 | int[] xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = {1, 2, 3}; 4 | 5 | // force block style, but not one-per-line for trailing ',': 6 | int[] x = {a.b, true ? 1 : 2, CONST,}; 7 | 8 | // don't format one-per-line here: 9 | int[] x = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; 10 | } 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20580212.input: -------------------------------------------------------------------------------- 1 | class B20580212 { 2 | void m() { 3 | GroupExpansionReply mockIsgReply = 4 | buildRecipientListSubGroupReply( 5 | RECIPIENT1, 6 | alternatives /* isgExpansions */, 7 | alternativesDeltas /* isgExpansionsScoreDeltas */, 8 | false /* withRecipient */, 9 | 0 /* recipientScoreDelta */); 10 | 11 | try { 12 | } catch (IllegalStateException e) { /* expected */ } 13 | } 14 | 15 | static class ThrowsAtEndException extends RuntimeException { /* nothing */ } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21278211.output: -------------------------------------------------------------------------------- 1 | class B21278211 { 2 | void m() { 3 | return names.isEmpty() || names.size() == 1 && names.get(0).toString().isEmpty(); 4 | 5 | // use unified breaks for all chained dereferences 6 | 7 | x.f().g(); 8 | x.fzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz() 9 | .gzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz(); 10 | 11 | x.f().g().h(); 12 | x.f() 13 | .g() 14 | .hzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz(); 15 | 16 | x.f().g().h().i(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B64493529.input: -------------------------------------------------------------------------------- 1 | /** Copies from {@link Foo} to {@link Bar}. */ 2 | // XXXX.XxXxxxxx() 3 | class B64493529 { 4 | // XXXX.XxxxXxxxxx(//xxxxx/xxxxxxx/xxxx/xxx/xxxxxx/xxx/xxxxxxx/xxxx/xxx/xxxxxxx/xxxxxxx/\ 5 | // XxxxxxXxxxxxXXxxxxxxXxxxxx.java) 6 | // XXXX.XxxxXxxxxx(//xxxxx/xxxxxxx/xxxx/xxx/xxxxxx/xxx/xxxxxxx/xxxx/xxx/xxxxxxx/xxxxxxx/\ 7 | // XxxxxxXxxxxxXXxxxxxxXxxxxx.java) 8 | } 9 | // XXXX.XxxxXxxxxx(//xxxxx/xxxxxxx/xxxx/xxx/xxxxxx/xxx/xxxxxxx/xxxx/xxx/xxxxxxx/xxxxxxx/\ 10 | // XxxxxxXxxxxxXXxxxxxxXxxxxx.java) 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B64493529.output: -------------------------------------------------------------------------------- 1 | /** Copies from {@link Foo} to {@link Bar}. */ 2 | // XXXX.XxXxxxxx() 3 | class B64493529 { 4 | // XXXX.XxxxXxxxxx(//xxxxx/xxxxxxx/xxxx/xxx/xxxxxx/xxx/xxxxxxx/xxxx/xxx/xxxxxxx/xxxxxxx/\ 5 | // XxxxxxXxxxxxXXxxxxxxXxxxxx.java) 6 | // XXXX.XxxxXxxxxx(//xxxxx/xxxxxxx/xxxx/xxx/xxxxxx/xxx/xxxxxxx/xxxx/xxx/xxxxxxx/xxxxxxx/\ 7 | // XxxxxxXxxxxxXXxxxxxxXxxxxx.java) 8 | } 9 | // XXXX.XxxxXxxxxx(//xxxxx/xxxxxxx/xxxx/xxx/xxxxxx/xxx/xxxxxxx/xxxx/xxx/xxxxxxx/xxxxxxx/\ 10 | // XxxxxxXxxxxxXXxxxxxxXxxxxx.java) 11 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B65214682.input: -------------------------------------------------------------------------------- 1 | @BugPattern( 2 | name = "AsyncFunctionReturnsImmediate", 3 | summary = SIMPLIFY, 4 | category = GUAVA, 5 | severity = NOT_A_PROBLEM, 6 | maturity = EXPERIMENTAL 7 | ) 8 | @BugPattern( 9 | name = "AsyncFunctionReturnsImmediate", 10 | summary = SIMPLIFY, 11 | explanation = 12 | "If an AsyncFunction always returns immediateFuture() and never throws, it can " 13 | + "be replaced with a Function.", 14 | category = GUAVA, 15 | severity = NOT_A_PROBLEM, 16 | maturity = EXPERIMENTAL) 17 | class Test {} 18 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B65214682.output: -------------------------------------------------------------------------------- 1 | @BugPattern( 2 | name = "AsyncFunctionReturnsImmediate", 3 | summary = SIMPLIFY, 4 | category = GUAVA, 5 | severity = NOT_A_PROBLEM, 6 | maturity = EXPERIMENTAL) 7 | @BugPattern( 8 | name = "AsyncFunctionReturnsImmediate", 9 | summary = SIMPLIFY, 10 | explanation = 11 | "If an AsyncFunction always returns immediateFuture() and never throws, it can " 12 | + "be replaced with a Function.", 13 | category = GUAVA, 14 | severity = NOT_A_PROBLEM, 15 | maturity = EXPERIMENTAL) 16 | class Test {} 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22873322.input: -------------------------------------------------------------------------------- 1 | class B22873322 { 2 | { 3 | f(param -> veryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongExpr(param)); 4 | f((param1, param2) -> veryLooooooooooooooooooooooooooooooooooooooooooooooooongExpr(param1, param2)); 5 | f((int param) -> veryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongExpr(param)); 6 | f((param1, param2) -> { 7 | return expr(param1, param2); 8 | }); 9 | f((param1, param2) -> { 10 | Object foo = expr(param1, param2); 11 | return foo; 12 | }); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/T.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** 4 | * Tests for ThisExpressions, ThrowStatements, TryStatements, TypeDeclarationStatements, 5 | * TypeDeclarations, TypeLiterals, TypeMethodReferences, TypeParameters, and Types. 6 | */ 7 | class T { 8 | // TODO(jdd): Add tests for higher language levels. 9 | 10 | T f(int x) throws Exception { 11 | class TT {} 12 | if (x == 0 || T.class == null) { 13 | return this; 14 | } 15 | try (AutoCloseable y = null) { 16 | throw new RuntimeException(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/T.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** 4 | * Tests for ThisExpressions, ThrowStatements, TryStatements, TypeDeclarationStatements, 5 | * TypeDeclarations, TypeLiterals, TypeMethodReferences, TypeParameters, and Types. 6 | */ 7 | class T { 8 | // TODO(jdd): Add tests for higher language levels. 9 | 10 | T f(int x) throws Exception { 11 | class TT {} 12 | if (x == 0 || T.class == null) { 13 | return this; 14 | } 15 | try (AutoCloseable y = null) { 16 | throw new RuntimeException(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20580212.output: -------------------------------------------------------------------------------- 1 | class B20580212 { 2 | void m() { 3 | GroupExpansionReply mockIsgReply = 4 | buildRecipientListSubGroupReply( 5 | RECIPIENT1, 6 | alternatives /* isgExpansions */, 7 | alternativesDeltas /* isgExpansionsScoreDeltas */, 8 | false /* withRecipient */, 9 | 0 /* recipientScoreDelta */); 10 | 11 | try { 12 | } catch (IllegalStateException e) { 13 | /* expected */ 14 | } 15 | } 16 | 17 | static class ThrowsAtEndException extends RuntimeException { 18 | /* nothing */ 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/N.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for NameQualifiedTypes, Names, NormalAnnotations, NullLiterals, and NumberLiterals. */ 4 | class N { 5 | @NormalAnnotation( 6 | a = 1, b = 2, c = 3, d = 4, e = 5, f = 6, g = 7, h = 8, i = 9, j = 10, k = 11, l = 12, m = 13, 7 | n = 14, o = 15, p = 16, q = 17, r = 18, s = 19, t = 20, u = 21, v = 22, w = 23, x = 24, 8 | y = 25, z = 26) 9 | void f() { 10 | assert 00 == 0 && 0x0 == 0 && 1.0e0f == 1.00e0f && 0.2D == .2D; 11 | java.lang. /* @MarkerAnnotation */String s = null; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20567842.output: -------------------------------------------------------------------------------- 1 | public class B20567842 { 2 | // don't try to wrap the rhs as '{1, 2, 3}', go to block-like initializer style: 3 | int[] xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx = { 4 | 1, 2, 3 5 | }; 6 | 7 | // force block style, but not one-per-line for trailing ',': 8 | int[] x = { 9 | a.b, true ? 1 : 2, CONST, 10 | }; 11 | 12 | // don't format one-per-line here: 13 | int[] x = { 14 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 15 | 1, 1, 1, 1 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20529113.input: -------------------------------------------------------------------------------- 1 | @BugPattern(category = GUAVA, severity = NOT_A_PROBLEM, maturity = EXPERIMENTAL) 2 | @BugPattern( 3 | name = "AsyncFunctionReturnsImmediate", summary = SIMPLIFY, 4 | category = GUAVA, severity = NOT_A_PROBLEM, maturity = EXPERIMENTAL) 5 | @BugPattern( 6 | name = "AsyncFunctionReturnsImmediate", summary = SIMPLIFY, 7 | explanation = 8 | "If an AsyncFunction always returns immediateFuture() and never throws, it can " 9 | + "be replaced with a Function.", 10 | category = GUAVA, severity = NOT_A_PROBLEM, maturity = EXPERIMENTAL) 11 | class Test { 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B23349153.input: -------------------------------------------------------------------------------- 1 | class B23349153 { 2 | enum Foo { 3 | A, B,; 4 | } 5 | { 6 | System.err.println("Hello");; 7 | } 8 | } 9 | 10 | private enum UnsafeAtomicHelperFactory { 11 | REALLY_TRY_TO_CREATE { 12 | @Override 13 | AtomicHelper tryCreateUnsafeAtomicHelper() { 14 | return new UnsafeAtomicHelper(); 15 | } 16 | }, 17 | 18 | DONT_EVEN_TRY_TO_CREATE { 19 | @Override 20 | AtomicHelper tryCreateUnsafeAtomicHelper() { 21 | return null; 22 | } 23 | }, 24 | 25 | ; 26 | 27 | abstract AtomicHelper tryCreateUnsafeAtomicHelper(); 28 | } 29 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/SuperQualifier.input: -------------------------------------------------------------------------------- 1 | class SuperQualifier { 2 | String a() { 3 | return this.toStringHelper() 4 | .add("foo", foo_________________________________________) 5 | .add("bar", bar_________________________________________); 6 | } 7 | 8 | String b() { 9 | return super.toStringHelper() 10 | .add("foo", foo_________________________________________) 11 | .add("bar", bar_________________________________________); 12 | } 13 | 14 | { 15 | this.aaaaaaaaaaaaaaaa.bbbbbbbbbbbbbbbbbbb( 16 | ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/P.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** 4 | * Tests for PackageDeclarations, ParameterizedTypes, ParenthesizedExpressions, PostfixExpressions, 5 | * PrefixExpressions, and PrimitiveTypes. 6 | */ 7 | class P< 8 | T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, 9 | T22, T23, T24> { 10 | void f() { 11 | int x = (1 + 2) * 3; 12 | ++x; 13 | x++; 14 | int j = + + +x; 15 | int k = + + ++x; 16 | int jj = - - -x; 17 | int kk = - - --x; 18 | boolean b = false; 19 | boolean bb = !!b; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/SuperQualifier.output: -------------------------------------------------------------------------------- 1 | class SuperQualifier { 2 | String a() { 3 | return this.toStringHelper() 4 | .add("foo", foo_________________________________________) 5 | .add("bar", bar_________________________________________); 6 | } 7 | 8 | String b() { 9 | return super.toStringHelper() 10 | .add("foo", foo_________________________________________) 11 | .add("bar", bar_________________________________________); 12 | } 13 | 14 | { 15 | this.aaaaaaaaaaaaaaaa.bbbbbbbbbbbbbbbbbbb( 16 | ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/Unformatted2.input: -------------------------------------------------------------------------------- 1 | package com . google . googlejavaformat ; 2 | 3 | /** 4 | * Rewrite comments. This interface is implemented by 5 | * {@link com.google.googlejavaformat.java.JavaCommentsHelper JavaCommentsHelper}. 6 | */ 7 | public interface CommentsHelper { 8 | /** 9 | * Try to rewrite comments, returning rewritten text. 10 | * @param text0 the literal comment text to rewrite 11 | * @param maxWidth the line length for the output 12 | * @param column0 the current column 13 | * @return the rewritten comment 14 | */ 15 | String rewrite ( String text0 , int maxWidth , int column0 ) ; 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/Unformatted2.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat; 2 | 3 | /** 4 | * Rewrite comments. This interface is implemented by {@link 5 | * com.google.googlejavaformat.java.JavaCommentsHelper JavaCommentsHelper}. 6 | */ 7 | public interface CommentsHelper { 8 | /** 9 | * Try to rewrite comments, returning rewritten text. 10 | * 11 | * @param text0 the literal comment text to rewrite 12 | * @param maxWidth the line length for the output 13 | * @param column0 the current column 14 | * @return the rewritten comment 15 | */ 16 | String rewrite(String text0, int maxWidth, int column0); 17 | } 18 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B23349153.output: -------------------------------------------------------------------------------- 1 | class B23349153 { 2 | enum Foo { 3 | A, 4 | B, 5 | ; 6 | } 7 | 8 | { 9 | System.err.println("Hello"); 10 | ; 11 | } 12 | } 13 | 14 | private enum UnsafeAtomicHelperFactory { 15 | REALLY_TRY_TO_CREATE { 16 | @Override 17 | AtomicHelper tryCreateUnsafeAtomicHelper() { 18 | return new UnsafeAtomicHelper(); 19 | } 20 | }, 21 | 22 | DONT_EVEN_TRY_TO_CREATE { 23 | @Override 24 | AtomicHelper tryCreateUnsafeAtomicHelper() { 25 | return null; 26 | } 27 | }, 28 | ; 29 | 30 | abstract AtomicHelper tryCreateUnsafeAtomicHelper(); 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21278211.input: -------------------------------------------------------------------------------- 1 | class B21278211 { 2 | void m() { 3 | return names.isEmpty() || names.size() == 1 && names.get(0).toString().isEmpty(); 4 | 5 | // use unified breaks for all chained dereferences 6 | 7 | x.f().g(); 8 | x.fzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz() 9 | .gzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz(); 10 | 11 | x.f().g().h(); 12 | x 13 | .f() 14 | .g() 15 | .hzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz(); 16 | 17 | x 18 | .f() 19 | .g() 20 | .h() 21 | .i(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B37629610.output: -------------------------------------------------------------------------------- 1 | class B37629610 { 2 | private static ImmutableList toInputOutputPairs(Options options) { 3 | for (Iterator inputIt = options.inputJars.iterator(), 4 | outputIt = options.outputJars.iterator(); 5 | inputIt.hasNext(); ) {} 6 | for (Iterator inputIt = options.inputJars.iterator(), 7 | outputIt = options.outputJars.iterator(); 8 | ; 9 | inputIt.next()) {} 10 | for (inputIt = options.inputJars.iterator(), // 11 | outputIt = options.outputJars.iterator(); 12 | ; 13 | inputIt.next()) {} 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B37629610.input: -------------------------------------------------------------------------------- 1 | class B37629610 { 2 | private static ImmutableList toInputOutputPairs(Options options) { 3 | for (Iterator inputIt = options.inputJars.iterator(), 4 | outputIt = options.outputJars.iterator(); 5 | inputIt.hasNext(); 6 | ) {} 7 | for (Iterator inputIt = options.inputJars.iterator(), 8 | outputIt = options.outputJars.iterator(); 9 | ; 10 | inputIt.next()) {} 11 | for (inputIt = options.inputJars.iterator(), // 12 | outputIt = options.outputJars.iterator(); 13 | ; 14 | inputIt.next()) {} 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20529113.output: -------------------------------------------------------------------------------- 1 | @BugPattern(category = GUAVA, severity = NOT_A_PROBLEM, maturity = EXPERIMENTAL) 2 | @BugPattern( 3 | name = "AsyncFunctionReturnsImmediate", 4 | summary = SIMPLIFY, 5 | category = GUAVA, 6 | severity = NOT_A_PROBLEM, 7 | maturity = EXPERIMENTAL) 8 | @BugPattern( 9 | name = "AsyncFunctionReturnsImmediate", 10 | summary = SIMPLIFY, 11 | explanation = 12 | "If an AsyncFunction always returns immediateFuture() and never throws, it can " 13 | + "be replaced with a Function.", 14 | category = GUAVA, 15 | severity = NOT_A_PROBLEM, 16 | maturity = EXPERIMENTAL) 17 | class Test {} 18 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B26694550.output: -------------------------------------------------------------------------------- 1 | class B26694550 { 2 | { 3 | /* === not a param comment */ 4 | fffffffffffffffffffffffffffffff( 5 | ImmutableList.copyOf(keys), /*&=*/ 6 | /*keepGoing=*/ false, 7 | ggggggggggggggggggggggggggggggggggggggggggg); 8 | fffffffffffffffffffffffffffffff( 9 | ImmutableList.copyOf(keys), 10 | /*keepGoing=*/ false, 11 | ggggggggggggggggggggggggggggggggggggggggggg); 12 | fffffffffffffffffffffffffffffff( 13 | ImmutableList.copyOf(keys), 14 | /*foo_bar=*/ false, 15 | /*foo-bar=*/ false, 16 | ggggggggggggggggggggggggggggggggggggggggggg); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B35644813.output: -------------------------------------------------------------------------------- 1 | class B35644813 { 2 | { 3 | return foo____________.bar__________().baz____________().stream() 4 | .map(Baz::getId) 5 | .collect(toList()); 6 | } 7 | 8 | private static final ImmutableSet SCANDINAVIA = 9 | ImmutableSet.of( 10 | DENMARK____________________________________________________, 11 | NORWAY_____________________________________________________, 12 | SWEDEN_____________________________________________________) 13 | .stream() 14 | .map(x -> String.format("country: %s", x.toLowerCase())) 15 | .collect(toImmutableSet()); 16 | } 17 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21192435.input: -------------------------------------------------------------------------------- 1 | package testdata.output; 2 | 3 | public class B21192435 { 4 | 5 | static class Test extends Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx implements Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx{} 6 | 7 | static class Testxxxxxxxxx extends Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx implements Xxxxx{} 8 | 9 | static class Testxxxxxxxxx extends Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx implements Xxxxxxxxxxxxxxxx{} 10 | 11 | static class Test extends Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx implements Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx {} 12 | } 13 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B26694550.input: -------------------------------------------------------------------------------- 1 | class B26694550 { 2 | { 3 | /* === not a param comment */ 4 | fffffffffffffffffffffffffffffff( 5 | ImmutableList.copyOf(keys), /*&=*//*keepGoing=*/ 6 | false, 7 | ggggggggggggggggggggggggggggggggggggggggggg); 8 | fffffffffffffffffffffffffffffff( 9 | ImmutableList.copyOf(keys), 10 | /*keepGoing=*/ 11 | false, 12 | ggggggggggggggggggggggggggggggggggggggggggg); 13 | fffffffffffffffffffffffffffffff( 14 | ImmutableList.copyOf(keys), 15 | /*foo_bar=*/ 16 | false, 17 | /*foo-bar=*/ 18 | false, 19 | ggggggggggggggggggggggggggggggggggggggggggg); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B35644813.input: -------------------------------------------------------------------------------- 1 | class B35644813 { 2 | { 3 | return foo____________ 4 | .bar__________() 5 | .baz____________() 6 | .stream() 7 | .map(Baz::getId) 8 | .collect(toList()); 9 | } 10 | 11 | private static final ImmutableSet SCANDINAVIA = 12 | ImmutableSet.of( 13 | DENMARK____________________________________________________, 14 | NORWAY_____________________________________________________, 15 | SWEDEN_____________________________________________________) 16 | .stream() 17 | .map(x -> String.format("country: %s", x.toLowerCase())) 18 | .collect(toImmutableSet()); 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/NormalAnnotation.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** JavaDoc comment. */ 4 | public @interface NormalAnnotation { 5 | int a(); 6 | 7 | int b(); 8 | 9 | int c(); 10 | 11 | int d(); 12 | 13 | int e(); 14 | 15 | int f(); 16 | 17 | int g(); 18 | 19 | int h(); 20 | 21 | int i(); 22 | 23 | int j(); 24 | 25 | int k(); 26 | 27 | int l(); 28 | 29 | int m(); 30 | 31 | int n(); 32 | 33 | int o(); 34 | 35 | int p(); 36 | 37 | int q(); 38 | 39 | int r(); 40 | 41 | int s(); 42 | 43 | int t(); 44 | 45 | int u(); 46 | 47 | int v(); 48 | 49 | int w(); 50 | 51 | int x(); 52 | 53 | int y(); 54 | 55 | int z(); 56 | } 57 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/NormalAnnotation.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** JavaDoc comment. */ 4 | public @interface NormalAnnotation { 5 | int a(); 6 | 7 | int b(); 8 | 9 | int c(); 10 | 11 | int d(); 12 | 13 | int e(); 14 | 15 | int f(); 16 | 17 | int g(); 18 | 19 | int h(); 20 | 21 | int i(); 22 | 23 | int j(); 24 | 25 | int k(); 26 | 27 | int l(); 28 | 29 | int m(); 30 | 31 | int n(); 32 | 33 | int o(); 34 | 35 | int p(); 36 | 37 | int q(); 38 | 39 | int r(); 40 | 41 | int s(); 42 | 43 | int t(); 44 | 45 | int u(); 46 | 47 | int v(); 48 | 49 | int w(); 50 | 51 | int x(); 52 | 53 | int y(); 54 | 55 | int z(); 56 | } 57 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testimports/A.imports-only: -------------------------------------------------------------------------------- 1 | package com.google.example; 2 | 3 | import static com.google.truth.Truth.assertThat; 4 | import static org.junit.Assert.fail; 5 | 6 | import com.google.common.base.Preconditions; 7 | import java.util.List; 8 | import javax.annotations.Nullable; 9 | import org.junit.runner.RunWith; 10 | import org.junit.runners.JUnit4; 11 | 12 | @RunWith( JUnit4.class ) public class SomeTest { 13 | 14 | void check(@Nullable List x) { 15 | Preconditions.checkNodeNull(x); 16 | } 17 | 18 | void f() { 19 | List xs = null; 20 | assertThat(xs).isNull(); 21 | try { 22 | check(xs); 23 | fail(); 24 | } catch (NullPointerException e) { 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/TryWithResources.input: -------------------------------------------------------------------------------- 1 | class TryWtihResources { 2 | { 3 | try (@A C c = c(); ) {} 4 | try (final @A C c = c(); ) {} 5 | try (@A final C c = c(); ) {} 6 | try (@A final @B C c = c(); ) {} 7 | 8 | try (final BufferedWriter writer = 9 | new BufferedWriter(new OutputStreamWriter(testFile, Charset.defaultCharset()))) { 10 | writer.append("tom cruise\n").append("avatar\n"); 11 | writer.flush(); 12 | } 13 | 14 | try (@SuppressWarnings("resource") 15 | Scanner inputScanner = new Scanner(inputStream).useDelimiter("\\s+|,")) { 16 | while (inputScanner.hasNextLong()) { 17 | placementIds.add(inputScanner.nextLong()); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/TryWithResources.output: -------------------------------------------------------------------------------- 1 | class TryWtihResources { 2 | { 3 | try (@A C c = c(); ) {} 4 | try (final @A C c = c(); ) {} 5 | try (@A final C c = c(); ) {} 6 | try (@A final @B C c = c(); ) {} 7 | 8 | try (final BufferedWriter writer = 9 | new BufferedWriter(new OutputStreamWriter(testFile, Charset.defaultCharset()))) { 10 | writer.append("tom cruise\n").append("avatar\n"); 11 | writer.flush(); 12 | } 13 | 14 | try (@SuppressWarnings("resource") 15 | Scanner inputScanner = new Scanner(inputStream).useDelimiter("\\s+|,")) { 16 | while (inputScanner.hasNextLong()) { 17 | placementIds.add(inputScanner.nextLong()); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testimports/A.imports-and-formatting: -------------------------------------------------------------------------------- 1 | package com.google.example; 2 | 3 | import static com.google.truth.Truth.assertThat; 4 | import static org.junit.Assert.fail; 5 | 6 | import com.google.common.base.Preconditions; 7 | import java.util.List; 8 | import javax.annotations.Nullable; 9 | import org.junit.runner.RunWith; 10 | import org.junit.runners.JUnit4; 11 | 12 | @RunWith(JUnit4.class) 13 | public class SomeTest { 14 | 15 | void check(@Nullable List x) { 16 | Preconditions.checkNodeNull(x); 17 | } 18 | 19 | void f() { 20 | List xs = null; 21 | assertThat(xs).isNull(); 22 | try { 23 | check(xs); 24 | fail(); 25 | } catch (NullPointerException e) { 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B18479811.input: -------------------------------------------------------------------------------- 1 | class Test { 2 | public void testPrimitiveFields() { 3 | ConverterVerifier.verifyFieldsAreAnnotatedWithToPojo( 4 | Contact.class, DomainContact.class, 5 | new ImmutableList.Builder().add( 6 | "address1", "address2", "assistant", "assistantPhone", "birthDate", "committed", 7 | "createdBy", "createdDate", "deleted", "department", "description", 8 | "domainObjId", "email1", "email2", "emailOptOut", "firstName", "lastName", 9 | "leadSource", "level", "modifiedBy", "modifiedDate", 10 | "phoneFax", "phoneHome", "phoneMobile", "phoneOther", "phoneWork", 11 | "salutation", "title" 12 | 13 | ).build()); 14 | } 15 | } -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testimports/A.formatting-only: -------------------------------------------------------------------------------- 1 | package com.google.example; 2 | 3 | import com.google.common.base.Preconditions; 4 | 5 | import org.junit.runner.RunWith; 6 | import org.junit.runners.JUnit4; 7 | 8 | import java.util.List; 9 | 10 | import javax.annotations.Nullable; 11 | 12 | import static org.junit.Assert.fail; 13 | import static com.google.truth.Truth.assertThat; 14 | 15 | @RunWith(JUnit4.class) 16 | public class SomeTest { 17 | 18 | void check(@Nullable List x) { 19 | Preconditions.checkNodeNull(x); 20 | } 21 | 22 | void f() { 23 | List xs = null; 24 | assertThat(xs).isNull(); 25 | try { 26 | check(xs); 27 | fail(); 28 | } catch (NullPointerException e) { 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22873322.output: -------------------------------------------------------------------------------- 1 | class B22873322 { 2 | { 3 | f( 4 | param -> 5 | veryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongExpr( 6 | param)); 7 | f( 8 | (param1, param2) -> 9 | veryLooooooooooooooooooooooooooooooooooooooooooooooooongExpr(param1, param2)); 10 | f( 11 | (int param) -> 12 | veryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongExpr(param)); 13 | f( 14 | (param1, param2) -> { 15 | return expr(param1, param2); 16 | }); 17 | f( 18 | (param1, param2) -> { 19 | Object foo = expr(param1, param2); 20 | return foo; 21 | }); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/M1.input: -------------------------------------------------------------------------------- 1 | import a.A; 2 | import a.B; 3 | import com.google.Foo; 4 | 5 | @A @B 6 | module com.google.m { 7 | requires com.google.r1; 8 | requires transitive com.google.r2; 9 | requires static com.google.r3; 10 | exports com.google.e1; 11 | exports com.google.e1 to com.google.e2; 12 | exports com.google.e1 to com.google.e2, com.google.e3; 13 | exports com.google.e1 to com.google.e2, com.google.e3, com.google.e4; 14 | opens com.google.o1; 15 | opens com.google.o1 to com.google.o2; 16 | opens com.google.o1 to com.google.o2, com.google.o3; 17 | opens com.google.o1 to com.google.o2, com.google.o3, com.googleoe4; 18 | uses Foo; 19 | uses com.google.Bar; 20 | provides com.google.Baz with Foo; 21 | provides com.google.Baz with Foo, com.google.Bar; 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testimports/A.input: -------------------------------------------------------------------------------- 1 | package com.google.example; 2 | 3 | import com.google.common.base.Preconditions; 4 | 5 | import org.junit.runner.RunWith; 6 | import org.junit.runners.JUnit4; 7 | 8 | import java.util.List; 9 | import java.util.Set; 10 | 11 | import javax.annotations.Nullable; 12 | 13 | import static org.junit.Assert.fail; 14 | import static com.google.truth.Truth.assertThat; 15 | 16 | @RunWith( JUnit4.class ) public class SomeTest { 17 | 18 | void check(@Nullable List x) { 19 | Preconditions.checkNodeNull(x); 20 | } 21 | 22 | void f() { 23 | List xs = null; 24 | assertThat(xs).isNull(); 25 | try { 26 | check(xs); 27 | fail(); 28 | } catch (NullPointerException e) { 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21192435.output: -------------------------------------------------------------------------------- 1 | package testdata.output; 2 | 3 | public class B21192435 { 4 | 5 | static class Test extends Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 6 | implements Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx {} 7 | 8 | static class Testxxxxxxxxx 9 | extends Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx implements Xxxxx {} 10 | 11 | static class Testxxxxxxxxx 12 | extends Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 13 | implements Xxxxxxxxxxxxxxxx {} 14 | 15 | static class Test< 16 | Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> 17 | extends Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx implements Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx {} 18 | } 19 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testimports/A.formatting-and-unused-import-removal: -------------------------------------------------------------------------------- 1 | package com.google.example; 2 | 3 | import com.google.common.base.Preconditions; 4 | 5 | import org.junit.runner.RunWith; 6 | import org.junit.runners.JUnit4; 7 | 8 | import java.util.List; 9 | 10 | import javax.annotations.Nullable; 11 | 12 | import static org.junit.Assert.fail; 13 | import static com.google.truth.Truth.assertThat; 14 | 15 | @RunWith(JUnit4.class) 16 | public class SomeTest { 17 | 18 | void check(@Nullable List x) { 19 | Preconditions.checkNodeNull(x); 20 | } 21 | 22 | void f() { 23 | List xs = null; 24 | assertThat(xs).isNull(); 25 | try { 26 | check(xs); 27 | fail(); 28 | } catch (NullPointerException e) { 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testimports/A.formatting-and-import-sorting: -------------------------------------------------------------------------------- 1 | package com.google.example; 2 | 3 | import static com.google.truth.Truth.assertThat; 4 | import static org.junit.Assert.fail; 5 | 6 | import com.google.common.base.Preconditions; 7 | import java.util.List; 8 | import java.util.Set; 9 | import javax.annotations.Nullable; 10 | import org.junit.runner.RunWith; 11 | import org.junit.runners.JUnit4; 12 | 13 | @RunWith(JUnit4.class) 14 | public class SomeTest { 15 | 16 | void check(@Nullable List x) { 17 | Preconditions.checkNodeNull(x); 18 | } 19 | 20 | void f() { 21 | List xs = null; 22 | assertThat(xs).isNull(); 23 | try { 24 | check(xs); 25 | fail(); 26 | } catch (NullPointerException e) { 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /eclipse_plugin/README.md: -------------------------------------------------------------------------------- 1 | # google-java-format Eclipse Plugin 2 | 3 | ## Enabling 4 | 5 | See https://github.com/google/google-java-format#eclipse 6 | 7 | ## Development 8 | 9 | 1) Uncomment `eclipse_plugin` in the parent `pom.xml` 10 | 11 | 2) Run `mvn install`, which will copy the dependences of the plugin to 12 | `eclipse_plugin/lib`. 13 | 14 | 2) If you are using Java 9, add 15 | 16 | ``` 17 | -vm 18 | /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/java 19 | ``` 20 | 21 | to `/Applications/Eclipse.app/Contents/Eclipse/eclipse.ini`. 22 | 23 | 3) Open the `eclipse_plugin` project in a recent Eclipse SDK build. 24 | 25 | 4) From `File > Export` select `Plugin-in Development > Deployable plugin-ins 26 | and fragments` and follow the wizard to export a plugin jar. 27 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22166687.input: -------------------------------------------------------------------------------- 1 | class B22166687 { 2 | public static class Wrapper 3 | extends CrossComponentSetBindingsWrapper< 4 | ExtensionWrapper> 5 | implements CrossComponentSetBindingsWrapper< 6 | ExtensionWrapper> { 7 | void m() {} 8 | } 9 | public static class Wrapper 10 | extends CrossComponentSetBindingsWrapper< 11 | ExtensionWrapper> 12 | implements CrossComponentSetBindingsWrapper< 13 | ExtensionWrapper>, 14 | CrossComponentSetBindingsWrapper< 15 | ExtensionWrapper> { 16 | void m() {} 17 | } 18 | } -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/P.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** 4 | * Tests for PackageDeclarations, ParameterizedTypes, ParenthesizedExpressions, PostfixExpressions, 5 | * PrefixExpressions, and PrimitiveTypes. 6 | */ 7 | class P< 8 | T1, 9 | T2, 10 | T3, 11 | T4, 12 | T5, 13 | T6, 14 | T7, 15 | T8, 16 | T9, 17 | T10, 18 | T11, 19 | T12, 20 | T13, 21 | T14, 22 | T15, 23 | T16, 24 | T17, 25 | T18, 26 | T19, 27 | T20, 28 | T21, 29 | T22, 30 | T23, 31 | T24> { 32 | void f() { 33 | int x = (1 + 2) * 3; 34 | ++x; 35 | x++; 36 | int j = + + +x; 37 | int k = + + ++x; 38 | int jj = - - -x; 39 | int kk = - - --x; 40 | boolean b = false; 41 | boolean bb = !!b; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B28066276.input: -------------------------------------------------------------------------------- 1 | class B28066276 { 2 | class A extends S 3 | implements I________________, I________________, I________________, I________________, 4 | I________________, I________________, I________________, I________________, 5 | I________________, I________________, I________________, I________________, 6 | I________________, I________________, I________________, I________________ {} 7 | 8 | interface B 9 | extends I________________, I________________, I________________, I________________, 10 | I________________, I________________, I________________, I________________, 11 | I________________, I________________, I________________, I________________, 12 | I________________, I________________, I________________, I________________ {} 13 | } -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22166687.output: -------------------------------------------------------------------------------- 1 | class B22166687 { 2 | public static class Wrapper 3 | extends CrossComponentSetBindingsWrapper< 4 | ExtensionWrapper> 5 | implements CrossComponentSetBindingsWrapper< 6 | ExtensionWrapper> { 7 | void m() {} 8 | } 9 | 10 | public static class Wrapper 11 | extends CrossComponentSetBindingsWrapper< 12 | ExtensionWrapper> 13 | implements CrossComponentSetBindingsWrapper< 14 | ExtensionWrapper>, 15 | CrossComponentSetBindingsWrapper< 16 | ExtensionWrapper> { 17 | void m() {} 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20569245.output: -------------------------------------------------------------------------------- 1 | class B20569245 { 2 | void m() { 3 | if (true) System.err.println("asd"); 4 | 5 | if (true) System.err.println("asd"); 6 | else if (true) System.err.println("asd"); 7 | else System.err.println("asd"); 8 | 9 | if (true) System.err.println("asd"); 10 | else if (true) System.err.println("asd"); 11 | 12 | if (true) System.err.println("asd"); 13 | else System.err.println("asd"); 14 | 15 | if (true) System.err.println("asd"); 16 | 17 | if (true) System.err.println("asd"); 18 | else if (true) System.err.println("asd"); 19 | else System.err.println("asd"); 20 | 21 | if (true) System.err.println("asd"); 22 | else if (true) System.err.println("asd"); 23 | 24 | if (true) System.err.println("asd"); 25 | else System.err.println("asd"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /core/src/main/java/com/google/googlejavaformat/java/GoogleJavaFormatVersion.java.template: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.googlejavaformat.java; 16 | 17 | class GoogleJavaFormatVersion { 18 | 19 | static String version() { 20 | return "%VERSION%"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/N.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for NameQualifiedTypes, Names, NormalAnnotations, NullLiterals, and NumberLiterals. */ 4 | class N { 5 | @NormalAnnotation( 6 | a = 1, 7 | b = 2, 8 | c = 3, 9 | d = 4, 10 | e = 5, 11 | f = 6, 12 | g = 7, 13 | h = 8, 14 | i = 9, 15 | j = 10, 16 | k = 11, 17 | l = 12, 18 | m = 13, 19 | n = 14, 20 | o = 15, 21 | p = 16, 22 | q = 17, 23 | r = 18, 24 | s = 19, 25 | t = 20, 26 | u = 21, 27 | v = 22, 28 | w = 23, 29 | x = 24, 30 | y = 25, 31 | z = 26) 32 | void f() { 33 | assert 00 == 0 && 0x0 == 0 && 1.0e0f == 1.00e0f && 0.2D == .2D; 34 | java.lang./* @MarkerAnnotation */ String s = null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/D.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for Dimensions and DoStatements. */ 4 | class D { 5 | // TODO(jdd): Test higher-language-level features. 6 | 7 | int[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][] 8 | [][][][] 9 | array[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][] 10 | [][][][][][][]; 11 | 12 | void f() { 13 | do { 14 | assert false; 15 | } while (1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 16 | + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 17 | == 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 18 | + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/D.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for Dimensions and DoStatements. */ 4 | class D { 5 | // TODO(jdd): Test higher-language-level features. 6 | 7 | int[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][] 8 | [][][][] 9 | array[][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][] 10 | [][][][][][][]; 11 | 12 | void f() { 13 | do { 14 | assert false; 15 | } while (1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 16 | + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 17 | == 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 18 | + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20569245.input: -------------------------------------------------------------------------------- 1 | class B20569245 { 2 | void m() { 3 | if (true) System.err.println("asd"); 4 | 5 | if (true) System.err.println("asd"); 6 | else if (true) System.err.println("asd"); 7 | else System.err.println("asd"); 8 | 9 | if (true) System.err.println("asd"); 10 | else if (true) System.err.println("asd"); 11 | 12 | if (true) System.err.println("asd"); 13 | else System.err.println("asd"); 14 | 15 | if (true) 16 | System.err.println("asd"); 17 | 18 | if (true) 19 | System.err.println("asd"); 20 | else if (true) 21 | System.err.println("asd"); 22 | else 23 | System.err.println("asd"); 24 | 25 | if (true) 26 | System.err.println("asd"); 27 | else if (true) 28 | System.err.println("asd"); 29 | 30 | if (true) 31 | System.err.println("asd"); 32 | else 33 | System.err.println("asd"); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20844369.input: -------------------------------------------------------------------------------- 1 | public class B20844369 { 2 | private static final String ID_PATTERN = 3 | // TODO(daw): add min/max lengths for the numbers here, e.g. android ID 4 | "(?:(?\\d+)\\+)?" // optional Android ID 5 | + "(?\\d+)" // type 6 | + ":" 7 | + "(?\\d+)" // timestamp 8 | + "(?%" // begin optional subtype 9 | + "(?:(?\\d+)#)?" // subtype's optional user ID, followed by a hash 10 | + "(?[0-9a-fA-F]{8})" // subtype's category hash 11 | + "(?[0-9a-fA-F]{8})" // subtype's token hash 12 | + ")?"; // end optional subtype 13 | 14 | int x = //foo 15 | 42 + //bar 16 | 1; 17 | 18 | int x = 19 | //foo 20 | 42 + //bar 21 | 1; 22 | 23 | int x = /*foo*/ 24 | 42 + //bar 25 | 1; 26 | 27 | int x = 28 | /*foo*/ 29 | 42 + //bar 30 | 1; 31 | } 32 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B30223986.output: -------------------------------------------------------------------------------- 1 | /** 2 | * Base class for {@link Foo}. 3 | * 4 | *

    The subclass should implement {@link #bar()}, with the implementation returning a new instance 5 | * of the foo relevant to that baz. 6 | * 7 | *

    Example: 8 | * @Override 9 | * protected Foo bar() { 10 | * return new Foo(); 11 | * } 12 | * The subclass should call {@link #get()} to get the foo object, and should not cache it in 13 | * the subclass. Example: 14 | * @Annotation("something") 15 | * public void thing() { 16 | * } 17 | * 18 | * 19 | * @param concrete subclass 20 | */ 21 | class Test { 22 | /** 23 | * Field 24 | * 25 | *

    Example: 26 | * 27 | *

    
    28 |    *   @Annotation("something")
    29 |    *   public void thing() {
    30 |    *   }
    31 |    * 
    32 | * 33 | * @param asd 34 | */ 35 | int x() {} 36 | 37 | /** Inline foo. */ 38 | int y() {} 39 | } 40 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B29368546.output: -------------------------------------------------------------------------------- 1 | public class B29368546 { 2 | /** 3 | * Example: 4 | * 5 | *
    {@code
     6 |    * class T {
     7 |    * }
     8 |    * }
    9 | */ 10 | int x; 11 | 12 | /** 13 | * Example: 14 | * 15 | *
    {@code
    16 |    * class T {
    17 |    * }
    18 |    * }
    19 | */ 20 | int x; 21 | 22 | /** 23 | * Example: 24 | * 25 | *
    {@code
    26 |    * class T {
    27 |    * }
    28 |    * }
    29 | */ 30 | int x; 31 | 32 | /** 33 | * Example: 34 | * 35 | *
    {@code
    36 |    * foo bar
    37 |    * }
    38 |    *
    39 |    * more stuff
    40 |    * 
    41 | * 42 | *
    {@code
    43 |    * foo bar
    44 |    * }
    45 |    *
    46 |    * more stuff that ends with {
    47 |    * }
    48 | */ 49 | int x; 50 | 51 | /** 52 | * Example: 53 | * 54 | *
    {@code
    55 |    * class T {}
    56 |    * 
    // oops, we forgot the close brace 57 | * 58 | * more stuff that ends with {} 59 | */ 60 | int x; 61 | } 62 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/M1.output: -------------------------------------------------------------------------------- 1 | import a.A; 2 | import a.B; 3 | import com.google.Foo; 4 | 5 | @A 6 | @B 7 | module com.google.m { 8 | requires com.google.r1; 9 | requires transitive com.google.r2; 10 | requires static com.google.r3; 11 | 12 | exports com.google.e1; 13 | exports com.google.e1 to 14 | com.google.e2; 15 | exports com.google.e1 to 16 | com.google.e2, 17 | com.google.e3; 18 | exports com.google.e1 to 19 | com.google.e2, 20 | com.google.e3, 21 | com.google.e4; 22 | 23 | opens com.google.o1; 24 | opens com.google.o1 to 25 | com.google.o2; 26 | opens com.google.o1 to 27 | com.google.o2, 28 | com.google.o3; 29 | opens com.google.o1 to 30 | com.google.o2, 31 | com.google.o3, 32 | com.googleoe4; 33 | 34 | uses Foo; 35 | uses com.google.Bar; 36 | 37 | provides com.google.Baz with 38 | Foo; 39 | provides com.google.Baz with 40 | Foo, 41 | com.google.Bar; 42 | } 43 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B29368546.input: -------------------------------------------------------------------------------- 1 | public class B29368546 { 2 | /** 3 | * Example: 4 | * 5 | *
    {@code
     6 |    *     class T {
     7 |    *     }
     8 |    * }
    9 | */ 10 | int x; 11 | 12 | /** 13 | * Example: 14 | * 15 | *
        {@code
    16 |    *   class T {
    17 |    *   }
    18 |    * }
    19 | */ 20 | int x; 21 | 22 | /** 23 | * Example: 24 | * 25 | *
    {@code
    26 |    *   class T {
    27 |    *   }}
    28 | */ 29 | int x; 30 | 31 | /** 32 | * Example: 33 | * 34 | *
    {@code
    35 |    * foo bar
    36 |    * }
    37 |    *
    38 |    * more stuff
    39 |    * 
    40 | * 41 | *
    {@code
    42 |    * foo bar
    43 |    * }
    44 |    *
    45 |    * more stuff that ends with {}
    46 |    * 
    47 | */ 48 | int x; 49 | 50 | /** 51 | * Example: 52 | * 53 | *
    {@code
    54 |    * class T {}
    55 |    * 
    // oops, we forgot the close brace 56 | * 57 | * more stuff that ends with {} 58 | */ 59 | int x; 60 | } 61 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B30223986.input: -------------------------------------------------------------------------------- 1 | /** 2 | * Base class for {@link Foo}. 3 | * 4 | *

    The subclass should implement {@link #bar()}, with the implementation returning a 5 | * new instance of the foo relevant to that baz. 6 | * 7 | * Example: 8 | * 9 | * @Override 10 | * protected Foo bar() { 11 | * return new Foo(); 12 | * } 13 | * 14 | * 15 | * The subclass should call {@link #get()} to get the foo object, 16 | * and should not cache it in the subclass. 17 | * Example: 18 | * 19 | * @Annotation("something") 20 | * public void thing() { 21 | * } 22 | * 23 | * 24 | * @param concrete subclass 25 | */ 26 | class Test { 27 | /** 28 | * Field 29 | * 30 | * Example: 31 | *

    
    32 |    *   @Annotation("something")
    33 |    *   public void thing() {
    34 |    *   }
    35 |    * 
    36 | * 37 | * @param asd 38 | */ 39 | int x() {} 40 | 41 | /** 42 | * Inline foo. 43 | */ 44 | int y() {} 45 | } -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B20844369.output: -------------------------------------------------------------------------------- 1 | public class B20844369 { 2 | private static final String ID_PATTERN = 3 | // TODO(daw): add min/max lengths for the numbers here, e.g. android ID 4 | "(?:(?\\d+)\\+)?" // optional Android ID 5 | + "(?\\d+)" // type 6 | + ":" 7 | + "(?\\d+)" // timestamp 8 | + "(?%" // begin optional subtype 9 | + "(?:(?\\d+)#)?" // subtype's optional user ID, followed by a hash 10 | + "(?[0-9a-fA-F]{8})" // subtype's category hash 11 | + "(?[0-9a-fA-F]{8})" // subtype's token hash 12 | + ")?"; // end optional subtype 13 | 14 | int x = // foo 15 | 42 + // bar 16 | 1; 17 | 18 | int x = 19 | // foo 20 | 42 21 | + // bar 22 | 1; 23 | 24 | int x = /*foo*/ 25 | 42 + // bar 26 | 1; 27 | 28 | int x = 29 | /*foo*/ 30 | 42 31 | + // bar 32 | 1; 33 | } 34 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/java14.output: -------------------------------------------------------------------------------- 1 | class Java14 { 2 | void f() { 3 | if (obj instanceof String s) { 4 | } else { 5 | } 6 | } 7 | 8 | record Range(T lo, T hi) implements Comparable> { 9 | 10 | public Range {} 11 | 12 | Range(T lo) { 13 | this(lo, lo); 14 | } 15 | 16 | @Override 17 | public int compareTo(Range other) { 18 | throw new UnsupportedOperationException(); 19 | } 20 | } 21 | 22 | record Foo(int id) {} 23 | 24 | record Rcv(int id) { 25 | public Rcv(Rcv this, int id) { 26 | this.id = id; 27 | } 28 | } 29 | 30 | void g() { 31 | var block = """ 32 | hello 33 | text 34 | blocks 35 | """.indent(6); 36 | } 37 | 38 | void h() { 39 | int numLetters = 40 | switch (day) { 41 | case MONDAY, FRIDAY, SUNDAY -> 6; 42 | case TUESDAY -> 7; 43 | case THURSDAY, SATURDAY -> 8; 44 | case WEDNESDAY -> 9; 45 | }; 46 | } 47 | 48 | { 49 | for (var arg : List.of()) {} 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/java14.input: -------------------------------------------------------------------------------- 1 | class Java14 { 2 | void f() { 3 | if (obj instanceof String s) { 4 | } else { 5 | } 6 | } 7 | 8 | record Range(T lo, T hi) implements Comparable> { 9 | 10 | public Range {} 11 | 12 | Range(T lo) { 13 | this(lo, lo); 14 | } 15 | 16 | @Override 17 | public int compareTo(Range other) { 18 | throw new UnsupportedOperationException(); 19 | } 20 | } 21 | 22 | record Foo(int id) {} 23 | 24 | record Rcv(int id) { 25 | public Rcv(Rcv this, int id) { 26 | this.id = id; 27 | } 28 | } 29 | 30 | void g() { 31 | var block = """ 32 | hello 33 | text 34 | blocks 35 | """.indent(6); 36 | } 37 | 38 | void h() { 39 | int numLetters = switch (day) { 40 | case MONDAY, FRIDAY, SUNDAY -> 6; 41 | case TUESDAY -> 7; 42 | case THURSDAY, SATURDAY -> 8; 43 | case WEDNESDAY -> 9; 44 | }; 45 | } 46 | 47 | { 48 | for (var arg : List.of()) {} 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | os: Visual Studio 2015 2 | install: 3 | - ps: | 4 | Add-Type -AssemblyName System.IO.Compression.FileSystem 5 | if (!(Test-Path -Path "C:\maven" )) { 6 | (new-object System.Net.WebClient).DownloadFile( 7 | 'http://www.us.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.zip', 8 | 'C:\maven-bin.zip' 9 | ) 10 | [System.IO.Compression.ZipFile]::ExtractToDirectory("C:\maven-bin.zip", "C:\maven") 11 | } 12 | - cmd: SET JAVA_HOME=C:\Program Files\Java\jdk11 13 | - cmd: SET PATH=C:\maven\apache-maven-3.3.9\bin;%JAVA_HOME%\bin;%PATH% 14 | - cmd: SET MAVEN_OPTS=-XX:MaxPermSize=2g -Xmx4g 15 | - cmd: SET JAVA_OPTS=-XX:MaxPermSize=2g -Xmx4g 16 | 17 | build_script: 18 | - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V 19 | 20 | test_script: 21 | - mvn test -B 22 | 23 | cache: 24 | - C:\maven\ 25 | - C:\Users\appveyor\.m2 26 | 27 | notifications: 28 | - provider: Email 29 | to: 30 | - google-java-format-dev+ci@google.com 31 | on_build_success: false 32 | on_build_failure: true 33 | on_build_status_changed: true 34 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B26952926.input: -------------------------------------------------------------------------------- 1 | class T { 2 | { 3 | this( 4 | x, // line comment 5 | x // line comment 6 | ); 7 | super( 8 | x, // line comment 9 | x // line comment 10 | ); 11 | new t( 12 | x, // line comment 13 | x // line comment 14 | ); 15 | f( 16 | x, // line comment 17 | x // line comment 18 | ); 19 | fffff.fffff( 20 | x, // line comment 21 | x // line comment 22 | ); 23 | fffff 24 | .fffff( 25 | x, // line comment 26 | x // line comment 27 | ) 28 | .fffff( 29 | x, // line comment 30 | x // line comment 31 | ); 32 | } 33 | 34 | { 35 | this(x // line comment 36 | ); 37 | super(x // line comment 38 | ); 39 | new t(x // line comment 40 | ); 41 | f(x // line comment 42 | ); 43 | fffff.fffff(x // line comment 44 | ); 45 | fffff 46 | .fffff(x // line comment 47 | ) 48 | .fffff(x // line comment 49 | ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B24202287.output: -------------------------------------------------------------------------------- 1 | class B24202287 { 2 | { 3 | this.overflowContactCompositeSupportedRenderers = 4 | this.getSharePanelResponse 5 | .contents 6 | .unifiedSharePanelRenderer 7 | .contents[0] 8 | .connectionSection 9 | .connectionsOverflowMenu 10 | .connectionsOverflowMenuRenderer 11 | .contents[0] 12 | .overflowConnectionSectionRenderer 13 | .contacts[0]; 14 | 15 | int y = ((int[]) null)[0]; 16 | } 17 | 18 | IntentSource getSource() { 19 | return mIntent.isPresent() && mIntent.get().hasExtra(INTENT_SOURCE_KEY) 20 | ? IntentSource.values()[ 21 | mIntent.get().getIntExtra(INTENT_SOURCE_KEY, IntentSource.OTHER.ordinal())] 22 | : IntentSource.OTHER; 23 | } 24 | 25 | { 26 | mTabUiParts[mRenderedTabIndex].setData( 27 | tabs[mRenderedTabIndex], 28 | true /* isSelected */, 29 | mIsLoadingState, 30 | mErrorMessageType, 31 | mOnDailySummaryHeaderClickListener, 32 | mShowSpacerForSnackbar, 33 | mResetScrollAndAnimationAndReplaceDoodle); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B25787055.output: -------------------------------------------------------------------------------- 1 | class B25787055 { 2 | { 3 | logger.atInfo().log( 4 | "Scratch Session Cleaner exiting. Number of deleted sessions: %d, names: %s", 5 | deletedPersistentNames.size(), deletedPersistentNames); 6 | logger.atInfo().atInfo().atInfo().atInfo().atInfo().atInfo().atInfo().atInfo().atInfo().atInfo() 7 | .atInfo().log( 8 | "Scratch Session Cleaner exiting. Number of deleted sessions: %d, names: %s", 9 | deletedPersistentNames.size(), deletedPersistentNames); 10 | logger // interior 11 | .atInfo() // comments 12 | .log( // are best comments 13 | "Scratch Session Cleaner exiting. Number of deleted sessions: %d, names: %s", 14 | deletedPersistentNames.size(), deletedPersistentNames); 15 | logger 16 | .log( 17 | "Scratch Session Cleaner exiting. Number of deleted sessions: %d, names: %s", 18 | deletedPersistentNames.size(), deletedPersistentNames) 19 | .log( 20 | "Scratch Session Cleaner exiting. Number of deleted sessions: %d, names: %s", 21 | deletedPersistentNames.size(), deletedPersistentNames); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B28066276.output: -------------------------------------------------------------------------------- 1 | class B28066276 { 2 | class A extends S 3 | implements I________________, 4 | I________________, 5 | I________________, 6 | I________________, 7 | I________________, 8 | I________________, 9 | I________________, 10 | I________________, 11 | I________________, 12 | I________________, 13 | I________________, 14 | I________________, 15 | I________________, 16 | I________________, 17 | I________________, 18 | I________________ {} 19 | 20 | interface B 21 | extends I________________, 22 | I________________, 23 | I________________, 24 | I________________, 25 | I________________, 26 | I________________, 27 | I________________, 28 | I________________, 29 | I________________, 30 | I________________, 31 | I________________, 32 | I________________, 33 | I________________, 34 | I________________, 35 | I________________, 36 | I________________ {} 37 | } 38 | -------------------------------------------------------------------------------- /idea_plugin/google-java-format.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B25372815.input: -------------------------------------------------------------------------------- 1 | class Test { 2 | { 3 | // For "All goals" view, show only advertiser goals tab. 4 | return newPageTypeSet( 5 | false /* advertisers */, 6 | false /* userManagement */, 7 | false /* campaigns */, 8 | false /* adGroups */, 9 | false /* ads */, 10 | false /* keywords */, 11 | false /* negativeKeywords */, 12 | false /* advertiserBidStrategies */, 13 | false /* bidStrategies */, 14 | false /* bidStrategyRecommendations */, 15 | false /* bidKeywords */, 16 | false /* engineBidStrategies */, 17 | false /* conversionTrackers */, 18 | false /* labels */, 19 | false /* labelKeywords */, 20 | false /* evergreen labels */, 21 | false /* searchQueries */, 22 | false /* engineSearchQueries */, 23 | false /* remarketingTarget */, 24 | false /* sitelinks */, 25 | false /* feedSitelinks */, 26 | false /* locationExtensions */, 27 | false /* callExtensions */, 28 | false /* calloutExtensions */, 29 | false /* appExtensions */, 30 | false /* events */); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B25372815.output: -------------------------------------------------------------------------------- 1 | class Test { 2 | { 3 | // For "All goals" view, show only advertiser goals tab. 4 | return newPageTypeSet( 5 | false /* advertisers */, 6 | false /* userManagement */, 7 | false /* campaigns */, 8 | false /* adGroups */, 9 | false /* ads */, 10 | false /* keywords */, 11 | false /* negativeKeywords */, 12 | false /* advertiserBidStrategies */, 13 | false /* bidStrategies */, 14 | false /* bidStrategyRecommendations */, 15 | false /* bidKeywords */, 16 | false /* engineBidStrategies */, 17 | false /* conversionTrackers */, 18 | false /* labels */, 19 | false /* labelKeywords */, 20 | false /* evergreen labels */, 21 | false /* searchQueries */, 22 | false /* engineSearchQueries */, 23 | false /* remarketingTarget */, 24 | false /* sitelinks */, 25 | false /* feedSitelinks */, 26 | false /* locationExtensions */, 27 | false /* callExtensions */, 28 | false /* calloutExtensions */, 29 | false /* appExtensions */, 30 | false /* events */); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B26293162.input: -------------------------------------------------------------------------------- 1 | class Xxxx { 2 | 3 | public static final class XxxxXxxxxxxxXxxxxxxxxXxxxxxXxxxxxxx< 4 | X, X, X extends XxxxxxxxxXxxxxxxxxXxxxxxxx> { 5 | 6 | int x; 7 | } 8 | 9 | public static final class XxxxXxxxxxxxXxxxxxxxxXxxxxxXxxxxxxx< 10 | X, X, X extends XxxxxxxxxXxxxxxxxxXxxxxxxx> extends Xxxxx { 11 | 12 | int x; 13 | } 14 | 15 | class XxxxxxxxXxxxxxxxxXxxxXxxx< 16 | X extends XxxxxxxxxXxxxxxx, X extends XxxxxxxxxXxxxxx, X extends Xxxxxxxxxxxxx, X> 17 | extends XxxxXxxx { 18 | 19 | int x; 20 | } 21 | 22 | @Xxx 23 | class XxxxxxxxxxxXxxxxxXx< 24 | X extends XxxxxxXxxxxxxxxxxXxxxxxXxxxxx, X extends Xxxxxxx, XX extends Xxxxxxxxx> 25 | extends XxxxxxxxXx { 26 | 27 | int x; 28 | } 29 | 30 | static class XxxxxXxxxxXxxx< 31 | XXXXX extends XxxxxxxxXxxxxxx, XXX extends XxxxxxxxXxxxxxx> { 32 | 33 | int x; 34 | } 35 | 36 | @Xxx 37 | class XxxxxxxxxxxXxxxxxXx< 38 | X extends XxxxxxXxxxxxxxxxxXxxxxxXxxxxx, X extends Xxxxxxx, X extends Xxxxxxx, 39 | XX extends Xxxxxxxxx> extends XxxxxxxxXx { 40 | 41 | int x; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /core/src/main/java/com/google/googlejavaformat/CommentsHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.googlejavaformat; 16 | 17 | /** 18 | * Rewrite comments. This interface is implemented by {@link 19 | * com.google.googlejavaformat.java.JavaCommentsHelper JavaCommentsHelper}. 20 | */ 21 | public interface CommentsHelper { 22 | /** 23 | * Try to rewrite comments, returning rewritten text. 24 | * 25 | * @param tok the comment's tok 26 | * @param maxWidth the line length for the output 27 | * @param column0 the current column 28 | * @return the rewritten comment 29 | */ 30 | String rewrite(Input.Tok tok, int maxWidth, int column0); 31 | } 32 | -------------------------------------------------------------------------------- /core/src/main/java/com/google/googlejavaformat/Op.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.googlejavaformat; 16 | 17 | /** 18 | * An {@code Op} is a member of the sequence of formatting operations emitted by {@link OpsBuilder} 19 | * and transformed by {@link DocBuilder} into a {@link Doc}. Leaf subclasses of {@link Doc} 20 | * implement {@code Op}; {@link Doc.Level} is the only non-leaf, and is represented by paired {@link 21 | * OpenOp}-{@link CloseOp} {@code Op}s. 22 | */ 23 | public interface Op { 24 | /** 25 | * Add an {@code Op} to a {@link DocBuilder}. 26 | * 27 | * @param builder the {@link DocBuilder} 28 | */ 29 | void add(DocBuilder builder); 30 | } 31 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B18479811.output: -------------------------------------------------------------------------------- 1 | class Test { 2 | public void testPrimitiveFields() { 3 | ConverterVerifier.verifyFieldsAreAnnotatedWithToPojo( 4 | Contact.class, 5 | DomainContact.class, 6 | new ImmutableList.Builder() 7 | .add( 8 | "address1", 9 | "address2", 10 | "assistant", 11 | "assistantPhone", 12 | "birthDate", 13 | "committed", 14 | "createdBy", 15 | "createdDate", 16 | "deleted", 17 | "department", 18 | "description", 19 | "domainObjId", 20 | "email1", 21 | "email2", 22 | "emailOptOut", 23 | "firstName", 24 | "lastName", 25 | "leadSource", 26 | "level", 27 | "modifiedBy", 28 | "modifiedDate", 29 | "phoneFax", 30 | "phoneHome", 31 | "phoneMobile", 32 | "phoneOther", 33 | "phoneWork", 34 | "salutation", 35 | "title") 36 | .build()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B26952926.output: -------------------------------------------------------------------------------- 1 | class T { 2 | { 3 | this( 4 | x, // line comment 5 | x // line comment 6 | ); 7 | super( 8 | x, // line comment 9 | x // line comment 10 | ); 11 | new t( 12 | x, // line comment 13 | x // line comment 14 | ); 15 | f( 16 | x, // line comment 17 | x // line comment 18 | ); 19 | fffff.fffff( 20 | x, // line comment 21 | x // line comment 22 | ); 23 | fffff 24 | .fffff( 25 | x, // line comment 26 | x // line comment 27 | ) 28 | .fffff( 29 | x, // line comment 30 | x // line comment 31 | ); 32 | } 33 | 34 | { 35 | this( 36 | x // line comment 37 | ); 38 | super( 39 | x // line comment 40 | ); 41 | new t( 42 | x // line comment 43 | ); 44 | f( 45 | x // line comment 46 | ); 47 | fffff.fffff( 48 | x // line comment 49 | ); 50 | fffff 51 | .fffff( 52 | x // line comment 53 | ) 54 | .fffff( 55 | x // line comment 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B24202287.input: -------------------------------------------------------------------------------- 1 | class B24202287 { 2 | { 3 | this.overflowContactCompositeSupportedRenderers = 4 | this.getSharePanelResponse.contents.unifiedSharePanelRenderer.contents[0] 5 | .connectionSection 6 | .connectionsOverflowMenu 7 | .connectionsOverflowMenuRenderer 8 | .contents[ 9 | 0] 10 | .overflowConnectionSectionRenderer 11 | .contacts[ 12 | 0]; 13 | 14 | int y = ((int[]) null)[0]; 15 | } 16 | 17 | IntentSource getSource() { 18 | return mIntent.isPresent() && mIntent.get().hasExtra(INTENT_SOURCE_KEY) 19 | ? IntentSource.values()[ 20 | mIntent.get().getIntExtra(INTENT_SOURCE_KEY, IntentSource.OTHER.ordinal())] 21 | : IntentSource.OTHER; 22 | } 23 | 24 | { 25 | mTabUiParts[mRenderedTabIndex] 26 | .setData( 27 | tabs[mRenderedTabIndex], 28 | true /* isSelected */, 29 | mIsLoadingState, 30 | mErrorMessageType, 31 | mOnDailySummaryHeaderClickListener, 32 | mShowSpacerForSnackbar, 33 | mResetScrollAndAnimationAndReplaceDoodle); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B26293162.output: -------------------------------------------------------------------------------- 1 | class Xxxx { 2 | 3 | public static final class XxxxXxxxxxxxXxxxxxxxxXxxxxxXxxxxxxx< 4 | X, X, X extends XxxxxxxxxXxxxxxxxxXxxxxxxx> { 5 | 6 | int x; 7 | } 8 | 9 | public static final class XxxxXxxxxxxxXxxxxxxxxXxxxxxXxxxxxxx< 10 | X, X, X extends XxxxxxxxxXxxxxxxxxXxxxxxxx> 11 | extends Xxxxx { 12 | 13 | int x; 14 | } 15 | 16 | class XxxxxxxxXxxxxxxxxXxxxXxxx< 17 | X extends XxxxxxxxxXxxxxxx, X extends XxxxxxxxxXxxxxx, X extends Xxxxxxxxxxxxx, X> 18 | extends XxxxXxxx { 19 | 20 | int x; 21 | } 22 | 23 | @Xxx 24 | class XxxxxxxxxxxXxxxxxXx< 25 | X extends XxxxxxXxxxxxxxxxxXxxxxxXxxxxx, X extends Xxxxxxx, XX extends Xxxxxxxxx> 26 | extends XxxxxxxxXx { 27 | 28 | int x; 29 | } 30 | 31 | static class XxxxxXxxxxXxxx< 32 | XXXXX extends XxxxxxxxXxxxxxx, XXX extends XxxxxxxxXxxxxxx> { 33 | 34 | int x; 35 | } 36 | 37 | @Xxx 38 | class XxxxxxxxxxxXxxxxxXx< 39 | X extends XxxxxxXxxxxxxxxxxXxxxxxXxxxxx, 40 | X extends Xxxxxxx, 41 | X extends Xxxxxxx, 42 | XX extends Xxxxxxxxx> 43 | extends XxxxxxxxXx { 44 | 45 | int x; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /core/src/main/java/com/google/googlejavaformat/java/javadoc/NestingCounter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.googlejavaformat.java.javadoc; 16 | 17 | /** Mutable integer for tracking the level of nesting. */ 18 | final class NestingCounter { 19 | private int value; 20 | 21 | int value() { 22 | return value; 23 | } 24 | 25 | void increment() { 26 | value++; 27 | } 28 | 29 | void incrementIfPositive() { 30 | if (value > 0) { 31 | value++; 32 | } 33 | } 34 | 35 | void decrementIfPositive() { 36 | if (value > 0) { 37 | value--; 38 | } 39 | } 40 | 41 | boolean isPositive() { 42 | return value > 0; 43 | } 44 | 45 | void reset() { 46 | value = 0; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B25787055.input: -------------------------------------------------------------------------------- 1 | class B25787055 { 2 | { 3 | logger 4 | .atInfo() 5 | .log( 6 | "Scratch Session Cleaner exiting. Number of deleted sessions: %d, names: %s", 7 | deletedPersistentNames.size(), 8 | deletedPersistentNames); 9 | logger.atInfo().atInfo().atInfo().atInfo().atInfo().atInfo().atInfo().atInfo().atInfo().atInfo().atInfo() 10 | .log( 11 | "Scratch Session Cleaner exiting. Number of deleted sessions: %d, names: %s", 12 | deletedPersistentNames.size(), 13 | deletedPersistentNames); 14 | logger // interior 15 | .atInfo() // comments 16 | .log( // are best comments 17 | "Scratch Session Cleaner exiting. Number of deleted sessions: %d, names: %s", 18 | deletedPersistentNames.size(), 19 | deletedPersistentNames); 20 | logger 21 | .log( 22 | "Scratch Session Cleaner exiting. Number of deleted sessions: %d, names: %s", 23 | deletedPersistentNames.size(), 24 | deletedPersistentNames) 25 | .log( 26 | "Scratch Session Cleaner exiting. Number of deleted sessions: %d, names: %s", 27 | deletedPersistentNames.size(), 28 | deletedPersistentNames); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/S.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** 4 | * Tests for SimpleNames, SimpleTypes, SingleMemberAnnotations, SingleVariableDeclarations, 5 | * Statements, StringLiterals, SuperConstructorInvocations, SuperFieldAccesses, 6 | * SuperMethodInvocations, SuperMethodReferences, SwitchCases, SwitchStatements, and 7 | * SynchronizedStatements. 8 | */ 9 | class S { 10 | // TODO(jdd): Add tests for higher language levels. 11 | 12 | int x = 0; 13 | 14 | @SingleMemberAnnotation( 15 | 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 16 | + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0) 17 | S() { 18 | super(); 19 | } 20 | 21 | class SS extends S { 22 | SS() { 23 | super(); 24 | super.x = 0; 25 | super.foo(); 26 | } 27 | } 28 | 29 | void foo() { 30 | Object[] object = null; 31 | synchronized ( 32 | object[ 33 | 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 34 | + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0]) { 35 | switch ("abc") { 36 | case "one": 37 | break; 38 | case "two": 39 | break; 40 | case "three": 41 | default: 42 | break; 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/S.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** 4 | * Tests for SimpleNames, SimpleTypes, SingleMemberAnnotations, SingleVariableDeclarations, 5 | * Statements, StringLiterals, SuperConstructorInvocations, SuperFieldAccesses, 6 | * SuperMethodInvocations, SuperMethodReferences, SwitchCases, SwitchStatements, and 7 | * SynchronizedStatements. 8 | */ 9 | class S { 10 | // TODO(jdd): Add tests for higher language levels. 11 | 12 | int x = 0; 13 | 14 | @SingleMemberAnnotation( 15 | 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 16 | + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0) 17 | S() { 18 | super(); 19 | } 20 | 21 | class SS extends S { 22 | SS() { 23 | super(); 24 | super.x = 0; 25 | super.foo(); 26 | } 27 | } 28 | 29 | void foo() { 30 | Object[] object = null; 31 | synchronized ( 32 | object[ 33 | 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 34 | + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0]) { 35 | switch ("abc") { 36 | case "one": 37 | break; 38 | case "two": 39 | break; 40 | case "three": 41 | default: 42 | break; 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B24702438.input: -------------------------------------------------------------------------------- 1 | class B24702438 { 2 | 3 | @Inject int x; 4 | 5 | @Inject int y; 6 | 7 | @Inject int z; 8 | 9 | @Inject int x; 10 | @Inject int y; 11 | @Inject int z; 12 | 13 | // this is a comment 14 | 15 | // another comment 16 | int x; 17 | 18 | // another comment 19 | 20 | int y; 21 | 22 | { 23 | switch (x) { 24 | 25 | case 1: 26 | 27 | break; 28 | 29 | case 1: 30 | 31 | break; 32 | 33 | default: 34 | 35 | break; 36 | 37 | } 38 | 39 | // this is a comment 40 | 41 | // another comment 42 | System.err.println("asd"); 43 | } 44 | 45 | void f( 46 | int a, 47 | @Nullable @Deprecated ImmutableList veryVeryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, 48 | @Nullable @Deprecated ImmutableList veryVeryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, 49 | @Nullable @Deprecated ImmutableList veryVeryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, 50 | int c) {} 51 | void g( 52 | @Nullable @Deprecated ImmutableList veryVeryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, 53 | @Nullable @Deprecated ImmutableList veryVeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooong) {} 54 | } 55 | -------------------------------------------------------------------------------- /core/src/main/java/com/google/googlejavaformat/FormattingError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.googlejavaformat; 16 | 17 | import com.google.common.base.Joiner; 18 | import com.google.common.collect.ImmutableList; 19 | 20 | /** An unchecked formatting error. */ 21 | public class FormattingError extends Error { 22 | 23 | private final ImmutableList diagnostics; 24 | 25 | public FormattingError(FormatterDiagnostic diagnostic) { 26 | this(ImmutableList.of(diagnostic)); 27 | } 28 | 29 | public FormattingError(Iterable diagnostics) { 30 | super(Joiner.on("\n").join(diagnostics) + "\n"); 31 | this.diagnostics = ImmutableList.copyOf(diagnostics); 32 | } 33 | 34 | public ImmutableList diagnostics() { 35 | return diagnostics; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/I1.input: -------------------------------------------------------------------------------- 1 | class Test { 2 | final CreationMechanism creationMechanism; 3 | final @Nullable String creationUserAgent; 4 | final ClientId clientId; 5 | final @Nullable String creationUserAgentXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; 6 | final Token externalId; 7 | 8 | { 9 | final CreationMechanism creationMechanism; 10 | final @Nullable String creationUserAgent; 11 | final ClientId clientId; 12 | final @Nullable String creationUserAgentXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; 13 | final Token externalId; 14 | } 15 | } 16 | 17 | class Test { 18 | final CreationMechanism creationMechanism; 19 | @Nullable final String creationUserAgent; 20 | final ClientId clientId; 21 | @Nullable final String creationUserAgentXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; 22 | final Token externalId; 23 | 24 | { 25 | final CreationMechanism creationMechanism; 26 | @Nullable final String creationUserAgent; 27 | final ClientId clientId; 28 | @Nullable final String creationUserAgentXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; 29 | final Token externalId; 30 | } 31 | } 32 | 33 | class Test { 34 | 35 | @Nullable 36 | final String creationUserAgent; 37 | 38 | { 39 | @Nullable 40 | final String creationUserAgent; 41 | } 42 | 43 | { 44 | 45 | @Nullable 46 | final String creationUserAgent; 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Want to contribute? Great! First, read this page (including the small print at 2 | the end). 3 | 4 | ### Before you contribute 5 | 6 | Before we can use your code, you must sign the [Google Individual Contributor 7 | License 8 | Agreement](https://developers.google.com/open-source/cla/individual?csw=1) 9 | (CLA), which you can do online. The CLA is necessary mainly because you own the 10 | copyright to your changes, even after your contribution becomes part of our 11 | codebase, so we need your permission to use and distribute your code. We also 12 | need to be sure of various other things—for instance that you'll tell us if you 13 | know that your code infringes on other people's patents. You don't have to sign 14 | the CLA until after you've submitted your code for review and a member has 15 | approved it, but you must do it before we can put your code into our codebase. 16 | Before you start working on a larger contribution, you should get in touch with 17 | us first through the issue tracker with your idea so that we can help out and 18 | possibly guide you. Coordinating up front makes it much easier to avoid 19 | frustration later on. 20 | 21 | ### Code reviews 22 | 23 | All submissions, including submissions by project members, require review. We 24 | use GitHub pull requests for this purpose. 25 | 26 | ### The small print 27 | 28 | Contributions made by corporations are covered by a different agreement than the 29 | one above, the Software Grant and Corporate Contributor License Agreement. 30 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/I1.output: -------------------------------------------------------------------------------- 1 | class Test { 2 | final CreationMechanism creationMechanism; 3 | final @Nullable String creationUserAgent; 4 | final ClientId clientId; 5 | final @Nullable String 6 | creationUserAgentXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; 7 | final Token externalId; 8 | 9 | { 10 | final CreationMechanism creationMechanism; 11 | final @Nullable String creationUserAgent; 12 | final ClientId clientId; 13 | final @Nullable String 14 | creationUserAgentXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; 15 | final Token externalId; 16 | } 17 | } 18 | 19 | class Test { 20 | final CreationMechanism creationMechanism; 21 | @Nullable final String creationUserAgent; 22 | final ClientId clientId; 23 | 24 | @Nullable 25 | final String creationUserAgentXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; 26 | 27 | final Token externalId; 28 | 29 | { 30 | final CreationMechanism creationMechanism; 31 | @Nullable final String creationUserAgent; 32 | final ClientId clientId; 33 | @Nullable 34 | final String creationUserAgentXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; 35 | final Token externalId; 36 | } 37 | } 38 | 39 | class Test { 40 | 41 | @Nullable final String creationUserAgent; 42 | 43 | { 44 | @Nullable final String creationUserAgent; 45 | } 46 | 47 | { 48 | @Nullable final String creationUserAgent; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B24702438.output: -------------------------------------------------------------------------------- 1 | class B24702438 { 2 | 3 | @Inject int x; 4 | 5 | @Inject int y; 6 | 7 | @Inject int z; 8 | 9 | @Inject int x; 10 | @Inject int y; 11 | @Inject int z; 12 | 13 | // this is a comment 14 | 15 | // another comment 16 | int x; 17 | 18 | // another comment 19 | 20 | int y; 21 | 22 | { 23 | switch (x) { 24 | case 1: 25 | break; 26 | 27 | case 1: 28 | break; 29 | 30 | default: 31 | break; 32 | } 33 | 34 | // this is a comment 35 | 36 | // another comment 37 | System.err.println("asd"); 38 | } 39 | 40 | void f( 41 | int a, 42 | @Nullable @Deprecated 43 | ImmutableList 44 | veryVeryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, 45 | @Nullable @Deprecated 46 | ImmutableList 47 | veryVeryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, 48 | @Nullable @Deprecated 49 | ImmutableList 50 | veryVeryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, 51 | int c) {} 52 | 53 | void g( 54 | @Nullable @Deprecated 55 | ImmutableList 56 | veryVeryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong, 57 | @Nullable @Deprecated 58 | ImmutableList 59 | veryVeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooong) {} 60 | } 61 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B23804934.input: -------------------------------------------------------------------------------- 1 | class B23804934{ 2 | 3 | @Zzzzzz 4 | B23804934( 5 | ZzzzzzzzZzzzzzZzzzzZzzzzzzz zzzzzzzzZzzzzzZzzzzZzzzzzzz, 6 | ZzzzzzzZzzzzzzz zzzzzzZzzzZzzzZzzzzzzz, 7 | @ZzzzZzzzzZzzzzzz Zzzzzz zzzzzZzzzzzz, 8 | @ZzzzzzzzzzzZzzzzzz(Zz.ZZZZZZZ_ZZZZZ_ZZZZ_ZZZZZZ_ZZZZ_ZZZZZZZZZZ) 9 | Zzzzzzzz zzzzzZzzzZzzzzzZzzzZzzzzzzzzz) { 10 | zzzz.zzzzzzzzZzzzzzZzzzzZzzzzzzz = zzzzzzzzZzzzzzZzzzzZzzzzzzz; 11 | zzzz.zzzzzzZzzzZzzzZzzzzzzz = zzzzzzZzzzZzzzZzzzzzzz; 12 | zzzz.zzzzzZzzzzzz = zzzzzZzzzzzz; 13 | zzzz.zzzzzZzzzZzzzzzZzzzZzzzzzzzzz = zzzzzZzzzZzzzzzZzzzZzzzzzzzzz; 14 | } 15 | 16 | zzzz z( 17 | zzz z, 18 | @Zzzzzzzz @Zzzzzzzzzz 19 | ZzzzzzzzzZzzz 20 | zzzzZzzzZzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz) {} 21 | 22 | @ZzzZzzzZzzzzzzzzzz 23 | @Zzzzzzzz(zzzzzzzzz = Zzzzzzzzz.ZZ) 24 | ZzzzzzzzzzZzzzzz zzzzzzzZzzzzzzzzzz( 25 | @Zzz @Zzz zzzz zzzzZzzzZz, 26 | @Zzz @ZzzzzzzzzzZzzzz(zzzz = ZzzzzZzzzzzZzzzz.ZZZZZZ_ZZZ_ZZZ_ZZZZZZZ) 27 | zzzzzzz zzzzzzZzzZzzZzzzzzz, 28 | @Zzzzz @ZzzzzzzzzzZzzzz(zzzz = ZzzzzZzzzzzZzzzz.ZZZZZ_ZZZ_ZZZZZZZZZZZ) 29 | zzzzzzz zzzzzZzzZzzzzzzzzzz, 30 | @Zzzzz ZzzzzZzzz zzzzzZzzz) {} 31 | 32 | void fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff( 33 | final zzzzzzzzzzzzzz zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz) {} 34 | } 35 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22815364.input: -------------------------------------------------------------------------------- 1 | class B22815364 { 2 | @Xxx({ 3 | "=0|=0", "Xxx xxxx xx xxxxxxxx xx xxxxxxxxxxxxx.", 4 | "=0|xxx", "Xxx xxxx x xxxxxxxxxxxx.", 5 | "xxx|=0", "Xxx xxxx x xxxxxxx.", 6 | "xxx|xxx", "Xxx xxxx xxx xxxxxxx xxx xxx xxxxxxxxxxxx.", 7 | "xxxxx|xxx", "Xxx xxxx {0} xxxxxxxx xxx xxx xxxxxxxxxxxx.", 8 | "xxx|xxxxx", "Xxx xxxx xxx xxxxxxx xxx {1} xxxxxxxxxxxxx." 9 | }) 10 | int x; 11 | 12 | @Xxx({ 13 | "a", "b", 14 | "c", "d", 15 | // 16 | }) 17 | int y; 18 | 19 | int[] xs = { 20 | 1, 2, 3, 21 | 1, 2, 3, 22 | 1, 2, 3, 23 | }; 24 | 25 | int[] xs = { 26 | 1, 2, 3, 27 | 1, 2, 3, 28 | 1, 2, 29 | }; 30 | 31 | int[] xs = { 32 | 1, 2, 33 | 1, 34 | }; 35 | 36 | int[][] xs = { 37 | {0b111111111111111111, 0b111111111111111111, 0b111111111111111111, 0b111111111111111111, 38 | 0b111111111111111111, 0b111111111111111111, 0b111111111111111111}, {0b111111111111111111, 39 | 0b111111111111111111, 0b111111111111111111, 0b111111111111111111, 0b111111111111111111, 40 | 0b111111111111111111, 0b111111111111111111}, 41 | {0b111111111111111111, 0b111111111111111111, 0b111111111111111111, 0b111111111111111111, 42 | 0b111111111111111111, 0b111111111111111111, 0b111111111111111111}, {0b111111111111111111, 43 | 0b111111111111111111, 0b111111111111111111, 0b111111111111111111, 0b111111111111111111, 44 | 0b111111111111111111, 0b111111111111111111}, 45 | }; 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21305044.input: -------------------------------------------------------------------------------- 1 | class B21305044 { 2 | 3 | class T<@Nullable X extends @Nullable Object, 4 | @Nullable Y extends @Nullable Object, 5 | @Nullable Z extends @Nullable Object> 6 | extends Function<@Nullable X, @Nullable Y> 7 | implements Predicate<@Nullable Z> { 8 | public T(@Nullable T this, List<@Nullable X> xs) { 9 | } 10 | 11 | public T(@Nullable T B21305044.this, List<@Nullable X> xs) { 12 | } 13 | 14 | List<@Nullable ?> a; 15 | List<@Nullable ? extends @Nullable Object> b; 16 | List<@Nullable ? super @Nullable Object> c; 17 | 18 | List c; 19 | } 20 | 21 | Function f = com.foo.bar.Baz::func; 22 | Function g = new Baz()::func; 23 | Function h = Baz::new; 24 | Function i = com.foo.bar.VeryLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongBaz::new; 25 | 26 | { 27 | Function f = () -> moderatelyLongResult; 28 | Function f = () -> breakableResult + breakableResult + breakableResult + breakableResult + breakableResult + breakableResult + breakableResult + breakableResult + breakableResult; 29 | Function f = () -> System.err.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); 30 | Function f = (someParam) -> System.err.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/U.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for UnionTypes. */ 4 | class U { 5 | void f() { 6 | class Exception0 extends Exception {} 7 | class Exception1 extends Exception {} 8 | class Exception2 extends Exception {} 9 | class Exception3 extends Exception {} 10 | class Exception4 extends Exception {} 11 | class Exception5 extends Exception {} 12 | class Exception6 extends Exception {} 13 | class Exception7 extends Exception {} 14 | class Exception8 extends Exception {} 15 | class Exception9 extends Exception {} 16 | try { 17 | char c = '\123'; 18 | switch (c) { 19 | case '0': 20 | throw new Exception0(); 21 | case '1': 22 | throw new Exception1(); 23 | case '2': 24 | throw new Exception2(); 25 | case '3': 26 | throw new Exception3(); 27 | case '4': 28 | throw new Exception4(); 29 | case '5': 30 | throw new Exception5(); 31 | case '6': 32 | throw new Exception6(); 33 | case '7': 34 | throw new Exception7(); 35 | case '8': 36 | throw new Exception8(); 37 | case '9': 38 | default: 39 | throw new Exception9(); 40 | } 41 | } catch ( 42 | Exception0 | Exception1 | Exception2 | Exception3 | Exception4 | Exception5 | Exception6 43 | | Exception7 | Exception8 | Exception9 44 | e) { 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B23804934.output: -------------------------------------------------------------------------------- 1 | class B23804934 { 2 | 3 | @Zzzzzz 4 | B23804934( 5 | ZzzzzzzzZzzzzzZzzzzZzzzzzzz zzzzzzzzZzzzzzZzzzzZzzzzzzz, 6 | ZzzzzzzZzzzzzzz zzzzzzZzzzZzzzZzzzzzzz, 7 | @ZzzzZzzzzZzzzzzz Zzzzzz zzzzzZzzzzzz, 8 | @ZzzzzzzzzzzZzzzzzz(Zz.ZZZZZZZ_ZZZZZ_ZZZZ_ZZZZZZ_ZZZZ_ZZZZZZZZZZ) 9 | Zzzzzzzz zzzzzZzzzZzzzzzZzzzZzzzzzzzzz) { 10 | zzzz.zzzzzzzzZzzzzzZzzzzZzzzzzzz = zzzzzzzzZzzzzzZzzzzZzzzzzzz; 11 | zzzz.zzzzzzZzzzZzzzZzzzzzzz = zzzzzzZzzzZzzzZzzzzzzz; 12 | zzzz.zzzzzZzzzzzz = zzzzzZzzzzzz; 13 | zzzz.zzzzzZzzzZzzzzzZzzzZzzzzzzzzz = zzzzzZzzzZzzzzzZzzzZzzzzzzzzz; 14 | } 15 | 16 | zzzz z( 17 | zzz z, 18 | @Zzzzzzzz @Zzzzzzzzzz 19 | ZzzzzzzzzZzzz 20 | zzzzZzzzZzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz) {} 21 | 22 | @ZzzZzzzZzzzzzzzzzz 23 | @Zzzzzzzz(zzzzzzzzz = Zzzzzzzzz.ZZ) 24 | ZzzzzzzzzzZzzzzz zzzzzzzZzzzzzzzzzz( 25 | @Zzz @Zzz zzzz zzzzZzzzZz, 26 | @Zzz @ZzzzzzzzzzZzzzz(zzzz = ZzzzzZzzzzzZzzzz.ZZZZZZ_ZZZ_ZZZ_ZZZZZZZ) 27 | zzzzzzz zzzzzzZzzZzzZzzzzzz, 28 | @Zzzzz @ZzzzzzzzzzZzzzz(zzzz = ZzzzzZzzzzzZzzzz.ZZZZZ_ZZZ_ZZZZZZZZZZZ) 29 | zzzzzzz zzzzzZzzZzzzzzzzzzz, 30 | @Zzzzz ZzzzzZzzz zzzzzZzzz) {} 31 | 32 | void fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff( 33 | final zzzzzzzzzzzzzz 34 | zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz) {} 35 | } 36 | -------------------------------------------------------------------------------- /core/src/main/java/com/google/googlejavaformat/CloseOp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.googlejavaformat; 16 | 17 | import com.google.common.base.MoreObjects; 18 | 19 | /** 20 | * A {@code CloseOp} closes a level. It is an {@link Op} in the sequence of {@link Op}s generated by 21 | * {@link OpsBuilder}. When the sequence is turned into a {@link Doc} by {@link DocBuilder}, ranges 22 | * delimited by {@link OpenOp}-{@code CloseOp} pairs turn into nested {@link Doc.Level}s. 23 | */ 24 | public enum CloseOp implements Op { 25 | CLOSE; 26 | 27 | /** 28 | * Make a {@code CloseOp}, returning a singleton since they are all the same. 29 | * 30 | * @return the singleton {@code CloseOp} 31 | */ 32 | public static Op make() { 33 | return CLOSE; 34 | } 35 | 36 | @Override 37 | public void add(DocBuilder builder) { 38 | builder.close(); 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return MoreObjects.toStringHelper(this).toString(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/U.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | /** Tests for UnionTypes. */ 4 | class U { 5 | void f() { 6 | class Exception0 extends Exception {} 7 | class Exception1 extends Exception {} 8 | class Exception2 extends Exception {} 9 | class Exception3 extends Exception {} 10 | class Exception4 extends Exception {} 11 | class Exception5 extends Exception {} 12 | class Exception6 extends Exception {} 13 | class Exception7 extends Exception {} 14 | class Exception8 extends Exception {} 15 | class Exception9 extends Exception {} 16 | try { 17 | char c = '\123'; 18 | switch (c) { 19 | case '0': 20 | throw new Exception0(); 21 | case '1': 22 | throw new Exception1(); 23 | case '2': 24 | throw new Exception2(); 25 | case '3': 26 | throw new Exception3(); 27 | case '4': 28 | throw new Exception4(); 29 | case '5': 30 | throw new Exception5(); 31 | case '6': 32 | throw new Exception6(); 33 | case '7': 34 | throw new Exception7(); 35 | case '8': 36 | throw new Exception8(); 37 | case '9': 38 | default: 39 | throw new Exception9(); 40 | } 41 | } catch (Exception0 42 | | Exception1 43 | | Exception2 44 | | Exception3 45 | | Exception4 46 | | Exception5 47 | | Exception6 48 | | Exception7 49 | | Exception8 50 | | Exception9 e) { 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21954779.input: -------------------------------------------------------------------------------- 1 | class B21954779 { 2 | { 3 | when(computeApi.findOrCreateVm( 4 | VM_METADATA, 5 | Optional.absent(), 6 | AssignReservedIp.YES, 7 | AttachDataDisk.YES)) 8 | .thenReturn(OPERATION); 9 | 10 | fail(String.format( 11 | " Experiment name %s is used multiple times in %s", 12 | expName, envName, zzzzzzzzzzzz, zzzzzzzzzzzz)); 13 | 14 | new Handler(Looper.getMainLooper()) 15 | .post( 16 | new Runnable() { 17 | @Override 18 | public void run() { 19 | utils.showShortToast( 20 | application.getString( 21 | R.string.working_on_project_format, 22 | Utils.getProjectDisplayName(selectedProject))); 23 | } 24 | }); 25 | 26 | (new Handler()) 27 | .post( 28 | new Runnable() { 29 | @Override 30 | public void run() { 31 | showErrorAndSetDone(error); 32 | } 33 | }); 34 | 35 | getContext() 36 | .getErrorReporter() 37 | .log(new RuntimeException("Called layout with a non-zero segment index: " + segmentIndex)); 38 | 39 | bind( 40 | new Key>() {}); 41 | 42 | // this isn't a feature; we'd prefer to keep `new Key...` as one unit 43 | bind( 44 | new Key>() {}).then(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B23749160.output: -------------------------------------------------------------------------------- 1 | class B23749160 { 2 | { 3 | mockDailySummaryModuleListFiller 4 | .buildDailySummaryModulesWithHeadersOnlyAndOneExpandedDayxxxxxxxxxxx( 5 | anyInt(), anyInt(), anyInt()); 6 | 7 | mockDailySummaryModuleListFiller 8 | . 10 | buildDailySummaryModulesWithHeadersOnlyAndOneExpandedDayxxxxxxxxxxx( 11 | anyInt(), anyInt(), anyInt()); 12 | 13 | foo. 15 | buildDailySummaryModulesWithHeadersOnlyAndOneExpandedDayxxxxxxxxxxx( 16 | anyInt(), anyInt(), anyInt()) 17 | .bar(); 18 | 19 | // `.build`... and `anotherThing`... are technically at different syntactic 20 | // levels, but the indentation required to express that starts to get out 21 | // of hand 22 | MockDailySummaryModuleListFiller 23 | .buildDailySummaryModulesWithHeadersOnlyAndOneExpandedDayxxxxxxxxxxx( 24 | anyInt(), anyInt(), anyInt()) 25 | .anotherThing(); 26 | 27 | when(mockDailySummaryModuleListFiller.buildDailySummaryModulesWithHeadersOnlyAndOneExpandedDay( 28 | anyInt(), anyInt(), anyInt())) 29 | .then(); 30 | 31 | final List XXXXXXXX = 32 | ImmutableList.of( 33 | XXXXXXX, // 34 | XXXXXXX, // 35 | XXXXXXX, // 36 | XXXXXXX, // 37 | XXXXXXX // 38 | ); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B26884608.output: -------------------------------------------------------------------------------- 1 | class X26884608 { 2 | { 3 | this.xxxxxxxxxXxxxxxXxxxxxxXxxxxx( 4 | XXXXXXXXX_XXXXXXXXX); 5 | this.xxxXxxxxXxxxxxx( 6 | XxxxxXxxx.xxxxxXxxxx(xxxxxx.xxxxxxxXxxxxxXxxxx(xxxxxx), xxxxxx.xxXxxxxxx())); 7 | Xxxxx.this.xxxxxxxxxXxxxxxXxxxxxxXxxxxx( 8 | XXXXXXXXX_XXXXXXXXX); 9 | Xxxxx.this.xxxXxxxxXxxx( 10 | XxxxxXxxx.xxxxxXx(xxxxxx.xxxxxxxXxxxxxXxxxx(xxxxxx), xxxxxx.xxXxxxxxx())); 11 | xxx.xxxxxx.Xxxxx.this 12 | .xxxxxxxxxXxxxxxXxxxxxxXxxxxx( 13 | XXXXXXXXX_XXXXXXXXX); 14 | xxx.xxxxxx.Xxxxx.this.xxxXxxxxXxxx( 15 | XxxxxXxxx.xxxxxXx(xxxxxx.xxxxxxxXxxxxxXxxxx(xxxxxx), xxxxxx.xxXxxxxxx())); 16 | 17 | super.xxxxxxxxxXxxxxxXxxxxxxXxxxxx( 18 | XXXXXXXXX_XXXXXXXXX); 19 | super.xxxXxxxxXxxx( 20 | XxxxxXxxxx.xxxxxXxxxx(xxxxxx.xxxxxxxXxxxxxXxxxx(xxxxxx), xxxxxx.xxXxxxxxx())); 21 | Xxxxx.super.xxxxxxxxxXxxxxxXxxxxxxXxxxxx( 22 | XXXXXXXXX_XXXXXXXXX); 23 | Xxxxx.super.xxxXxxxxXxxx( 24 | XxxxxXxxx.xxxxxXx(xxxxxx.xxxxxxxXxxxxxXxxxx(xxxxxx), xxxxxx.xxXxxxxxx())); 25 | xxx.xxxxxx.Xxxxx.super 26 | .xxxxxxxxxXxxxxxXxxxxxxXxxxxx( 27 | XXXXXXXXX_XXXXXXXXX); 28 | xxx.xxxxxx.Xxxxx.super.xxxXxxxxXxxx( 29 | XxxxxXxxx.xxxxxXx(xxxxxx.xxxxxxxXxxxxxXxxxx(xxxxxx), xxxxxx.xxXxxxxxx())); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /idea_plugin/build.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | plugins { 18 | id "org.jetbrains.intellij" version "0.4.18" 19 | } 20 | 21 | repositories { 22 | mavenCentral() 23 | } 24 | 25 | ext { 26 | googleJavaFormatVersion = '1.7' 27 | } 28 | 29 | apply plugin: 'org.jetbrains.intellij' 30 | apply plugin: 'java' 31 | 32 | intellij { 33 | pluginName = "google-java-format" 34 | version = "2020.1" 35 | } 36 | 37 | patchPluginXml { 38 | pluginDescription = "Formats source code using the google-java-format tool. This version of " + 39 | "the plugin uses version ${googleJavaFormatVersion} of the tool." 40 | version = "${googleJavaFormatVersion}.0.5" 41 | sinceBuild = '201' 42 | untilBuild = '' 43 | } 44 | 45 | publishPlugin { 46 | token = project.ext.properties.jetbrainsPluginRepoToken 47 | } 48 | 49 | sourceSets { 50 | main { 51 | java.srcDir 'src' 52 | resources.srcDir 'resources' 53 | } 54 | } 55 | 56 | dependencies { 57 | compile "com.google.googlejavaformat:google-java-format:${googleJavaFormatVersion}" 58 | } 59 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B24543625.output: -------------------------------------------------------------------------------- 1 | /** 2 | * This
    3 | * is
    4 | * a
    5 | * train. 6 | */ 7 | class TheTrain { 8 | /* 9 | ______ 10 | .-"""".._'. _,## 11 | _..__ |.-"""-.| | _,##'`-._ 12 | (_____)||_____|| |_,##'`-._,##'` 13 | _| |.;-""-. | |#'`-._,##'` 14 | _.;_ `--' `\ \ |.'`\._,##'` 15 | /.-.\ `\ |.-";.`_, |##'` 16 | |\__/ | _..;__ |'-' / 17 | '.____.'_.-`)\--' /'-'` 18 | //||\\(_.-'_,'-'` 19 | (`-...-')_,##'` 20 | jgs _,##`-..,-;##` 21 | _,##'`-._,##'` 22 | _,##'`-._,##'` 23 | `-._,##'` 24 | */ 25 | public static final Object THE_TRAIN = null; 26 | 27 | /* 28 | BLOCK COMMENT 29 | 30 | */ 31 | int x; 32 | 33 | /* . 34 | BLOCK COMMENT . 35 | 36 | */ 37 | int y; 38 | 39 | /* . 40 | BLOCK COMMENT . 41 | 42 | */ 43 | int z; 44 | 45 | /* . 46 | BLOCK COMMENT . 47 | 48 | */ 49 | int z; 50 | 51 | /* 52 | * This is almost javadoc. 53 | * 54 | */ 55 | int z; 56 | 57 | /** 58 | * This is (was) malformed javadoc. 59 | * 60 | *
    61 |    * System.err.println
    62 |    * 
    63 | */ 64 | int z; 65 | 66 | private Object f; /*-{ 67 | System.err.println("asd"); 68 | }-*/ 69 | 70 | private native Object f() /*-{ 71 | System.err.println("asd"); 72 | }-*/; 73 | 74 | private native Object f() /*-{ 75 | System.err.println("asd"); 76 | }-*/; 77 | } 78 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B21954779.output: -------------------------------------------------------------------------------- 1 | class B21954779 { 2 | { 3 | when(computeApi.findOrCreateVm( 4 | VM_METADATA, 5 | Optional.absent(), 6 | AssignReservedIp.YES, 7 | AttachDataDisk.YES)) 8 | .thenReturn(OPERATION); 9 | 10 | fail( 11 | String.format( 12 | " Experiment name %s is used multiple times in %s", 13 | expName, envName, zzzzzzzzzzzz, zzzzzzzzzzzz)); 14 | 15 | new Handler(Looper.getMainLooper()) 16 | .post( 17 | new Runnable() { 18 | @Override 19 | public void run() { 20 | utils.showShortToast( 21 | application.getString( 22 | R.string.working_on_project_format, 23 | Utils.getProjectDisplayName(selectedProject))); 24 | } 25 | }); 26 | 27 | (new Handler()) 28 | .post( 29 | new Runnable() { 30 | @Override 31 | public void run() { 32 | showErrorAndSetDone(error); 33 | } 34 | }); 35 | 36 | getContext() 37 | .getErrorReporter() 38 | .log(new RuntimeException("Called layout with a non-zero segment index: " + segmentIndex)); 39 | 40 | bind( 41 | new Key>() {}); 42 | 43 | // this isn't a feature; we'd prefer to keep `new Key...` as one unit 44 | bind(new Key< 45 | ServiceMethodRunner>() {}) 46 | .then(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B26884608.input: -------------------------------------------------------------------------------- 1 | class X26884608 { 2 | { 3 | this 4 | .xxxxxxxxxXxxxxxXxxxxxxXxxxxx( 5 | XXXXXXXXX_XXXXXXXXX); 6 | this 7 | .xxxXxxxxXxxxxxx( 8 | XxxxxXxxx.xxxxxXxxxx(xxxxxx.xxxxxxxXxxxxxXxxxx(xxxxxx), xxxxxx.xxXxxxxxx())); 9 | Xxxxx.this 10 | .xxxxxxxxxXxxxxxXxxxxxxXxxxxx( 11 | XXXXXXXXX_XXXXXXXXX); 12 | Xxxxx.this 13 | .xxxXxxxxXxxx(XxxxxXxxx.xxxxxXx(xxxxxx.xxxxxxxXxxxxxXxxxx(xxxxxx), xxxxxx.xxXxxxxxx())); 14 | xxx.xxxxxx.Xxxxx.this 15 | .xxxxxxxxxXxxxxxXxxxxxxXxxxxx( 16 | XXXXXXXXX_XXXXXXXXX); 17 | xxx.xxxxxx.Xxxxx.this 18 | .xxxXxxxxXxxx(XxxxxXxxx.xxxxxXx(xxxxxx.xxxxxxxXxxxxxXxxxx(xxxxxx), xxxxxx.xxXxxxxxx())); 19 | 20 | super.xxxxxxxxxXxxxxxXxxxxxxXxxxxx( 21 | XXXXXXXXX_XXXXXXXXX); 22 | super.xxxXxxxxXxxx( 23 | XxxxxXxxxx.xxxxxXxxxx(xxxxxx.xxxxxxxXxxxxxXxxxx(xxxxxx), xxxxxx.xxXxxxxxx())); 24 | Xxxxx.super.xxxxxxxxxXxxxxxXxxxxxxXxxxxx( 25 | XXXXXXXXX_XXXXXXXXX); 26 | Xxxxx.super.xxxXxxxxXxxx( 27 | XxxxxXxxx.xxxxxXx(xxxxxx.xxxxxxxXxxxxxXxxxx(xxxxxx), xxxxxx.xxXxxxxxx())); 28 | xxx.xxxxxx.Xxxxx.super.xxxxxxxxxXxxxxxXxxxxxxXxxxxx(XXXXXXXXX_XXXXXXXXX); 30 | xxx.xxxxxx.Xxxxx.super.xxxXxxxxXxxx( 31 | XxxxxXxxx.xxxxxXx(xxxxxx.xxxxxxxXxxxxxXxxxx(xxxxxx), xxxxxx.xxXxxxxxx())); 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B23749160.input: -------------------------------------------------------------------------------- 1 | class B23749160 { 2 | { 3 | mockDailySummaryModuleListFiller 4 | .buildDailySummaryModulesWithHeadersOnlyAndOneExpandedDayxxxxxxxxxxx( 5 | anyInt(), anyInt(), anyInt()); 6 | 7 | mockDailySummaryModuleListFiller 8 | . 10 | buildDailySummaryModulesWithHeadersOnlyAndOneExpandedDayxxxxxxxxxxx( 11 | anyInt(), anyInt(), anyInt()); 12 | 13 | foo 14 | . 16 | buildDailySummaryModulesWithHeadersOnlyAndOneExpandedDayxxxxxxxxxxx( 17 | anyInt(), anyInt(), anyInt()) 18 | .bar(); 19 | 20 | // `.build`... and `anotherThing`... are technically at different syntactic 21 | // levels, but the indentation required to express that starts to get out 22 | // of hand 23 | MockDailySummaryModuleListFiller 24 | .buildDailySummaryModulesWithHeadersOnlyAndOneExpandedDayxxxxxxxxxxx( 25 | anyInt(), anyInt(), anyInt()) 26 | .anotherThing(); 27 | 28 | when( 29 | mockDailySummaryModuleListFiller 30 | .buildDailySummaryModulesWithHeadersOnlyAndOneExpandedDay( 31 | anyInt(), anyInt(), anyInt())) 32 | .then(); 33 | 34 | final List XXXXXXXX = 35 | ImmutableList.of( 36 | XXXXXXX, // 37 | XXXXXXX, // 38 | XXXXXXX, // 39 | XXXXXXX, // 40 | XXXXXXX // 41 | ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/B22815364.output: -------------------------------------------------------------------------------- 1 | class B22815364 { 2 | @Xxx({ 3 | "=0|=0", "Xxx xxxx xx xxxxxxxx xx xxxxxxxxxxxxx.", 4 | "=0|xxx", "Xxx xxxx x xxxxxxxxxxxx.", 5 | "xxx|=0", "Xxx xxxx x xxxxxxx.", 6 | "xxx|xxx", "Xxx xxxx xxx xxxxxxx xxx xxx xxxxxxxxxxxx.", 7 | "xxxxx|xxx", "Xxx xxxx {0} xxxxxxxx xxx xxx xxxxxxxxxxxx.", 8 | "xxx|xxxxx", "Xxx xxxx xxx xxxxxxx xxx {1} xxxxxxxxxxxxx." 9 | }) 10 | int x; 11 | 12 | @Xxx({ 13 | "a", "b", 14 | "c", "d", 15 | // 16 | }) 17 | int y; 18 | 19 | int[] xs = { 20 | 1, 2, 3, 21 | 1, 2, 3, 22 | 1, 2, 3, 23 | }; 24 | 25 | int[] xs = { 26 | 1, 2, 3, 27 | 1, 2, 3, 28 | 1, 2, 29 | }; 30 | 31 | int[] xs = { 32 | 1, 2, 1, 33 | }; 34 | 35 | int[][] xs = { 36 | { 37 | 0b111111111111111111, 38 | 0b111111111111111111, 39 | 0b111111111111111111, 40 | 0b111111111111111111, 41 | 0b111111111111111111, 42 | 0b111111111111111111, 43 | 0b111111111111111111 44 | }, 45 | { 46 | 0b111111111111111111, 47 | 0b111111111111111111, 48 | 0b111111111111111111, 49 | 0b111111111111111111, 50 | 0b111111111111111111, 51 | 0b111111111111111111, 52 | 0b111111111111111111 53 | }, 54 | { 55 | 0b111111111111111111, 56 | 0b111111111111111111, 57 | 0b111111111111111111, 58 | 0b111111111111111111, 59 | 0b111111111111111111, 60 | 0b111111111111111111, 61 | 0b111111111111111111 62 | }, 63 | { 64 | 0b111111111111111111, 65 | 0b111111111111111111, 66 | 0b111111111111111111, 67 | 0b111111111111111111, 68 | 0b111111111111111111, 69 | 0b111111111111111111, 70 | 0b111111111111111111 71 | }, 72 | }; 73 | } 74 | -------------------------------------------------------------------------------- /core/src/main/java/com/google/googlejavaformat/OpenOp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | 15 | package com.google.googlejavaformat; 16 | 17 | import com.google.common.base.MoreObjects; 18 | 19 | /** 20 | * An {@code OpenOp} opens a level. It is an {@link Op} in the sequence of {@link Op}s generated by 21 | * {@link OpsBuilder}. When the sequence is turned into a {@link Doc} by {@link DocBuilder}, {@link 22 | * Input.Tok}s delimited by {@code OpenOp}-{@link CloseOp} pairs turn into nested {@link 23 | * Doc.Level}s. 24 | */ 25 | public final class OpenOp implements Op { 26 | private final Indent plusIndent; 27 | 28 | private OpenOp(Indent plusIndent) { 29 | this.plusIndent = plusIndent; 30 | } 31 | 32 | /** 33 | * Make an ordinary {@code OpenOp}. 34 | * 35 | * @param plusIndent the indent for breaks at this level 36 | * @return the {@code OpenOp} 37 | */ 38 | public static Op make(Indent plusIndent) { 39 | return new OpenOp(plusIndent); 40 | } 41 | 42 | @Override 43 | public void add(DocBuilder builder) { 44 | builder.open(plusIndent); 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return MoreObjects.toStringHelper(this).add("plusIndent", plusIndent).toString(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /idea_plugin/src/com/google/googlejavaformat/intellij/UiFormatterStyle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Google Inc. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.google.googlejavaformat.intellij; 18 | 19 | import com.google.googlejavaformat.java.JavaFormatterOptions; 20 | import com.google.googlejavaformat.java.JavaFormatterOptions.Style; 21 | import java.util.Arrays; 22 | import java.util.Objects; 23 | 24 | /** Configuration options for the formatting style. */ 25 | enum UiFormatterStyle { 26 | GOOGLE("Default Google Java style", Style.GOOGLE), 27 | AOSP("Android Open Source Project (AOSP) style", Style.AOSP); 28 | 29 | private final String description; 30 | private final JavaFormatterOptions.Style style; 31 | 32 | UiFormatterStyle(String description, JavaFormatterOptions.Style style) { 33 | this.description = description; 34 | this.style = style; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return description; 40 | } 41 | 42 | public JavaFormatterOptions.Style convert() { 43 | return style; 44 | } 45 | 46 | static UiFormatterStyle convert(JavaFormatterOptions.Style style) { 47 | return Arrays.stream(UiFormatterStyle.values()) 48 | .filter(value -> Objects.equals(value.style, style)) 49 | .findFirst() 50 | .get(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/I.input: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Tests for IfStatements, ImportDeclarations, InfixExpressions, Initializers, 7 | * InstanceofExpressions, and IntersectionTypes. 8 | */ 9 | class I { 10 | interface I0 {} 11 | 12 | interface I1 {} 13 | 14 | interface I2 {} 15 | 16 | interface I3 {} 17 | 18 | interface I4 {} 19 | 20 | interface I5 {} 21 | 22 | interface I6 {} 23 | 24 | interface I7 {} 25 | 26 | interface I8 {} 27 | 28 | interface I9 {} 29 | 30 | interface I10 {} 31 | 32 | interface I11 {} 33 | 34 | interface I12 {} 35 | 36 | interface I13 {} 37 | 38 | interface I14 {} 39 | 40 | interface I15 {} 41 | 42 | interface I16 {} 43 | 44 | interface I17 {} 45 | 46 | interface I18 {} 47 | 48 | interface I19 {} 49 | 50 | class II< 51 | T extends 52 | I0 & I1 & I2 & I3 & I4 & I5 & I6 & I7 & I8 & I9 & I10 & I11 & I12 & I13 & I14 & I15 & I16 53 | & I17 & I18 & I19> {} 54 | 55 | static class CC { 56 | static { 57 | int i = 0; 58 | } 59 | } 60 | 61 | int x = 62 | 0 >>> 0 + 0 / 0 * 0 - 0 & 0 << 0 * 0 / 0 >> 0 - 0 ^ 0 * 0 / 0 >>> 0 << 0 * 0 - 0 / 0 63 | | 0 * 0 >> 0 + 0 / 0 * 0 - 0 << 0 64 | & 0 * 0 / 0 >>> 0 - 0 * 0 >> 0 / 0 << 0 * 0 + 0 - 0 / 0 * 0 65 | | 0 - 0 * 0 >>> 0 << 0 / 0 * 0 >> 0 - 0 ^ 0 * 0 / 0 & 0 << 0 + 0; 66 | 67 | void f() { 68 | if (0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 69 | + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 70 | == 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 71 | + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0) { 72 | } else if (null instanceof List) { 73 | } else { 74 | } 75 | if (true) {} 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /core/src/test/resources/com/google/googlejavaformat/java/testdata/I.output: -------------------------------------------------------------------------------- 1 | package com.google.googlejavaformat.java.test; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Tests for IfStatements, ImportDeclarations, InfixExpressions, Initializers, 7 | * InstanceofExpressions, and IntersectionTypes. 8 | */ 9 | class I { 10 | interface I0 {} 11 | 12 | interface I1 {} 13 | 14 | interface I2 {} 15 | 16 | interface I3 {} 17 | 18 | interface I4 {} 19 | 20 | interface I5 {} 21 | 22 | interface I6 {} 23 | 24 | interface I7 {} 25 | 26 | interface I8 {} 27 | 28 | interface I9 {} 29 | 30 | interface I10 {} 31 | 32 | interface I11 {} 33 | 34 | interface I12 {} 35 | 36 | interface I13 {} 37 | 38 | interface I14 {} 39 | 40 | interface I15 {} 41 | 42 | interface I16 {} 43 | 44 | interface I17 {} 45 | 46 | interface I18 {} 47 | 48 | interface I19 {} 49 | 50 | class II< 51 | T extends 52 | I0 & I1 & I2 & I3 & I4 & I5 & I6 & I7 & I8 & I9 & I10 & I11 & I12 & I13 & I14 & I15 & I16 53 | & I17 & I18 & I19> {} 54 | 55 | static class CC { 56 | static { 57 | int i = 0; 58 | } 59 | } 60 | 61 | int x = 62 | 0 >>> 0 + 0 / 0 * 0 - 0 & 0 << 0 * 0 / 0 >> 0 - 0 ^ 0 * 0 / 0 >>> 0 << 0 * 0 - 0 / 0 63 | | 0 * 0 >> 0 + 0 / 0 * 0 - 0 << 0 64 | & 0 * 0 / 0 >>> 0 - 0 * 0 >> 0 / 0 << 0 * 0 + 0 - 0 / 0 * 0 65 | | 0 - 0 * 0 >>> 0 << 0 / 0 * 0 >> 0 - 0 ^ 0 * 0 / 0 & 0 << 0 + 0; 66 | 67 | void f() { 68 | if (0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 69 | + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 70 | == 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 71 | + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0) { 72 | } else if (null instanceof List) { 73 | } else { 74 | } 75 | if (true) {} 76 | } 77 | } 78 | --------------------------------------------------------------------------------