Search in sources :

Example 1 with PackageDeclaration

use of com.github.antlrjavaparser.api.PackageDeclaration in project spring-roo by spring-projects.

the class JavaParserTypeParsingService method getCompilationUnitContents.

@Override
public final String getCompilationUnitContents(final ClassOrInterfaceTypeDetails cid) {
    Validate.notNull(cid, "Class or interface type details are required");
    // Create a compilation unit to store the type to be created
    final CompilationUnit compilationUnit = new CompilationUnit();
    // NB: this import list is replaced at the end of this method by a
    // sorted version
    compilationUnit.setImports(new ArrayList<ImportDeclaration>());
    if (!cid.getName().isDefaultPackage()) {
        compilationUnit.setPackage(new PackageDeclaration(ASTHelper.createNameExpr(cid.getName().getPackage().getFullyQualifiedPackageName())));
    }
    // Add the class of interface declaration to the compilation unit
    final List<TypeDeclaration> types = new ArrayList<TypeDeclaration>();
    compilationUnit.setTypes(types);
    updateOutput(compilationUnit, null, cid, null);
    return compilationUnit.toString();
}
Also used : CompilationUnit(com.github.antlrjavaparser.api.CompilationUnit) ImportDeclaration(com.github.antlrjavaparser.api.ImportDeclaration) ArrayList(java.util.ArrayList) TypeDeclaration(com.github.antlrjavaparser.api.body.TypeDeclaration) PackageDeclaration(com.github.antlrjavaparser.api.PackageDeclaration)

Aggregations

CompilationUnit (com.github.antlrjavaparser.api.CompilationUnit)1 ImportDeclaration (com.github.antlrjavaparser.api.ImportDeclaration)1 PackageDeclaration (com.github.antlrjavaparser.api.PackageDeclaration)1 TypeDeclaration (com.github.antlrjavaparser.api.body.TypeDeclaration)1 ArrayList (java.util.ArrayList)1