@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(); }
public PackageDeclaration adapt(Java7Parser.PackageDeclarationContext context, AdapterParameters adapterParameters) { if (context == null) { return null; } PackageDeclaration packageDeclaration = new PackageDeclaration(); AdapterUtil.setComments(packageDeclaration, context, adapterParameters); AdapterUtil.setPosition(packageDeclaration, context); packageDeclaration.setName(Adapters.getQualifiedNameContextAdapter().adapt(context.qualifiedName(), adapterParameters)); if (context.annotations() != null) { packageDeclaration.setAnnotations(Adapters.getAnnotationsContextAdapter().adapt(context.annotations(), adapterParameters)); } return packageDeclaration; } }
public PackageDeclaration adapt(Java7Parser.PackageDeclarationContext context, AdapterParameters adapterParameters) { if (context == null) { return null; } PackageDeclaration packageDeclaration = new PackageDeclaration(); AdapterUtil.setComments(packageDeclaration, context, adapterParameters); AdapterUtil.setPosition(packageDeclaration, context); packageDeclaration.setName(Adapters.getQualifiedNameContextAdapter().adapt(context.qualifiedName(), adapterParameters)); if (context.annotations() != null) { packageDeclaration.setAnnotations(Adapters.getAnnotationsContextAdapter().adapt(context.annotations(), adapterParameters)); } return packageDeclaration; } }