Search in sources :

Example 1 with ModuleReference

use of org.eclipse.jdt.internal.compiler.ast.ModuleReference 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;
}
Also used : CtPackageExport(spoon.reflect.declaration.CtPackageExport) CtPackageReference(spoon.reflect.reference.CtPackageReference) ModuleReference(org.eclipse.jdt.internal.compiler.ast.ModuleReference) CtModuleReference(spoon.reflect.reference.CtModuleReference) CtModuleReference(spoon.reflect.reference.CtModuleReference) ArrayList(java.util.ArrayList)

Example 2 with ModuleReference

use of org.eclipse.jdt.internal.compiler.ast.ModuleReference 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;
}
Also used : CtPackageExport(spoon.reflect.declaration.CtPackageExport) CtPackageReference(spoon.reflect.reference.CtPackageReference) ModuleReference(org.eclipse.jdt.internal.compiler.ast.ModuleReference) CtModuleReference(spoon.reflect.reference.CtModuleReference) CtModuleReference(spoon.reflect.reference.CtModuleReference) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 ModuleReference (org.eclipse.jdt.internal.compiler.ast.ModuleReference)2 CtPackageExport (spoon.reflect.declaration.CtPackageExport)2 CtModuleReference (spoon.reflect.reference.CtModuleReference)2 CtPackageReference (spoon.reflect.reference.CtPackageReference)2