/** * Visits a class declaration. * * @param d the declaration to visit */ public void visitClassDeclaration(ClassDeclaration d) { d.accept(pre); SortedSet<Declaration> decls = new TreeSet<Declaration>(SourceOrderDeclScanner.comparator); for (TypeParameterDeclaration tpDecl : d.getFormalTypeParameters()) { decls.add(tpDecl); } for (FieldDeclaration fieldDecl : d.getFields()) { decls.add(fieldDecl); } for (MethodDeclaration methodDecl : d.getMethods()) { decls.add(methodDecl); } for (TypeDeclaration typeDecl : d.getNestedTypes()) { decls.add(typeDecl); } for (ConstructorDeclaration ctorDecl : d.getConstructors()) { decls.add(ctorDecl); } for (Declaration decl : decls) decl.accept(this); d.accept(post); }
@SuppressWarnings("cast") private int compareEqualPosition(Declaration d1, Declaration d2) { assert d1.getPosition() == d2.getPosition(); DeclPartialOrder dpo1 = new DeclPartialOrder(); DeclPartialOrder dpo2 = new DeclPartialOrder(); d1.accept(dpo1); d2.accept(dpo2); int difference = dpo1.getValue() - dpo2.getValue(); if (difference != 0) return difference; else { int result = d1.getSimpleName().compareTo(d2.getSimpleName()); if (result != 0) return result; return (int) (Long.signum((long) System.identityHashCode(d1) - (long) System.identityHashCode(d2))); } }
public void visitExecutableDeclaration(ExecutableDeclaration d) { d.accept(pre); SortedSet<Declaration> decls = new TreeSet<Declaration>(SourceOrderDeclScanner.comparator); for (TypeParameterDeclaration tpDecl : d.getFormalTypeParameters()) decls.add(tpDecl); for (ParameterDeclaration pDecl : d.getParameters()) decls.add(pDecl); for (Declaration decl : decls) decl.accept(this); d.accept(post); }