public Boolean visit(PackageDeclaration n1, Node arg) { PackageDeclaration n2 = (PackageDeclaration) arg; if (!nodeEquals(n1.getName(), n2.getName())) { return Boolean.FALSE; } if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { return Boolean.FALSE; } return Boolean.TRUE; }
@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 void visit(PackageDeclaration n, Object arg) { printBeginComments(n.getBeginComments(), arg); printAnnotations(n.getAnnotations(), arg); printer.print("package "); n.getName().accept(this, arg); printer.print(";"); printEndComments(n.getEndComments(), arg); printer.printLn(); }
public Node visit(PackageDeclaration n, A arg) { List<AnnotationExpr> annotations = n.getAnnotations(); if (annotations != null) { for (int i = 0; i < annotations.size(); i++) { annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); } removeNulls(annotations); } n.setName((NameExpr) n.getName().accept(this, arg)); return n; }
@Override public final JavaPackage getPackage(final String fileIdentifier) { Validate.notBlank(fileIdentifier, "Compilation unit path required"); Validate.isTrue(new File(fileIdentifier).exists(), "The file doesn't exist"); Validate.isTrue(new File(fileIdentifier).isFile(), "The identifier doesn't represent a file"); try { final File file = new File(fileIdentifier); String typeContents = ""; try { typeContents = FileUtils.readFileToString(file); } catch (final IOException ignored) { } if (StringUtils.isBlank(typeContents)) { return null; } final CompilationUnit compilationUnit = JavaParser.parse(new ByteArrayInputStream(typeContents.getBytes())); if (compilationUnit == null || compilationUnit.getPackage() == null) { return null; } return new JavaPackage(compilationUnit.getPackage().getName().toString()); } catch (final IOException e) { throw new IllegalStateException(e); } catch (final ParseException e) { throw new IllegalStateException("Failed to parse " + fileIdentifier + " : " + e.getMessage()); } } }
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 Node visit(CompilationUnit n, A arg) { if (n.getPackage() != null) { n.setPackage((PackageDeclaration) n.getPackage().accept(this, arg)); } List<ImportDeclaration> imports = n.getImports(); if (imports != null) { for (int i = 0; i < imports.size(); i++) { imports.set(i, (ImportDeclaration) imports.get(i).accept(this, arg)); } removeNulls(imports); } List<TypeDeclaration> types = n.getTypes(); if (types != null) { for (int i = 0; i < types.size(); i++) { types.set(i, (TypeDeclaration) types.get(i).accept(this, arg)); } removeNulls(types); } return n; }
.getPackage().getAnnotations(); for (AnnotationExpr annot : annots) { if (annot instanceof NormalAnnotationExpr) {
public void visit(PackageDeclaration n, Object arg) { printBeginComments(n.getBeginComments(), arg); printAnnotations(n.getAnnotations(), arg); printer.print("package "); n.getName().accept(this, arg); printer.print(";"); printEndComments(n.getEndComments(), arg); printer.printLn(); }
public Node visit(PackageDeclaration n, A arg) { List<AnnotationExpr> annotations = n.getAnnotations(); if (annotations != null) { for (int i = 0; i < annotations.size(); i++) { annotations.set(i, (AnnotationExpr) annotations.get(i).accept(this, arg)); } removeNulls(annotations); } n.setName((NameExpr) n.getName().accept(this, arg)); return n; }
for (final TypeDeclaration typeDeclaration : compilationUnit.getTypes()) { if (typeName.equals(typeDeclaration.getName())) { return new JavaType(compilationUnit.getPackage().getName().getName() + "." + typeDeclaration.getName());
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 Node visit(CompilationUnit n, A arg) { if (n.getPackage() != null) { n.setPackage((PackageDeclaration) n.getPackage().accept(this, arg)); } List<ImportDeclaration> imports = n.getImports(); if (imports != null) { for (int i = 0; i < imports.size(); i++) { imports.set(i, (ImportDeclaration) imports.get(i).accept(this, arg)); } removeNulls(imports); } List<TypeDeclaration> types = n.getTypes(); if (types != null) { for (int i = 0; i < types.size(); i++) { types.set(i, (TypeDeclaration) types.get(i).accept(this, arg)); } removeNulls(types); } return n; }
public Boolean visit(PackageDeclaration n1, Node arg) { PackageDeclaration n2 = (PackageDeclaration) arg; if (!nodeEquals(n1.getName(), n2.getName())) { return Boolean.FALSE; } if (!nodesEquals(n1.getAnnotations(), n2.getAnnotations())) { return Boolean.FALSE; } return Boolean.TRUE; }
public void visit(CompilationUnit n, Object arg) { if (n.getPackage() != null) { n.getPackage().accept(this, arg); } if (n.getImports() != null) { for (ImportDeclaration i : n.getImports()) { i.accept(this, arg); } printer.printLn(); } if (n.getTypes() != null) { for (Iterator<TypeDeclaration> i = n.getTypes().iterator(); i.hasNext();) { i.next().accept(this, arg); printer.printLn(); if (i.hasNext()) { printer.printLn(); } } } }
public void visit(PackageDeclaration n, A arg) { if (n.getAnnotations() != null) { for (AnnotationExpr a : n.getAnnotations()) { a.accept(this, arg); } } n.getName().accept(this, arg); }
EnumDeclaration enumClazz = null; final StringBuilder sb = new StringBuilder(compilationUnit.getPackage().getName().toString()); if (name.getEnclosingType() != null) { sb.append(".").append(name.getEnclosingType().getSimpleTypeName());
public void visit(CompilationUnit n, Object arg) { if (n.getPackage() != null) { n.getPackage().accept(this, arg); } if (n.getImports() != null) { for (ImportDeclaration i : n.getImports()) { i.accept(this, arg); } printer.printLn(); } if (n.getTypes() != null) { for (Iterator<TypeDeclaration> i = n.getTypes().iterator(); i.hasNext();) { i.next().accept(this, arg); printer.printLn(); if (i.hasNext()) { printer.printLn(); } } } }
public R visit(PackageDeclaration n, A arg) { if (n.getAnnotations() != null) { for (AnnotationExpr a : n.getAnnotations()) { a.accept(this, arg); } } n.getName().accept(this, arg); return null; }