use of spoon.reflect.declaration.CtModuleDirective in project spoon by INRIA.
the class CtModuleImpl method setModuleDirectives.
@Override
public <T extends CtModule> T setModuleDirectives(List<CtModuleDirective> moduleDirectives) {
getFactory().getEnvironment().getModelChangeListener().onListDeleteAll(this, CtRole.MODULE_DIRECTIVE, this.moduleDirectives, new ArrayList<>(this.moduleDirectives));
if (moduleDirectives == null || moduleDirectives.isEmpty()) {
this.moduleDirectives = CtElementImpl.emptyList();
return (T) this;
}
if (this.moduleDirectives == CtElementImpl.<CtModuleDirective>emptyList()) {
this.moduleDirectives = new SortedList<>(new CtLineElementComparator());
}
this.moduleDirectives.clear();
for (CtModuleDirective moduleDirective : moduleDirectives) {
this.addModuleDirective(moduleDirective);
}
return (T) this;
}
use of spoon.reflect.declaration.CtModuleDirective in project spoon by INRIA.
the class TestModule method testDirectiveOrders.
@Test
public void testDirectiveOrders() {
// contract: module directive should be ordered the same way as in the original file
final Launcher launcher = new Launcher();
launcher.getEnvironment().setNoClasspath(true);
launcher.getEnvironment().setComplianceLevel(9);
launcher.addInputResource(MODULE_RESOURCES_PATH + "/module_with_comments/module-info.java");
launcher.buildModel();
assertEquals(2, launcher.getModel().getAllModules().size());
CtModule module = launcher.getFactory().Module().getModule("module_with_comments");
assertNotNull(module);
List<CtModuleDirective> moduleDirectives = module.getModuleDirectives();
assertEquals(3, moduleDirectives.size());
assertTrue(moduleDirectives.get(0) instanceof CtModuleRequirement);
assertTrue(moduleDirectives.get(1) instanceof CtProvidedService);
assertTrue(moduleDirectives.get(2) instanceof CtUsedService);
}
use of spoon.reflect.declaration.CtModuleDirective in project spoon by INRIA.
the class DefaultJavaPrettyPrinter method visitCtModule.
@Override
public void visitCtModule(CtModule module) {
enter(module);
if (module.isOpenModule()) {
printer.writeKeyword("open").writeSpace();
}
printer.writeKeyword("module").writeSpace().writeIdentifier(module.getSimpleName());
printer.writeSpace().writeSeparator("{").incTab().writeln();
for (CtModuleDirective moduleDirective : module.getModuleDirectives()) {
scan(moduleDirective);
}
printer.decTab().writeSeparator("}");
exit(module);
}
Aggregations