@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()); } } }
for (final TypeDeclaration typeDeclaration : compilationUnit.getTypes()) { if (typeName.equals(typeDeclaration.getName())) { return new JavaType(compilationUnit.getPackage().getName().getName() + "." + typeDeclaration.getName());
if (!compilationUnit.getPackage().getName().getName() .equals(cidCompilationUnit.getPackage().getName().getName())) { compilationUnit.setPackage(cidCompilationUnit.getPackage());
EnumDeclaration enumClazz = null; final StringBuilder sb = new StringBuilder(compilationUnit.getPackage().getName().toString()); if (name.getEnclosingType() != null) { sb.append(".").append(name.getEnclosingType().getSimpleTypeName());
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 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(CompilationUnit n1, Node arg) { CompilationUnit n2 = (CompilationUnit) arg; if (!nodeEquals(n1.getPackage(), n2.getPackage())) { return Boolean.FALSE; } if (!nodesEquals(n1.getImports(), n2.getImports())) { return Boolean.FALSE; } if (!nodesEquals(n1.getTypes(), n2.getTypes())) { return Boolean.FALSE; } return Boolean.TRUE; }
public Boolean visit(CompilationUnit n1, Node arg) { CompilationUnit n2 = (CompilationUnit) arg; if (!nodeEquals(n1.getPackage(), n2.getPackage())) { return Boolean.FALSE; } if (!nodesEquals(n1.getImports(), n2.getImports())) { return Boolean.FALSE; } if (!nodesEquals(n1.getTypes(), n2.getTypes())) { return Boolean.FALSE; } return Boolean.TRUE; }
public void visit(CompilationUnit n, A arg) { if (n.getPackage() != null) { n.getPackage().accept(this, arg); } if (n.getImports() != null) { for (ImportDeclaration i : n.getImports()) { i.accept(this, arg); } } if (n.getTypes() != null) { for (TypeDeclaration typeDeclaration : n.getTypes()) { typeDeclaration.accept(this, arg); } } }
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(CompilationUnit n, A arg) { if (n.getPackage() != null) { n.getPackage().accept(this, arg); } if (n.getImports() != null) { for (ImportDeclaration i : n.getImports()) { i.accept(this, arg); } } if (n.getTypes() != null) { for (TypeDeclaration typeDeclaration : n.getTypes()) { typeDeclaration.accept(this, arg); } } }
public R visit(CompilationUnit n, A arg) { if (n.getPackage() != null) { n.getPackage().accept(this, arg); } if (n.getImports() != null) { for (ImportDeclaration i : n.getImports()) { i.accept(this, arg); } } if (n.getTypes() != null) { for (TypeDeclaration typeDeclaration : n.getTypes()) { typeDeclaration.accept(this, arg); } } return null; }
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(CompilationUnit n, A arg) { if (n.getPackage() != null) { n.getPackage().accept(this, arg); } if (n.getImports() != null) { for (ImportDeclaration i : n.getImports()) { i.accept(this, arg); } } if (n.getTypes() != null) { for (TypeDeclaration typeDeclaration : n.getTypes()) { typeDeclaration.accept(this, arg); } } return null; }
.getPackage().getAnnotations(); for (AnnotationExpr annot : annots) { if (annot instanceof NormalAnnotationExpr) {
String pkg = compUnit.getPackage().getName().toString();
try { compilationUnit = JavaParser.parse(webFaultFile); packageDeclaration = compilationUnit.getPackage(); new JavaPackage(compilationUnit.getPackage() .getName().toString()), javaType, compilationUnit.getImports(),
try { compilationUnit = JavaParser.parse(webServiceFile); packageDeclaration = compilationUnit.getPackage(); new JavaPackage(compilationUnit.getPackage() .getName().toString()), javaType, compilationUnit.getImports(),