PackageList { @Nonnull static String removeComment(@Nonnull final String text, final boolean checkQuotes) { int pos = -1; boolean quot = false; boolean found = false; for (int i = 0; i < text.length() && !found; i++) { switch (text.charAt(i)) { case '\"': { quot = !quot; pos = -1; } break; case '/': { if (!checkQuotes || !quot) { if (pos < 0) { pos = i; } else { found = true; } } } break; default: { pos = -1; } break; } } return found ? text.substring(0, pos) : text; } PackageList(@Nonnull @MustNotContainNull final File file, @Nonnull final String text, @Nonnull final ContentProvider contentProvider); @Nonnull @MustNotContainNull List<Package> getPackages();  }
@Test public void testRemoveComment_CheckQuotes_False() { assertEquals("", PackageList.removeComment(" assertEquals("a", PackageList.removeComment("a assertEquals("a", PackageList.removeComment("a assertEquals("a ", PackageList.removeComment("a assertEquals("#include", PackageList.removeComment("#include assertEquals("#include a/b/c", PackageList.removeComment("#include a/b/c assertEquals("#include \"a/b/c", PackageList.removeComment("#include \"a/b/c assertEquals("#include \"a/b/c", PackageList.removeComment("#include \"a/b/c assertEquals("#include \"a/b/c\"", PackageList.removeComment("#include \"a/b/c\" }
@Test public void testRemoveComment_CheckQuotes_True() { assertEquals("", PackageList.removeComment(" assertEquals("a", PackageList.removeComment("a assertEquals("a", PackageList.removeComment("a assertEquals("a ", PackageList.removeComment("a assertEquals("#include", PackageList.removeComment("#include assertEquals("#include a/b/c", PackageList.removeComment("#include a/b/c assertEquals("#include \"a/b/c assertEquals("#include \"a/b/c assertEquals("#include \"a/b/c\"", PackageList.removeComment("#include \"a/b/c\" }