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; }
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; }
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; }
@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 }
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) {
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) {
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 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); }
@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); }
@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); }
@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()); 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());
@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()); 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());
@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()); 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());
@Override public void visitTopLevel(JCCompilationUnit node) { CompilationUnit unit = new CompilationUnit(); if (node.pid != null) { PackageDeclaration pkg = new PackageDeclaration(); fillWithIdentifiers(node.pid, pkg.astParts()); unit.astPackageDeclaration(setPos(node.pid, pkg)); fillList(node.packageAnnotations, pkg.rawAnnotations()); } for (JCTree def : node.defs) { if (def instanceof JCImport) { unit.rawImportDeclarations().addToEnd(toTree(def)); } else { unit.rawTypeDeclarations().addToEnd(toTree(def, FlagKey.SKIP_IS_DECL)); } } setConversionStructureInfo(unit, "converted"); set(node, unit); }
@Override public void visitTopLevel(JCCompilationUnit node) { CompilationUnit unit = new CompilationUnit(); if (node.pid != null) { PackageDeclaration pkg = new PackageDeclaration(); fillWithIdentifiers(node.pid, pkg.astParts()); unit.astPackageDeclaration(setPos(node.pid, pkg)); fillList(node.packageAnnotations, pkg.rawAnnotations()); } for (JCTree def : node.defs) { if (def instanceof JCImport) { unit.rawImportDeclarations().addToEnd(toTree(def)); } else { unit.rawTypeDeclarations().addToEnd(toTree(def, FlagKey.SKIP_IS_DECL)); } } setConversionStructureInfo(unit, "converted"); set(node, unit); }
@Override public void visitTopLevel(JCCompilationUnit node) { CompilationUnit unit = new CompilationUnit(); if (node.pid != null) { PackageDeclaration pkg = new PackageDeclaration(); fillWithIdentifiers(node.pid, pkg.astParts()); unit.astPackageDeclaration(setPos(node.pid, pkg)); fillList(node.packageAnnotations, pkg.rawAnnotations()); } for (JCTree def : node.defs) { if (def instanceof JCImport) { unit.rawImportDeclarations().addToEnd(toTree(def)); } else { unit.rawTypeDeclarations().addToEnd(toTree(def, FlagKey.SKIP_IS_DECL)); } } setConversionStructureInfo(unit, "converted"); set(node, unit); }