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 Void visit(PackageDeclaration n, Visit arg) { ((Visit.CU)arg).pkg = toString(n.getName()); return super.visit(n, arg); }
@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; }
@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(PackageDeclaration n, Object arg) { if (pack == null) { pack = new CGEntry(CGEntry.TYPE.PACKAGE, null, null, n.getName().toString()); if (isDebug()) System.out.println("P:" + pack); list.add(pack); } super.visit(n, arg); }
final String enclosingName = n.getPackage().getName() + "." + n.getTypes().get(0).getName();
public void build() { UnitChromatticVisitor unitChromatticVisitor = new UnitChromatticVisitor(); compilationUnit.getPackage().getName().setName(compilationUnit.getPackage().getName().getName() + ".groovy"); unitChromatticVisitor.visit(compilationUnit, null); sb.append(compilationUnit.toString(new GroovyCompatibilityFactory())); }
@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 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); }
public void visit(PackageDeclaration n, Object arg) { printAnnotations(n.getAnnotations(), arg); printer.print("package "); n.getName().accept(this, arg); printer.printLn(";"); printer.printLn(); }
@Override public final NodeData resolve(Node node, String mappedClass) { if (!(node instanceof FieldDeclaration)) { throw new IllegalArgumentException("this annotation belongs only on FieldDeclaration"); } final FieldDeclaration field = (FieldDeclaration) node; if (ResolverUtil.canFieldBeAnnotated(field)) { final TypeDeclaration dclr = (TypeDeclaration) node.getParentNode(); final String name = dclr.getName(); final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString(); final String fullyQualifiedClass = pckg + "." + name; final boolean mappedColumn = OjbUtil.isMappedColumn(mappedClass, ParserUtil.getFieldName(field), descriptorRepositories); if (mappedColumn) { return getAnnotationNodes(fullyQualifiedClass, ParserUtil.getFieldName(field), mappedClass); } } 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); }
@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; }
@Override public NodeData resolve(Node node, String mappedClass) { if (!(node instanceof ClassOrInterfaceDeclaration)) { throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration"); } final TypeDeclaration dclr = (TypeDeclaration) node; if (!(dclr.getParentNode() instanceof CompilationUnit)) { //handling nested classes return null; } final String name = dclr.getName(); final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString(); final String enclosingClass = pckg + "." + name; final Collection<String> customizedFieldsOnNode = getFieldsOnNode(dclr, getCustomizedFields(mappedClass)); if (customizedFieldsOnNode == null || customizedFieldsOnNode.isEmpty()) { LOG.info(ResolverUtil.logMsgForClass(enclosingClass, mappedClass) + " has no customized fields"); return null; } return new NodeData(new SingleMemberAnnotationExpr(new NameExpr(SIMPLE_NAME), new NameExpr("CreateCustomizerFor" + customizedFieldsOnNode.toString())), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false)); }
@Override public NodeData resolve(Node node, String mappedClass) { if (!(node instanceof ClassOrInterfaceDeclaration)) { throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration"); } final TypeDeclaration dclr = (TypeDeclaration) node; if (!(dclr.getParentNode() instanceof CompilationUnit)) { //handling nested classes return null; } final String name = dclr.getName(); final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString(); final String enclosingClass = pckg + "." + name; if (!enclosingClass.equals(mappedClass)) { return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false)); } return null; } }
@Override public NodeData resolve(Node node, String mappedClass) { if (!(node instanceof ClassOrInterfaceDeclaration)) { throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration"); } final TypeDeclaration dclr = (TypeDeclaration) node; if (!(dclr.getParentNode() instanceof CompilationUnit)) { //handling nested classes return null; } final String name = dclr.getName(); final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString(); final String enclosingClass = pckg + "." + name; final ClassDescriptor cd = OjbUtil.findClassDescriptor(enclosingClass, descriptorRepositories); if (cd != null) { final String tableName = getMappedTable(enclosingClass); if (tableName == null) { LOG.error(ResolverUtil.logMsgForClass(enclosingClass, mappedClass) + " table could not be found"); return null; } return new NodeData(new NormalAnnotationExpr(new NameExpr(SIMPLE_NAME), Collections.singletonList(new MemberValuePair("name", new StringLiteralExpr(upperCaseTableName ? tableName.toUpperCase() : tableName)))), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false)); } return null; }
@Override public NodeData resolve(Node node, String mappedClass) { if (!(node instanceof ClassOrInterfaceDeclaration)) { throw new IllegalArgumentException("this annotation belongs only on ClassOrInterfaceDeclaration"); } final TypeDeclaration dclr = (TypeDeclaration) node; if (!(dclr.getParentNode() instanceof CompilationUnit)) { //handling nested classes return null; } final String name = dclr.getName(); final String pckg = ((CompilationUnit) dclr.getParentNode()).getPackage().getName().toString(); final String enclosingClass = pckg + "." + name; final ClassDescriptor cd = OjbUtil.findClassDescriptor(enclosingClass, descriptorRepositories); if (cd != null) { return new NodeData(new MarkerAnnotationExpr(new NameExpr(SIMPLE_NAME)), new ImportDeclaration(new QualifiedNameExpr(new NameExpr(PACKAGE), SIMPLE_NAME), false, false)); } return null; } }