@Override public void visitCompilationUnitDeclaration(CompilationUnitDeclaration node) { lombok.ast.CompilationUnit unit = new lombok.ast.CompilationUnit(); unit.rawPackageDeclaration(toTree(node.currentPackage, FlagKey.IMPORTDECLARATION_IS_PACKAGE)); if (node.javadoc != null) { lombok.ast.PackageDeclaration lombokJavadoc = unit.astPackageDeclaration(); if (lombokJavadoc != null) { lombokJavadoc.rawJavadoc(toTree(node.javadoc)); } } fillList(node.imports, unit.rawImportDeclarations()); TypeDeclaration[] newTypes = null; if (node.types != null && node.types.length > 0 && CharOperation.equals(EcjTreeBuilder.PACKAGE_INFO, node.types[0].name)) { newTypes = new TypeDeclaration[node.types.length - 1]; System.arraycopy(node.types, 1, newTypes, 0, node.types.length - 1); } else { newTypes = node.types; } fillList(newTypes, unit.rawTypeDeclarations()); set(node, unit); }
public Node createCompilationUnit(Node packageDeclaration, List<Node> importDeclarations, List<Node> typeDeclarations) { CompilationUnit unit = new CompilationUnit().rawPackageDeclaration(packageDeclaration); if (importDeclarations != null) for (Node n : importDeclarations) if (n != null) unit.rawImportDeclarations().addToEnd(n); if (typeDeclarations != null) for (Node n : typeDeclarations) if (n != null) unit.rawTypeDeclarations().addToEnd(n); return posify(unit); }
@Override public boolean visitCompilationUnit(CompilationUnit node) { formatter.buildBlock(node); if (node.rawPackageDeclaration() != null) { visit(node.rawPackageDeclaration()); if (!node.rawTypeDeclarations().isEmpty() || !node.rawImportDeclarations().isEmpty()) formatter.verticalSpace(); } visitAll(node.rawImportDeclarations(), "", "", ""); if (!node.rawTypeDeclarations().isEmpty() && !node.rawImportDeclarations().isEmpty()) formatter.verticalSpace(); visitAll(node.rawTypeDeclarations(), "\n", "", ""); formatter.closeBlock(); return true; }
@Override public boolean visitCompilationUnit(CompilationUnit node) { List<JCTree> preamble = toList(JCTree.class, node.astPackageDeclaration()); List<JCTree> imports = toList(JCTree.class, node.astImportDeclarations()); List<JCTree> types = toList(JCTree.class, node.astTypeDeclarations()); int end = node.getPosition().getEnd(); if (node.astPackageDeclaration() != null) start = Math.min(start, node.astPackageDeclaration().getPosition().getStart()); if (!node.astImportDeclarations().isEmpty()) start = Math.min(start, node.rawImportDeclarations().first().getPosition().getStart()); if (!node.astTypeDeclarations().isEmpty()) start = Math.min(start, node.rawTypeDeclarations().first().getPosition().getStart()); if (start == Integer.MAX_VALUE) start = node.getPosition().getStart(); return set(node, setPos(start, end, topLevel));
cud.bits |= ASTNode.HasAllMethodBodies; cud.currentPackage = (ImportReference) toTree(node.astPackageDeclaration()); cud.imports = toArray(ImportReference.class, node.astImportDeclarations()); cud.types = toArray(TypeDeclaration.class, node.astTypeDeclarations()); cud.types = newTypes; lombok.ast.PackageDeclaration pkgDeclaration = node.astPackageDeclaration(); Comment javadoc = pkgDeclaration == null ? null : pkgDeclaration.astJavadoc(); if (javadoc != null) {
private ImportList getImportList(Node n) { ImportList il = new ImportList(); while (n != null) { if (n instanceof CompilationUnit) { CompilationUnit cu = (CompilationUnit) n; PackageDeclaration pkg = cu.astPackageDeclaration(); if (pkg != null) il.stars.add(pkg.getPackageName()); for (ImportDeclaration imp : cu.astImportDeclarations()) { if (imp.astStaticImport()) continue; if (imp.astStarImport()) { String i = imp.asFullyQualifiedName(); i = i.substring(0, i.length() - 2); il.stars.add(i); } else { il.explicits.add(imp.asFullyQualifiedName()); } } } n = n.getParent(); } return il; }
stopAtSelf = false; } else if (n instanceof CompilationUnit) { list = ((CompilationUnit) n).rawTypeDeclarations(); cu = (CompilationUnit) n; stopAtSelf = false; if (wantedPkg.isEmpty()) return cu == null || cu.rawPackageDeclaration() == null;
@Override public boolean visitClassDeclaration(ClassDeclaration node) { String name = node.astName().astValue(); if (mActivities != null && mActivities.contains(mClassFqn) || name.endsWith(ACTIVITY) || node.astExtending() != null && node.astExtending().getTypeName().endsWith(ACTIVITY)) { String packageName = ""; if (node.getParent() instanceof CompilationUnit) { CompilationUnit compilationUnit = (CompilationUnit) node.getParent(); PackageDeclaration packageDeclaration = compilationUnit.astPackageDeclaration(); if (packageDeclaration == null) { // No package declaration: ignore this one return true; } packageName = packageDeclaration.getPackageName(); } mClassFqn = (!packageName.isEmpty() ? (packageName + '.') : "") + name; return false; } return true; // Done: No need to look inside this class }
@Override public boolean visitCompilationUnit(CompilationUnit node) { List<JCTree> preamble = toList(JCTree.class, node.astPackageDeclaration()); List<JCTree> imports = toList(JCTree.class, node.astImportDeclarations()); List<JCTree> types = toList(JCTree.class, node.astTypeDeclarations()); int end = node.getPosition().getEnd(); if (node.astPackageDeclaration() != null) start = Math.min(start, node.astPackageDeclaration().getPosition().getStart()); if (!node.astImportDeclarations().isEmpty()) start = Math.min(start, node.rawImportDeclarations().first().getPosition().getStart()); if (!node.astTypeDeclarations().isEmpty()) start = Math.min(start, node.rawTypeDeclarations().first().getPosition().getStart()); if (start == Integer.MAX_VALUE) start = node.getPosition().getStart(); return set(node, setPos(start, end, topLevel));
cud.bits |= ASTNode.HasAllMethodBodies; cud.currentPackage = (ImportReference) toTree(node.astPackageDeclaration()); cud.imports = toArray(ImportReference.class, node.astImportDeclarations()); cud.types = toArray(TypeDeclaration.class, node.astTypeDeclarations()); cud.types = newTypes; lombok.ast.PackageDeclaration pkgDeclaration = node.astPackageDeclaration(); Comment javadoc = pkgDeclaration == null ? null : pkgDeclaration.astJavadoc(); if (javadoc != null) {
@Override public boolean visitCompilationUnit(CompilationUnit node) { formatter.buildBlock(node); if (node.rawPackageDeclaration() != null) { visit(node.rawPackageDeclaration()); if (!node.rawTypeDeclarations().isEmpty() || !node.rawImportDeclarations().isEmpty()) formatter.verticalSpace(); } visitAll(node.rawImportDeclarations(), "", "", ""); if (!node.rawTypeDeclarations().isEmpty() && !node.rawImportDeclarations().isEmpty()) formatter.verticalSpace(); visitAll(node.rawTypeDeclarations(), "\n", "", ""); formatter.closeBlock(); return true; }
private ImportList getImportList(Node n) { ImportList il = new ImportList(); while (n != null) { if (n instanceof CompilationUnit) { CompilationUnit cu = (CompilationUnit) n; PackageDeclaration pkg = cu.astPackageDeclaration(); if (pkg != null) il.stars.add(pkg.getPackageName()); for (ImportDeclaration imp : cu.astImportDeclarations()) { if (imp.astStaticImport()) continue; if (imp.astStarImport()) { String i = imp.asFullyQualifiedName(); i = i.substring(0, i.length() - 2); il.stars.add(i); } else { il.explicits.add(imp.asFullyQualifiedName()); } } } n = n.getParent(); } return il; }
stopAtSelf = false; } else if (n instanceof CompilationUnit) { list = ((CompilationUnit) n).rawTypeDeclarations(); cu = (CompilationUnit) n; stopAtSelf = false; if (wantedPkg.isEmpty()) return cu == null || cu.rawPackageDeclaration() == null;
public Node createCompilationUnit(Node packageDeclaration, List<Node> importDeclarations, List<Node> typeDeclarations) { CompilationUnit unit = new CompilationUnit().rawPackageDeclaration(packageDeclaration); if (importDeclarations != null) for (Node n : importDeclarations) if (n != null) unit.rawImportDeclarations().addToEnd(n); if (typeDeclarations != null) for (Node n : typeDeclarations) if (n != null) unit.rawTypeDeclarations().addToEnd(n); return posify(unit); }
@Override public boolean visitCompilationUnit(CompilationUnit node) { List<JCTree> preamble = toList(JCTree.class, node.astPackageDeclaration()); List<JCTree> imports = toList(JCTree.class, node.astImportDeclarations()); List<JCTree> types = toList(JCTree.class, node.astTypeDeclarations()); int end = node.getPosition().getEnd(); if (node.astPackageDeclaration() != null) start = Math.min(start, node.astPackageDeclaration().getPosition().getStart()); if (!node.astImportDeclarations().isEmpty()) start = Math.min(start, node.rawImportDeclarations().first().getPosition().getStart()); if (!node.astTypeDeclarations().isEmpty()) start = Math.min(start, node.rawTypeDeclarations().first().getPosition().getStart()); if (start == Integer.MAX_VALUE) start = node.getPosition().getStart(); return set(node, setPos(start, end, topLevel));
cud.bits |= ASTNode.HasAllMethodBodies; cud.currentPackage = (ImportReference) toTree(node.astPackageDeclaration()); cud.imports = toArray(ImportReference.class, node.astImportDeclarations()); cud.types = toArray(TypeDeclaration.class, node.astTypeDeclarations()); cud.types = newTypes; lombok.ast.PackageDeclaration pkgDeclaration = node.astPackageDeclaration(); Comment javadoc = pkgDeclaration == null ? null : pkgDeclaration.astJavadoc(); if (javadoc != null) {
@Override public boolean visitCompilationUnit(CompilationUnit node) { formatter.buildBlock(node); if (node.rawPackageDeclaration() != null) { visit(node.rawPackageDeclaration()); if (!node.rawTypeDeclarations().isEmpty() || !node.rawImportDeclarations().isEmpty()) formatter.verticalSpace(); } visitAll(node.rawImportDeclarations(), "", "", ""); if (!node.rawTypeDeclarations().isEmpty() && !node.rawImportDeclarations().isEmpty()) formatter.verticalSpace(); visitAll(node.rawTypeDeclarations(), "\n", "", ""); formatter.closeBlock(); return true; }
private ImportList getImportList(Node n) { ImportList il = new ImportList(); while (n != null) { if (n instanceof CompilationUnit) { CompilationUnit cu = (CompilationUnit) n; PackageDeclaration pkg = cu.astPackageDeclaration(); if (pkg != null) il.stars.add(pkg.getPackageName()); for (ImportDeclaration imp : cu.astImportDeclarations()) { if (imp.astStaticImport()) continue; if (imp.astStarImport()) { String i = imp.asFullyQualifiedName(); i = i.substring(0, i.length() - 2); il.stars.add(i); } else { il.explicits.add(imp.asFullyQualifiedName()); } } } n = n.getParent(); } return il; }
stopAtSelf = false; } else if (n instanceof CompilationUnit) { list = ((CompilationUnit) n).rawTypeDeclarations(); cu = (CompilationUnit) n; stopAtSelf = false; if (wantedPkg.isEmpty()) return cu == null || cu.rawPackageDeclaration() == null;
public Node createCompilationUnit(Node packageDeclaration, List<Node> importDeclarations, List<Node> typeDeclarations) { CompilationUnit unit = new CompilationUnit().rawPackageDeclaration(packageDeclaration); if (importDeclarations != null) for (Node n : importDeclarations) if (n != null) unit.rawImportDeclarations().addToEnd(n); if (typeDeclarations != null) for (Node n : typeDeclarations) if (n != null) unit.rawTypeDeclarations().addToEnd(n); return posify(unit); }