use of org.eclipse.jdt.internal.compiler.ast.RequiresStatement in project spoon by INRIA.
the class JDTTreeBuilderHelper method createModule.
/**
* Creates an entire object CtModule from a module declaration.
* @return a CtModule
*/
CtModule createModule(ModuleDeclaration moduleDeclaration) {
CtModule module = jdtTreeBuilder.getFactory().Module().getOrCreate(new String(moduleDeclaration.moduleName));
module.setIsOpenModule(moduleDeclaration.isOpen());
jdtTreeBuilder.getContextBuilder().enter(module, moduleDeclaration);
if (moduleDeclaration.requires != null && moduleDeclaration.requires.length > 0) {
List<CtModuleRequirement> moduleRequirements = new ArrayList<>();
for (RequiresStatement requiresStatement : moduleDeclaration.requires) {
moduleRequirements.add(this.createModuleRequirement(requiresStatement));
}
module.setRequiredModules(moduleRequirements);
}
if (moduleDeclaration.exports != null && moduleDeclaration.exports.length > 0) {
List<CtPackageExport> moduleExports = new ArrayList<>();
for (ExportsStatement exportsStatement : moduleDeclaration.exports) {
moduleExports.add(this.createModuleExport(exportsStatement));
}
module.setExportedPackages(moduleExports);
}
if (moduleDeclaration.opens != null && moduleDeclaration.opens.length > 0) {
List<CtPackageExport> moduleOpens = new ArrayList<>();
for (OpensStatement opensStatement : moduleDeclaration.opens) {
moduleOpens.add(this.createModuleExport(opensStatement));
}
module.setOpenedPackages(moduleOpens);
}
if (moduleDeclaration.uses != null && moduleDeclaration.uses.length > 0) {
List<CtUsedService> consumedServices = new ArrayList<>();
for (UsesStatement consumedService : moduleDeclaration.uses) {
consumedServices.add(this.createUsedService(consumedService));
}
module.setUsedServices(consumedServices);
}
if (moduleDeclaration.services != null && moduleDeclaration.services.length > 0) {
List<CtProvidedService> moduleProvidedServices = new ArrayList<>();
for (ProvidesStatement providesStatement : moduleDeclaration.services) {
moduleProvidedServices.add(this.createModuleProvidedService(providesStatement));
}
module.setProvidedServices(moduleProvidedServices);
}
module.setPosition(this.jdtTreeBuilder.getPositionBuilder().buildPosition(moduleDeclaration.declarationSourceStart, moduleDeclaration.declarationSourceEnd));
return module;
}
Aggregations