@Override public Node visit(PackageDeclaration _n, Object _arg) { List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg); NameExpr name = cloneNodes(_n.getName(), _arg); Comment comment = cloneNodes(_n.getComment(), _arg); PackageDeclaration r = new PackageDeclaration( _n.getBeginLine(), _n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(), annotations, name ); r.setComment(comment); return r; }
public PackageDeclaration(List<AnnotationExpr> annotations, NameExpr name) { setAnnotations(annotations); setName(name); }
@Override public Boolean visit(final PackageDeclaration n1, final Node arg) { final 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; }
private String packageNameFromCompilationUnit() { PackageDeclaration packageDeclaration = compilationUnit.getPackage(); if (packageDeclaration == null) { throw new IllegalArgumentException("Source file does not declare a package. Default package is unsupported."); } return packageDeclaration.getName().toString(); } }
@Override public Node visit(final PackageDeclaration n, final A arg) { final 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 void visit(final PackageDeclaration n, final A arg) { visitComment(n.getComment(), arg); if (n.getAnnotations() != null) { for (final AnnotationExpr a : n.getAnnotations()) { a.accept(this, arg); } } n.getName().accept(this, arg); }
@Test public void testRemoveAnnotation() throws Exception { CompilerAssert<File, File> helper = incrementalCompiler("metamodel.application"); helper.assertCompile(); // JavaFile pkgFile = helper.assertJavaSource("metamodel.application.package-info"); PackageDeclaration pkg = pkgFile.assertPackage(); pkg.getAnnotations().clear(); pkgFile.assertSave(); // helper.assertCompile(); } }
pkg.getAnnotations().clear(); List<AnnotationExpr> a = Collections.<AnnotationExpr>singletonList(new NormalAnnotationExpr(ASTHelper.createNameExpr( Application.class.getName()), "name", new StringLiteralExpr("abc") )))); pkg.setAnnotations(a); pkgFile.assertSave();
if (jj_2_1(2147483647)) { pakage = PackageDeclaration(); line = pakage.getBeginLine(); column = pakage.getBeginColumn(); } else {
@Override public Node visit(final CompilationUnit n, final A arg) { if (n.getPackage() != null) { n.setPackage((PackageDeclaration) n.getPackage().accept(this, arg)); } final 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); } final 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 PackageDeclaration(NameExpr name) { setName(name); }
final public PackageDeclaration PackageDeclaration() throws ParseException { List annotations = null; AnnotationExpr ann; NameExpr name; int line; int column; label_3: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AT: ; break; default: jj_la1[3] = jj_gen; break label_3; } ann = Annotation(); annotations = add(annotations, ann); } jj_consume_token(PACKAGE); line=token.beginLine; column=token.beginColumn; name = Name(); jj_consume_token(SEMICOLON); {if (true) return new PackageDeclaration(line, column, token.endLine, token.endColumn,annotations, name);} throw new Error("Missing return statement in function"); }
@Override public Void visit(PackageDeclaration n, Visit arg) { ((Visit.CU)arg).pkg = toString(n.getName()); return super.visit(n, arg); }
@Override public R visit(final PackageDeclaration n, final A arg) { if (n.getAnnotations() != null) { for (final AnnotationExpr a : n.getAnnotations()) { { R result = a.accept(this, arg); if (result != null) { return result; } } } } { R result = n.getName().accept(this, arg); if (result != null) { return result; } } return null; }
@Override public void visit(final PackageDeclaration n, final Object arg) { printJavaComment(n.getComment(), arg); printAnnotations(n.getAnnotations(), arg); printer.print("package "); n.getName().accept(this, arg); printer.printLn(";"); printer.printLn(); printOrphanCommentsEnding(n); }
@Test public void testRemoveAnnotation() throws Exception { CompilerAssert<File, File> helper = incrementalCompiler("metamodel.application"); helper.assertCompile(); // JavaFile pkgFile = helper.assertJavaSource("metamodel.application.package-info"); PackageDeclaration pkg = pkgFile.assertPackage(); pkg.getAnnotations().clear(); pkgFile.assertSave(); // helper.assertCompile(); } }
pkg.getAnnotations().clear(); List<AnnotationExpr> a = Collections.<AnnotationExpr>singletonList(new NormalAnnotationExpr(ASTHelper.createNameExpr( Application.class.getName()), "name", new StringLiteralExpr("abc") )))); pkg.setAnnotations(a); pkgFile.assertSave();
if (jj_2_1(2147483647)) { pakage = PackageDeclaration(); line = pakage.getBeginLine(); column = pakage.getBeginColumn(); } else {
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(); } } } }
assertTrue(file.renameTo(tmp)); JavaFile javaFile = helper.assertJavaSource("metamodel.controller.sub.A"); javaFile.assertCompilationUnit().getPackage().setName(ASTHelper.createNameExpr("metamodel.controller.sub")); javaFile.assertSave();