GwtSourceFilter { public boolean elementIsPartOfGwtSource(Element element) { PackageElement packageElement = utils.getElements().getPackageOf(element); String packageName = packageElement.getQualifiedName() + "."; for (String sourcePackage : getSourcePackages()) { if (packageName.startsWith(sourcePackage + ".")) { return true; } } return false; } GwtSourceFilter(
            Logger logger,
            Utils utils,
            String... moduleNames); String getApplicationPackage(); Set<String> getSourcePackages(); Set<E> filterElements(Set<E> elements); boolean elementIsPartOfGwtSource(Element element); void addModules(String[] moduleNames); void addModules(Collection<String> moduleNames); void addModule(String moduleName); static final String GWTP_MODULE_OPTION; }
@Test public void elementIsPartOfGwtSource_notInSource() { GwtSourceFilter filter = new GwtSourceFilter(logger, utils, MODULE1); Element element = createElementStubWithPackage("org.jukito"); boolean result = filter.elementIsPartOfGwtSource(element); assertThat(result).isFalse(); }
@Test public void elementIsPartOfGwtSource_sameSource() { GwtSourceFilter filter = new GwtSourceFilter(logger, utils, MODULE1); Element element = createElementStubWithPackage(MODULE4_SOURCE_PATH); boolean result = filter.elementIsPartOfGwtSource(element); assertThat(result).isTrue(); }
@Test public void elementIsPartOfGwtSource_subPackage() { GwtSourceFilter filter = new GwtSourceFilter(logger, utils, MODULE1); Element element = createElementStubWithPackage(MODULE4_SOURCE_PATH + ".sub.subsub"); boolean result = filter.elementIsPartOfGwtSource(element); assertThat(result).isTrue(); }