import java.util.Collection; import java.util.Map; aspect Locking { public ASTNode ASTNode.lockNames(String... endangered) { return lockNames(Arrays.asList(endangered)); } public ASTNode ASTNode.lockNames(Collection endangered) { for(int i=0;i endangered) { if(isLocked()) { // skip over type access for(int i=1;i endangered) { for(int i=0;i endangered) { for(int i=0;i constructorSigs = new HashSet(), methodSigs = new HashSet(), fieldNames = new HashSet(), typeNames = new HashSet(); for(BodyDecl bd : getBodyDecls()) { if(bd instanceof ConstructorDecl) { ConstructorDecl cd = (ConstructorDecl)bd; if(constructorSigs.contains(cd.signature())) throw new RefactoringException("two or more constructors with same signature"); constructorSigs.add(cd.signature()); } else if(bd instanceof MethodDecl) { MethodDecl md = (MethodDecl)bd; if(methodSigs.contains(md.signature())) throw new RefactoringException("two or more methods with same signature"); methodSigs.add(md.signature()); } else if(bd instanceof FieldDeclaration) { FieldDeclaration fd = (FieldDeclaration)bd; if(fieldNames.contains(fd.name())) throw new RefactoringException("two or more fields with same name"); fieldNames.add(fd.name()); } if(bd instanceof MemberTypeDecl) { TypeDecl td = ((MemberTypeDecl)bd).typeDecl(); if(typeNames.contains(td.name())) throw new RefactoringException("two or more member types with the same name"); typeNames.add(td.name()); } } } super.checkNamingConstraints(); } // locked copy of a subtree public ASTNode ASTNode.lockedCopy() { ASTNode res = (ASTNode)copy(); for(int i=0;i