use of spoon.reflect.reference.CtModuleReference in project spoon by INRIA.
the class JDTTreeBuilderHelper method createModuleRequirement.
CtModuleRequirement createModuleRequirement(RequiresStatement requiresStatement) {
int sourceStart = requiresStatement.sourceStart;
int sourceEnd = requiresStatement.sourceEnd;
CtModuleReference ctModuleReference = jdtTreeBuilder.references.getModuleReference(requiresStatement.module);
CtModuleRequirement moduleRequirement = jdtTreeBuilder.getFactory().Module().createModuleRequirement(ctModuleReference);
Set<CtModuleRequirement.RequiresModifier> modifiers = new HashSet<>();
if (requiresStatement.isStatic()) {
modifiers.add(CtModuleRequirement.RequiresModifier.STATIC);
}
if (requiresStatement.isTransitive()) {
modifiers.add(CtModuleRequirement.RequiresModifier.TRANSITIVE);
}
moduleRequirement.setRequiresModifiers(modifiers);
moduleRequirement.setPosition(this.jdtTreeBuilder.getPositionBuilder().buildPosition(sourceStart, sourceEnd));
return moduleRequirement;
}
use of spoon.reflect.reference.CtModuleReference in project spoon by INRIA.
the class JDTTreeBuilderHelper method createModuleExport.
CtPackageExport createModuleExport(ExportsStatement exportsStatement) {
String packageName = new String(exportsStatement.pkgName);
int sourceStart = exportsStatement.sourceStart;
int sourceEnd = exportsStatement.sourceEnd;
CtPackageReference ctPackageReference = jdtTreeBuilder.references.getPackageReference(packageName);
CtPackageExport moduleExport = jdtTreeBuilder.getFactory().Module().createPackageExport(ctPackageReference);
if (exportsStatement.targets != null && exportsStatement.targets.length > 0) {
List<CtModuleReference> moduleReferences = new ArrayList<>();
for (ModuleReference moduleReference : exportsStatement.targets) {
moduleReferences.add(this.jdtTreeBuilder.references.getModuleReference(moduleReference));
}
moduleExport.setTargetExport(moduleReferences);
}
moduleExport.setPosition(this.jdtTreeBuilder.getPositionBuilder().buildPosition(sourceStart, sourceEnd));
return moduleExport;
}
use of spoon.reflect.reference.CtModuleReference in project spoon by INRIA.
the class DefaultJavaPrettyPrinter method visitCtPackageExport.
@Override
public void visitCtPackageExport(CtPackageExport moduleExport) {
if (moduleExport.isOpenedPackage()) {
printer.writeKeyword("opens");
} else {
printer.writeKeyword("exports");
}
printer.writeSpace();
visitCtPackageReference(moduleExport.getPackageReference());
if (!moduleExport.getTargetExport().isEmpty()) {
try (ListPrinter lp = this.elementPrinterHelper.createListPrinter(false, " to", true, false, ",", true, false, null)) {
for (CtModuleReference moduleReference : moduleExport.getTargetExport()) {
lp.printSeparatorIfAppropriate();
scan(moduleReference);
}
}
}
printer.writeSeparator(";").writeln();
}
use of spoon.reflect.reference.CtModuleReference in project spoon by INRIA.
the class DefaultCoreFactory method createModuleReference.
@Override
public CtModuleReference createModuleReference() {
CtModuleReference moduleReference = new CtModuleReferenceImpl();
moduleReference.setFactory(getMainFactory());
return moduleReference;
}
use of spoon.reflect.reference.CtModuleReference in project spoon by INRIA.
the class JDTTreeBuilderHelper method createModuleExport.
CtPackageExport createModuleExport(OpensStatement opensStatement) {
String packageName = new String(opensStatement.pkgName);
int sourceStart = opensStatement.sourceStart;
int sourceEnd = opensStatement.sourceEnd;
CtPackageReference ctPackageReference = jdtTreeBuilder.references.getPackageReference(packageName);
CtPackageExport moduleExport = jdtTreeBuilder.getFactory().Module().createPackageExport(ctPackageReference);
if (opensStatement.targets != null && opensStatement.targets.length > 0) {
List<CtModuleReference> moduleReferences = new ArrayList<>();
for (ModuleReference moduleReference : opensStatement.targets) {
moduleReferences.add(this.jdtTreeBuilder.references.getModuleReference(moduleReference));
}
moduleExport.setTargetExport(moduleReferences);
}
moduleExport.setPosition(this.jdtTreeBuilder.getPositionBuilder().buildPosition(sourceStart, sourceEnd));
return moduleExport;
}
Aggregations