diff --git a/tools/java/com/google/j2cl/tools/gwtincompatible/GwtIncompatibleStripper.java b/tools/java/com/google/j2cl/tools/gwtincompatible/GwtIncompatibleStripper.java index 4e0791fbdd..1230038174 100644 --- a/tools/java/com/google/j2cl/tools/gwtincompatible/GwtIncompatibleStripper.java +++ b/tools/java/com/google/j2cl/tools/gwtincompatible/GwtIncompatibleStripper.java @@ -15,7 +15,6 @@ import static com.google.common.base.Preconditions.checkState; -import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.io.MoreFiles; @@ -44,7 +43,7 @@ * A helper to comment out source code elements annotated with @GwtIncompatible so that they are * ignored by tools taking that source as input such as the java compile or the j2cl transpile. */ -final class GwtIncompatibleStripper { +public final class GwtIncompatibleStripper { static Problems strip(List files, String outputPath) { try { @@ -74,7 +73,7 @@ private static void preprocessFiles(List fileInfos, Path output, Probl try { String fileContent = MoreFiles.asCharSource(Paths.get(fileInfo.sourcePath()), StandardCharsets.UTF_8).read(); - processedFileContent = processFile(fileContent); + processedFileContent = strip(fileContent); } catch (IOException e) { problems.fatal(FatalError.CANNOT_OPEN_FILE, e.toString()); return; @@ -86,8 +85,7 @@ private static void preprocessFiles(List fileInfos, Path output, Probl } } - @VisibleForTesting - static String processFile(String fileContent) { + public static String strip(String fileContent) { // Avoid parsing if there are no textual references to GwtIncompatible. if (!fileContent.contains("GwtIncompatible")) { return fileContent; diff --git a/tools/javatests/com/google/j2cl/tools/gwtincompatible/GwtIncompatibleStripperTest.java b/tools/javatests/com/google/j2cl/tools/gwtincompatible/GwtIncompatibleStripperTest.java index 537cbe526b..bcb6b970da 100644 --- a/tools/javatests/com/google/j2cl/tools/gwtincompatible/GwtIncompatibleStripperTest.java +++ b/tools/javatests/com/google/j2cl/tools/gwtincompatible/GwtIncompatibleStripperTest.java @@ -30,13 +30,13 @@ public class GwtIncompatibleStripperTest { @Test public void testNoProcess() { String content = "public class Foo {}"; - assertEquals(content, GwtIncompatibleStripper.processFile(content)); + assertEquals(content, GwtIncompatibleStripper.strip(content)); } @Test public void testNoProcessString() { String content = "public class Foo {String a = \"@GwtIncompatible\");}"; - assertEquals(content, GwtIncompatibleStripper.processFile(content)); + assertEquals(content, GwtIncompatibleStripper.strip(content)); } @Test @@ -57,7 +57,7 @@ public void testProcessClass() { Strings.repeat(" ", "public class Foo {".length()), Strings.repeat(" ", " public X m() {return null;}".length()), Strings.repeat(" ", "}".length())); - assertEquals(after, GwtIncompatibleStripper.processFile(before)); + assertEquals(after, GwtIncompatibleStripper.strip(before)); } @Test @@ -84,7 +84,7 @@ public void testProcessMethod() { Strings.repeat(" ", " @GwtIncompatible".length()), Strings.repeat(" ", " public D n() {}".length()), "}"); - assertEquals(after, GwtIncompatibleStripper.processFile(before)); + assertEquals(after, GwtIncompatibleStripper.strip(before)); } @Test @@ -107,7 +107,7 @@ public void testProcessField() { Strings.repeat(" ", " public String b;".length()), " public String c;", "}"); - assertEquals(after, GwtIncompatibleStripper.processFile(before)); + assertEquals(after, GwtIncompatibleStripper.strip(before)); } @Test @@ -148,7 +148,7 @@ public void testProcessMultiple() { Strings.repeat(" ", " }".length()), " String s;", "}"); - assertEquals(after, GwtIncompatibleStripper.processFile(before)); + assertEquals(after, GwtIncompatibleStripper.strip(before)); } @Test @@ -169,7 +169,7 @@ public void testNestedComment() { Strings.repeat(" ", " @GwtIncompatible".length()), Strings.repeat(" ", " public void n() {foo(x /* the value of x */);}".length()), "}"); - assertEquals(after, GwtIncompatibleStripper.processFile(before)); + assertEquals(after, GwtIncompatibleStripper.strip(before)); } @Test @@ -190,7 +190,7 @@ public void testTabs() { Strings.repeat(" ", " @GwtIncompatible".length()), " \t" + Strings.repeat(" ", "public B n() {}".length()), "}"); - assertEquals(after, GwtIncompatibleStripper.processFile(before)); + assertEquals(after, GwtIncompatibleStripper.strip(before)); } @Test @@ -213,6 +213,6 @@ public void testMultibyteChars() { Strings.repeat(" ", " //மெ.பை.".length()), Strings.repeat(" ", " public B n() {}".length()), "}"); - assertEquals(after, GwtIncompatibleStripper.processFile(before)); + assertEquals(after, GwtIncompatibleStripper.strip(before)); } }