@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());
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(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; }
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; }
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); }
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; }
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); }
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; }
String pkg = compUnit.getPackage().getName().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 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(); }