diff --git a/src/main/java/spoon/generating/CloneVisitorGenerator.java b/src/main/java/spoon/generating/CloneVisitorGenerator.java index 109fff93bcb..537c81116f5 100644 --- a/src/main/java/spoon/generating/CloneVisitorGenerator.java +++ b/src/main/java/spoon/generating/CloneVisitorGenerator.java @@ -99,7 +99,7 @@ public void visitCtMethod(CtMethod element) { // Changes body of the cloned method. for (int i = 1; i < clone.getBody().getStatements().size() - 1; i++) { - final CtInvocation targetInvocation = (CtInvocation) ((CtInvocation) clone.getBody().getStatement(i)).getArguments().get(0); + final CtInvocation targetInvocation = (CtInvocation) ((CtInvocation) clone.getBody().getStatement(i)).getArguments().get(1); if ("getValue".equals(targetInvocation.getExecutable().getSimpleName()) && "CtLiteral".equals(targetInvocation.getExecutable().getDeclaringType().getSimpleName())) { clone.getBody().getStatement(i--).delete(); continue; @@ -134,7 +134,7 @@ public void visitCtMethod(CtMethod element) { * @param elementVarRead anElement. */ private CtInvocation createSetter(CtInvocation scanInvocation, CtVariableAccess elementVarRead) { - final CtInvocation getter = (CtInvocation) scanInvocation.getArguments().get(0); + final CtInvocation getter = (CtInvocation) scanInvocation.getArguments().get(1); final String getterName = getter.getExecutable().getSimpleName(); final CtExecutableReference setterRef = factory.Executable().createReference("void CtElement#set" + getterName.substring(3, getterName.length()) + "()"); final CtExecutableReference cloneRef = factory.Executable().createReference("CtElement spoon.support.visitor.equals.CloneHelper#clone()"); diff --git a/src/main/java/spoon/generating/CtBiScannerGenerator.java b/src/main/java/spoon/generating/CtBiScannerGenerator.java index cd483c2302c..c8f4b741d48 100644 --- a/src/main/java/spoon/generating/CtBiScannerGenerator.java +++ b/src/main/java/spoon/generating/CtBiScannerGenerator.java @@ -69,7 +69,7 @@ public void process() { clone.getBody().insertBegin(peek); for (int i = 2; i < clone.getBody().getStatements().size() - 1; i++) { - final CtInvocation targetInvocation = (CtInvocation) ((CtInvocation) clone.getBody().getStatement(i)).getArguments().get(0); + final CtInvocation targetInvocation = (CtInvocation) ((CtInvocation) clone.getBody().getStatement(i)).getArguments().get(1); if ("getValue".equals(targetInvocation.getExecutable().getSimpleName()) && "CtLiteral".equals(targetInvocation.getExecutable().getDeclaringType().getSimpleName())) { clone.getBody().getStatement(i--).delete(); continue; @@ -81,12 +81,12 @@ public void process() { // Creates other inv. final CtVariableAccess otherRead = factory.Code().createVariableRead(peek.getReference(), false); - replace.addArgument(factory.Code().createInvocation(otherRead, ((CtInvocation) replace.getArguments().get(0)).getExecutable())); + replace.addArgument(factory.Code().createInvocation(otherRead, ((CtInvocation) replace.getArguments().get(1)).getExecutable())); if ("Map".equals(targetInvocation.getExecutable().getType().getSimpleName())) { - ((CtExpression) replace.getArguments().get(0)).replace(factory.Code().createInvocation(targetInvocation, factory.Executable().createReference("List Map#values()"))); - CtInvocation invocation = factory.Code().createInvocation(replace.getArguments().get(1).clone(), factory.Executable().createReference("List Map#values()")); - replace.getArguments().get(1).replace(invocation); + ((CtExpression) replace.getArguments().get(1)).replace(factory.Code().createInvocation(targetInvocation, factory.Executable().createReference("List Map#values()"))); + CtInvocation invocation = factory.Code().createInvocation(replace.getArguments().get(2).clone(), factory.Executable().createReference("List Map#values()")); + replace.getArguments().get(2).replace(invocation); } clone.getBody().getStatement(i).replace(replace); diff --git a/src/main/java/spoon/generating/replace/ReplaceScanner.java b/src/main/java/spoon/generating/replace/ReplaceScanner.java index 10de5bad1e1..65df71510aa 100644 --- a/src/main/java/spoon/generating/replace/ReplaceScanner.java +++ b/src/main/java/spoon/generating/replace/ReplaceScanner.java @@ -42,6 +42,7 @@ import spoon.reflect.visitor.CtScanner; import spoon.reflect.visitor.filter.TypeFilter; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -81,7 +82,10 @@ public void visitCtMethod(CtMethod element) { clone.getBody().getStatements().clear(); for (int i = 1; i < element.getBody().getStatements().size() - 1; i++) { CtInvocation inv = element.getBody().getStatement(i); - CtInvocation getter = (CtInvocation) inv.getArguments().get(0); + List> invArgs = new ArrayList<>(inv.getArguments()); + //remove role argument + invArgs.remove(0); + CtInvocation getter = (CtInvocation) invArgs.get(0); if (clone.getComments().size() == 0) { // Add auto-generated comment. @@ -91,26 +95,26 @@ public void visitCtMethod(CtMethod element) { clone.addComment(comment); } Class actualClass = getter.getType().getActualClass(); - CtInvocation invocation = createInvocation(factory, element, inv, getter, actualClass); + CtInvocation invocation = createInvocation(factory, element, invArgs, getter, actualClass); clone.getBody().addStatement(invocation); } target.addMethod(clone); } - private CtInvocation createInvocation(Factory factory, CtMethod candidate, CtInvocation current, CtInvocation getter, Class getterTypeClass) { + private CtInvocation createInvocation(Factory factory, CtMethod candidate, List> invArgs, CtInvocation getter, Class getterTypeClass) { CtInvocation invocation; Type type; if (getterTypeClass.equals(Collection.class) || getterTypeClass.equals(List.class)) { - invocation = factory.Code().createInvocation(null, this.list, current.getArguments()); + invocation = factory.Code().createInvocation(null, this.list, invArgs); type = Type.LIST; } else if (getterTypeClass.equals(Map.class)) { - invocation = factory.Code().createInvocation(null, this.map, current.getArguments()); + invocation = factory.Code().createInvocation(null, this.map, invArgs); type = Type.MAP; } else if (getterTypeClass.equals(Set.class)) { - invocation = factory.Code().createInvocation(null, this.set, current.getArguments()); + invocation = factory.Code().createInvocation(null, this.set, invArgs); type = Type.SET; } else { - invocation = factory.Code().createInvocation(null, this.element, current.getArguments()); + invocation = factory.Code().createInvocation(null, this.element, invArgs); type = Type.ELEMENT; } // Listener diff --git a/src/main/java/spoon/reflect/visitor/CtAbstractBiScanner.java b/src/main/java/spoon/reflect/visitor/CtAbstractBiScanner.java index e4104c51bae..b310f47968b 100644 --- a/src/main/java/spoon/reflect/visitor/CtAbstractBiScanner.java +++ b/src/main/java/spoon/reflect/visitor/CtAbstractBiScanner.java @@ -17,6 +17,7 @@ package spoon.reflect.visitor; import spoon.reflect.declaration.CtElement; +import spoon.reflect.path.CtRole; import java.util.ArrayDeque; import java.util.Collection; @@ -38,6 +39,9 @@ protected void exit(CtElement e) { protected boolean isNotEqual = false; public boolean biScan(Collection elements, Collection others) { + return biScan(null, elements, others); + } + public boolean biScan(CtRole role, Collection elements, Collection others) { if (isNotEqual) { return isNotEqual; } @@ -53,11 +57,14 @@ public boolean biScan(Collection elements, Collection firstIt = elements.iterator(), secondIt = others.iterator(); (firstIt.hasNext()) && (secondIt.hasNext());) { - biScan(firstIt.next(), secondIt.next()); + biScan(role, firstIt.next(), secondIt.next()); } return isNotEqual; } + public boolean biScan(CtRole role, CtElement element, CtElement other) { + return biScan(element, other); + } public boolean biScan(CtElement element, CtElement other) { if (isNotEqual) { return isNotEqual; diff --git a/src/main/java/spoon/reflect/visitor/CtBiScannerDefault.java b/src/main/java/spoon/reflect/visitor/CtBiScannerDefault.java index 1571ee403fd..57c49968e87 100644 --- a/src/main/java/spoon/reflect/visitor/CtBiScannerDefault.java +++ b/src/main/java/spoon/reflect/visitor/CtBiScannerDefault.java @@ -33,11 +33,11 @@ public abstract class CtBiScannerDefault extends spoon.reflect.visitor.CtAbstrac public void visitCtAnnotation(final spoon.reflect.declaration.CtAnnotation annotation) { spoon.reflect.declaration.CtAnnotation other = ((spoon.reflect.declaration.CtAnnotation) (this.stack.peek())); enter(annotation); - biScan(annotation.getType(), other.getType()); - biScan(annotation.getComments(), other.getComments()); - biScan(annotation.getAnnotationType(), other.getAnnotationType()); - biScan(annotation.getAnnotations(), other.getAnnotations()); - biScan(annotation.getValues().values(), other.getValues().values()); + biScan(spoon.reflect.path.CtRole.TYPE, annotation.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.COMMENT, annotation.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION_TYPE, annotation.getAnnotationType(), other.getAnnotationType()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, annotation.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.VALUE, annotation.getValues().values(), other.getValues().values()); exit(annotation); } @@ -45,9 +45,9 @@ public void visitCtAnnotation(final public void visitCtAnnotationType(final spoon.reflect.declaration.CtAnnotationType annotationType) { spoon.reflect.declaration.CtAnnotationType other = ((spoon.reflect.declaration.CtAnnotationType) (this.stack.peek())); enter(annotationType); - biScan(annotationType.getAnnotations(), other.getAnnotations()); - biScan(annotationType.getTypeMembers(), other.getTypeMembers()); - biScan(annotationType.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, annotationType.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE_MEMBER, annotationType.getTypeMembers(), other.getTypeMembers()); + biScan(spoon.reflect.path.CtRole.COMMENT, annotationType.getComments(), other.getComments()); exit(annotationType); } @@ -55,9 +55,9 @@ public void visitCtAnnotationType(fi public void visitCtAnonymousExecutable(final spoon.reflect.declaration.CtAnonymousExecutable anonymousExec) { spoon.reflect.declaration.CtAnonymousExecutable other = ((spoon.reflect.declaration.CtAnonymousExecutable) (this.stack.peek())); enter(anonymousExec); - biScan(anonymousExec.getAnnotations(), other.getAnnotations()); - biScan(anonymousExec.getBody(), other.getBody()); - biScan(anonymousExec.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, anonymousExec.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.BODY, anonymousExec.getBody(), other.getBody()); + biScan(spoon.reflect.path.CtRole.COMMENT, anonymousExec.getComments(), other.getComments()); exit(anonymousExec); } @@ -66,12 +66,12 @@ public void visitCtAnonymousExecutable(final spoon.reflect.declaration.CtAnonymo public void visitCtArrayRead(final spoon.reflect.code.CtArrayRead arrayRead) { spoon.reflect.code.CtArrayRead other = ((spoon.reflect.code.CtArrayRead) (this.stack.peek())); enter(arrayRead); - biScan(arrayRead.getAnnotations(), other.getAnnotations()); - biScan(arrayRead.getType(), other.getType()); - biScan(arrayRead.getTypeCasts(), other.getTypeCasts()); - biScan(arrayRead.getTarget(), other.getTarget()); - biScan(arrayRead.getIndexExpression(), other.getIndexExpression()); - biScan(arrayRead.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, arrayRead.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, arrayRead.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.CAST, arrayRead.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.TARGET, arrayRead.getTarget(), other.getTarget()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, arrayRead.getIndexExpression(), other.getIndexExpression()); + biScan(spoon.reflect.path.CtRole.COMMENT, arrayRead.getComments(), other.getComments()); exit(arrayRead); } @@ -80,12 +80,12 @@ public void visitCtArrayRead(final spoon.reflect.code.CtArrayRead arrayRe public void visitCtArrayWrite(final spoon.reflect.code.CtArrayWrite arrayWrite) { spoon.reflect.code.CtArrayWrite other = ((spoon.reflect.code.CtArrayWrite) (this.stack.peek())); enter(arrayWrite); - biScan(arrayWrite.getAnnotations(), other.getAnnotations()); - biScan(arrayWrite.getType(), other.getType()); - biScan(arrayWrite.getTypeCasts(), other.getTypeCasts()); - biScan(arrayWrite.getTarget(), other.getTarget()); - biScan(arrayWrite.getIndexExpression(), other.getIndexExpression()); - biScan(arrayWrite.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, arrayWrite.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, arrayWrite.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.CAST, arrayWrite.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.TARGET, arrayWrite.getTarget(), other.getTarget()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, arrayWrite.getIndexExpression(), other.getIndexExpression()); + biScan(spoon.reflect.path.CtRole.COMMENT, arrayWrite.getComments(), other.getComments()); exit(arrayWrite); } @@ -93,12 +93,12 @@ public void visitCtArrayWrite(final spoon.reflect.code.CtArrayWrite array public void visitCtArrayTypeReference(final spoon.reflect.reference.CtArrayTypeReference reference) { spoon.reflect.reference.CtArrayTypeReference other = ((spoon.reflect.reference.CtArrayTypeReference) (this.stack.peek())); enter(reference); - biScan(reference.getComments(), other.getComments()); - biScan(reference.getPackage(), other.getPackage()); - biScan(reference.getDeclaringType(), other.getDeclaringType()); - biScan(reference.getComponentType(), other.getComponentType()); - biScan(reference.getActualTypeArguments(), other.getActualTypeArguments()); - biScan(reference.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.COMMENT, reference.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.PACKAGE_REF, reference.getPackage(), other.getPackage()); + biScan(spoon.reflect.path.CtRole.DECLARING_TYPE, reference.getDeclaringType(), other.getDeclaringType()); + biScan(spoon.reflect.path.CtRole.TYPE, reference.getComponentType(), other.getComponentType()); + biScan(spoon.reflect.path.CtRole.TYPE_ARGUMENT, reference.getActualTypeArguments(), other.getActualTypeArguments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, reference.getAnnotations(), other.getAnnotations()); exit(reference); } @@ -106,10 +106,10 @@ public void visitCtArrayTypeReference(final spoon.reflect.reference.CtArrayT public void visitCtAssert(final spoon.reflect.code.CtAssert asserted) { spoon.reflect.code.CtAssert other = ((spoon.reflect.code.CtAssert) (this.stack.peek())); enter(asserted); - biScan(asserted.getAnnotations(), other.getAnnotations()); - biScan(asserted.getAssertExpression(), other.getAssertExpression()); - biScan(asserted.getExpression(), other.getExpression()); - biScan(asserted.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, asserted.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.CONDITION, asserted.getAssertExpression(), other.getAssertExpression()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, asserted.getExpression(), other.getExpression()); + biScan(spoon.reflect.path.CtRole.COMMENT, asserted.getComments(), other.getComments()); exit(asserted); } @@ -117,12 +117,12 @@ public void visitCtAssert(final spoon.reflect.code.CtAssert asserted) { public void visitCtAssignment(final spoon.reflect.code.CtAssignment assignement) { spoon.reflect.code.CtAssignment other = ((spoon.reflect.code.CtAssignment) (this.stack.peek())); enter(assignement); - biScan(assignement.getAnnotations(), other.getAnnotations()); - biScan(assignement.getType(), other.getType()); - biScan(assignement.getTypeCasts(), other.getTypeCasts()); - biScan(assignement.getAssigned(), other.getAssigned()); - biScan(assignement.getAssignment(), other.getAssignment()); - biScan(assignement.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, assignement.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, assignement.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.CAST, assignement.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.ASSIGNED, assignement.getAssigned(), other.getAssigned()); + biScan(spoon.reflect.path.CtRole.ASSIGNMENT, assignement.getAssignment(), other.getAssignment()); + biScan(spoon.reflect.path.CtRole.COMMENT, assignement.getComments(), other.getComments()); exit(assignement); } @@ -130,12 +130,12 @@ public void visitCtAssignment(final spoon.reflect.code.CtAssign public void visitCtBinaryOperator(final spoon.reflect.code.CtBinaryOperator operator) { spoon.reflect.code.CtBinaryOperator other = ((spoon.reflect.code.CtBinaryOperator) (this.stack.peek())); enter(operator); - biScan(operator.getAnnotations(), other.getAnnotations()); - biScan(operator.getType(), other.getType()); - biScan(operator.getTypeCasts(), other.getTypeCasts()); - biScan(operator.getLeftHandOperand(), other.getLeftHandOperand()); - biScan(operator.getRightHandOperand(), other.getRightHandOperand()); - biScan(operator.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, operator.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, operator.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.CAST, operator.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.LEFT_OPERAND, operator.getLeftHandOperand(), other.getLeftHandOperand()); + biScan(spoon.reflect.path.CtRole.RIGHT_OPERAND, operator.getRightHandOperand(), other.getRightHandOperand()); + biScan(spoon.reflect.path.CtRole.COMMENT, operator.getComments(), other.getComments()); exit(operator); } @@ -143,9 +143,9 @@ public void visitCtBinaryOperator(final spoon.reflect.code.CtBinaryOperator< public void visitCtBlock(final spoon.reflect.code.CtBlock block) { spoon.reflect.code.CtBlock other = ((spoon.reflect.code.CtBlock) (this.stack.peek())); enter(block); - biScan(block.getAnnotations(), other.getAnnotations()); - biScan(block.getStatements(), other.getStatements()); - biScan(block.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, block.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.STATEMENT, block.getStatements(), other.getStatements()); + biScan(spoon.reflect.path.CtRole.COMMENT, block.getComments(), other.getComments()); exit(block); } @@ -153,8 +153,8 @@ public void visitCtBlock(final spoon.reflect.code.CtBlock block) { public void visitCtBreak(final spoon.reflect.code.CtBreak breakStatement) { spoon.reflect.code.CtBreak other = ((spoon.reflect.code.CtBreak) (this.stack.peek())); enter(breakStatement); - biScan(breakStatement.getAnnotations(), other.getAnnotations()); - biScan(breakStatement.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, breakStatement.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.COMMENT, breakStatement.getComments(), other.getComments()); exit(breakStatement); } @@ -162,10 +162,10 @@ public void visitCtBreak(final spoon.reflect.code.CtBreak breakStatement) { public void visitCtCase(final spoon.reflect.code.CtCase caseStatement) { spoon.reflect.code.CtCase other = ((spoon.reflect.code.CtCase) (this.stack.peek())); enter(caseStatement); - biScan(caseStatement.getAnnotations(), other.getAnnotations()); - biScan(caseStatement.getCaseExpression(), other.getCaseExpression()); - biScan(caseStatement.getStatements(), other.getStatements()); - biScan(caseStatement.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, caseStatement.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, caseStatement.getCaseExpression(), other.getCaseExpression()); + biScan(spoon.reflect.path.CtRole.STATEMENT, caseStatement.getStatements(), other.getStatements()); + biScan(spoon.reflect.path.CtRole.COMMENT, caseStatement.getComments(), other.getComments()); exit(caseStatement); } @@ -173,10 +173,10 @@ public void visitCtCase(final spoon.reflect.code.CtCase caseStatement) { public void visitCtCatch(final spoon.reflect.code.CtCatch catchBlock) { spoon.reflect.code.CtCatch other = ((spoon.reflect.code.CtCatch) (this.stack.peek())); enter(catchBlock); - biScan(catchBlock.getAnnotations(), other.getAnnotations()); - biScan(catchBlock.getParameter(), other.getParameter()); - biScan(catchBlock.getBody(), other.getBody()); - biScan(catchBlock.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, catchBlock.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.PARAMETER, catchBlock.getParameter(), other.getParameter()); + biScan(spoon.reflect.path.CtRole.BODY, catchBlock.getBody(), other.getBody()); + biScan(spoon.reflect.path.CtRole.COMMENT, catchBlock.getComments(), other.getComments()); exit(catchBlock); } @@ -184,12 +184,12 @@ public void visitCtCatch(final spoon.reflect.code.CtCatch catchBlock) { public void visitCtClass(final spoon.reflect.declaration.CtClass ctClass) { spoon.reflect.declaration.CtClass other = ((spoon.reflect.declaration.CtClass) (this.stack.peek())); enter(ctClass); - biScan(ctClass.getAnnotations(), other.getAnnotations()); - biScan(ctClass.getSuperclass(), other.getSuperclass()); - biScan(ctClass.getSuperInterfaces(), other.getSuperInterfaces()); - biScan(ctClass.getFormalCtTypeParameters(), other.getFormalCtTypeParameters()); - biScan(ctClass.getTypeMembers(), other.getTypeMembers()); - biScan(ctClass.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, ctClass.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.SUPER_TYPE, ctClass.getSuperclass(), other.getSuperclass()); + biScan(spoon.reflect.path.CtRole.INTERFACE, ctClass.getSuperInterfaces(), other.getSuperInterfaces()); + biScan(spoon.reflect.path.CtRole.TYPE_PARAMETER, ctClass.getFormalCtTypeParameters(), other.getFormalCtTypeParameters()); + biScan(spoon.reflect.path.CtRole.TYPE_MEMBER, ctClass.getTypeMembers(), other.getTypeMembers()); + biScan(spoon.reflect.path.CtRole.COMMENT, ctClass.getComments(), other.getComments()); exit(ctClass); } @@ -198,9 +198,9 @@ public void visitCtClass(final spoon.reflect.declaration.CtClass ctClass) public void visitCtTypeParameter(spoon.reflect.declaration.CtTypeParameter typeParameter) { spoon.reflect.declaration.CtTypeParameter other = ((spoon.reflect.declaration.CtTypeParameter) (this.stack.peek())); enter(typeParameter); - biScan(typeParameter.getAnnotations(), other.getAnnotations()); - biScan(typeParameter.getSuperclass(), other.getSuperclass()); - biScan(typeParameter.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, typeParameter.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.SUPER_TYPE, typeParameter.getSuperclass(), other.getSuperclass()); + biScan(spoon.reflect.path.CtRole.COMMENT, typeParameter.getComments(), other.getComments()); exit(typeParameter); } @@ -208,13 +208,13 @@ public void visitCtTypeParameter(spoon.reflect.declaration.CtTypeParameter typeP public void visitCtConditional(final spoon.reflect.code.CtConditional conditional) { spoon.reflect.code.CtConditional other = ((spoon.reflect.code.CtConditional) (this.stack.peek())); enter(conditional); - biScan(conditional.getType(), other.getType()); - biScan(conditional.getAnnotations(), other.getAnnotations()); - biScan(conditional.getCondition(), other.getCondition()); - biScan(conditional.getThenExpression(), other.getThenExpression()); - biScan(conditional.getElseExpression(), other.getElseExpression()); - biScan(conditional.getComments(), other.getComments()); - biScan(conditional.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.TYPE, conditional.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, conditional.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.CONDITION, conditional.getCondition(), other.getCondition()); + biScan(spoon.reflect.path.CtRole.THEN, conditional.getThenExpression(), other.getThenExpression()); + biScan(spoon.reflect.path.CtRole.ELSE, conditional.getElseExpression(), other.getElseExpression()); + biScan(spoon.reflect.path.CtRole.COMMENT, conditional.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.CAST, conditional.getTypeCasts(), other.getTypeCasts()); exit(conditional); } @@ -222,12 +222,12 @@ public void visitCtConditional(final spoon.reflect.code.CtConditional con public void visitCtConstructor(final spoon.reflect.declaration.CtConstructor c) { spoon.reflect.declaration.CtConstructor other = ((spoon.reflect.declaration.CtConstructor) (this.stack.peek())); enter(c); - biScan(c.getAnnotations(), other.getAnnotations()); - biScan(c.getParameters(), other.getParameters()); - biScan(c.getThrownTypes(), other.getThrownTypes()); - biScan(c.getFormalCtTypeParameters(), other.getFormalCtTypeParameters()); - biScan(c.getBody(), other.getBody()); - biScan(c.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, c.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.PARAMETER, c.getParameters(), other.getParameters()); + biScan(spoon.reflect.path.CtRole.THROWN, c.getThrownTypes(), other.getThrownTypes()); + biScan(spoon.reflect.path.CtRole.TYPE_PARAMETER, c.getFormalCtTypeParameters(), other.getFormalCtTypeParameters()); + biScan(spoon.reflect.path.CtRole.BODY, c.getBody(), other.getBody()); + biScan(spoon.reflect.path.CtRole.COMMENT, c.getComments(), other.getComments()); exit(c); } @@ -235,8 +235,8 @@ public void visitCtConstructor(final spoon.reflect.declaration.CtConstructor public void visitCtContinue(final spoon.reflect.code.CtContinue continueStatement) { spoon.reflect.code.CtContinue other = ((spoon.reflect.code.CtContinue) (this.stack.peek())); enter(continueStatement); - biScan(continueStatement.getAnnotations(), other.getAnnotations()); - biScan(continueStatement.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, continueStatement.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.COMMENT, continueStatement.getComments(), other.getComments()); exit(continueStatement); } @@ -244,10 +244,10 @@ public void visitCtContinue(final spoon.reflect.code.CtContinue continueStatemen public void visitCtDo(final spoon.reflect.code.CtDo doLoop) { spoon.reflect.code.CtDo other = ((spoon.reflect.code.CtDo) (this.stack.peek())); enter(doLoop); - biScan(doLoop.getAnnotations(), other.getAnnotations()); - biScan(doLoop.getLoopingExpression(), other.getLoopingExpression()); - biScan(doLoop.getBody(), other.getBody()); - biScan(doLoop.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, doLoop.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, doLoop.getLoopingExpression(), other.getLoopingExpression()); + biScan(spoon.reflect.path.CtRole.BODY, doLoop.getBody(), other.getBody()); + biScan(spoon.reflect.path.CtRole.COMMENT, doLoop.getComments(), other.getComments()); exit(doLoop); } @@ -255,11 +255,11 @@ public void visitCtDo(final spoon.reflect.code.CtDo doLoop) { public > void visitCtEnum(final spoon.reflect.declaration.CtEnum ctEnum) { spoon.reflect.declaration.CtEnum other = ((spoon.reflect.declaration.CtEnum) (this.stack.peek())); enter(ctEnum); - biScan(ctEnum.getAnnotations(), other.getAnnotations()); - biScan(ctEnum.getSuperInterfaces(), other.getSuperInterfaces()); - biScan(ctEnum.getTypeMembers(), other.getTypeMembers()); - biScan(ctEnum.getEnumValues(), other.getEnumValues()); - biScan(ctEnum.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, ctEnum.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.INTERFACE, ctEnum.getSuperInterfaces(), other.getSuperInterfaces()); + biScan(spoon.reflect.path.CtRole.TYPE_MEMBER, ctEnum.getTypeMembers(), other.getTypeMembers()); + biScan(spoon.reflect.path.CtRole.VALUE, ctEnum.getEnumValues(), other.getEnumValues()); + biScan(spoon.reflect.path.CtRole.COMMENT, ctEnum.getComments(), other.getComments()); exit(ctEnum); } @@ -267,12 +267,12 @@ public > void visitCtEnum(final spoon.reflect.declar public void visitCtExecutableReference(final spoon.reflect.reference.CtExecutableReference reference) { spoon.reflect.reference.CtExecutableReference other = ((spoon.reflect.reference.CtExecutableReference) (this.stack.peek())); enter(reference); - biScan(reference.getDeclaringType(), other.getDeclaringType()); - biScan(reference.getType(), other.getType()); - biScan(reference.getParameters(), other.getParameters()); - biScan(reference.getActualTypeArguments(), other.getActualTypeArguments()); - biScan(reference.getAnnotations(), other.getAnnotations()); - biScan(reference.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.DECLARING_TYPE, reference.getDeclaringType(), other.getDeclaringType()); + biScan(spoon.reflect.path.CtRole.TYPE, reference.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.ARGUMENT_TYPE, reference.getParameters(), other.getParameters()); + biScan(spoon.reflect.path.CtRole.TYPE_ARGUMENT, reference.getActualTypeArguments(), other.getActualTypeArguments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, reference.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.COMMENT, reference.getComments(), other.getComments()); exit(reference); } @@ -280,10 +280,10 @@ public void visitCtExecutableReference(final spoon.reflect.reference.CtExecu public void visitCtField(final spoon.reflect.declaration.CtField f) { spoon.reflect.declaration.CtField other = ((spoon.reflect.declaration.CtField) (this.stack.peek())); enter(f); - biScan(f.getAnnotations(), other.getAnnotations()); - biScan(f.getType(), other.getType()); - biScan(f.getDefaultExpression(), other.getDefaultExpression()); - biScan(f.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, f.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, f.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.DEFAULT_EXPRESSION, f.getDefaultExpression(), other.getDefaultExpression()); + biScan(spoon.reflect.path.CtRole.COMMENT, f.getComments(), other.getComments()); exit(f); } @@ -292,10 +292,10 @@ public void visitCtField(final spoon.reflect.declaration.CtField f) { public void visitCtEnumValue(final spoon.reflect.declaration.CtEnumValue enumValue) { spoon.reflect.declaration.CtEnumValue other = ((spoon.reflect.declaration.CtEnumValue) (this.stack.peek())); enter(enumValue); - biScan(enumValue.getAnnotations(), other.getAnnotations()); - biScan(enumValue.getType(), other.getType()); - biScan(enumValue.getDefaultExpression(), other.getDefaultExpression()); - biScan(enumValue.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, enumValue.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, enumValue.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.DEFAULT_EXPRESSION, enumValue.getDefaultExpression(), other.getDefaultExpression()); + biScan(spoon.reflect.path.CtRole.COMMENT, enumValue.getComments(), other.getComments()); exit(enumValue); } @@ -304,11 +304,11 @@ public void visitCtEnumValue(final spoon.reflect.declaration.CtEnumValue public void visitCtThisAccess(final spoon.reflect.code.CtThisAccess thisAccess) { spoon.reflect.code.CtThisAccess other = ((spoon.reflect.code.CtThisAccess) (this.stack.peek())); enter(thisAccess); - biScan(thisAccess.getComments(), other.getComments()); - biScan(thisAccess.getAnnotations(), other.getAnnotations()); - biScan(thisAccess.getType(), other.getType()); - biScan(thisAccess.getTypeCasts(), other.getTypeCasts()); - biScan(thisAccess.getTarget(), other.getTarget()); + biScan(spoon.reflect.path.CtRole.COMMENT, thisAccess.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, thisAccess.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, thisAccess.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.CAST, thisAccess.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.TARGET, thisAccess.getTarget(), other.getTarget()); exit(thisAccess); } @@ -316,11 +316,11 @@ public void visitCtThisAccess(final spoon.reflect.code.CtThisAccess thisA public void visitCtAnnotationFieldAccess(final spoon.reflect.code.CtAnnotationFieldAccess annotationFieldAccess) { spoon.reflect.code.CtAnnotationFieldAccess other = ((spoon.reflect.code.CtAnnotationFieldAccess) (this.stack.peek())); enter(annotationFieldAccess); - biScan(annotationFieldAccess.getComments(), other.getComments()); - biScan(annotationFieldAccess.getAnnotations(), other.getAnnotations()); - biScan(annotationFieldAccess.getTypeCasts(), other.getTypeCasts()); - biScan(annotationFieldAccess.getTarget(), other.getTarget()); - biScan(annotationFieldAccess.getVariable(), other.getVariable()); + biScan(spoon.reflect.path.CtRole.COMMENT, annotationFieldAccess.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, annotationFieldAccess.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.CAST, annotationFieldAccess.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.TARGET, annotationFieldAccess.getTarget(), other.getTarget()); + biScan(spoon.reflect.path.CtRole.VARIABLE, annotationFieldAccess.getVariable(), other.getVariable()); exit(annotationFieldAccess); } @@ -328,9 +328,9 @@ public void visitCtAnnotationFieldAccess(final spoon.reflect.code.CtAnnotati public void visitCtFieldReference(final spoon.reflect.reference.CtFieldReference reference) { spoon.reflect.reference.CtFieldReference other = ((spoon.reflect.reference.CtFieldReference) (this.stack.peek())); enter(reference); - biScan(reference.getDeclaringType(), other.getDeclaringType()); - biScan(reference.getType(), other.getType()); - biScan(reference.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.DECLARING_TYPE, reference.getDeclaringType(), other.getDeclaringType()); + biScan(spoon.reflect.path.CtRole.TYPE, reference.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, reference.getAnnotations(), other.getAnnotations()); exit(reference); } @@ -338,12 +338,12 @@ public void visitCtFieldReference(final spoon.reflect.reference.CtFieldRefer public void visitCtFor(final spoon.reflect.code.CtFor forLoop) { spoon.reflect.code.CtFor other = ((spoon.reflect.code.CtFor) (this.stack.peek())); enter(forLoop); - biScan(forLoop.getAnnotations(), other.getAnnotations()); - biScan(forLoop.getForInit(), other.getForInit()); - biScan(forLoop.getExpression(), other.getExpression()); - biScan(forLoop.getForUpdate(), other.getForUpdate()); - biScan(forLoop.getBody(), other.getBody()); - biScan(forLoop.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, forLoop.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.FOR_INIT, forLoop.getForInit(), other.getForInit()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, forLoop.getExpression(), other.getExpression()); + biScan(spoon.reflect.path.CtRole.FOR_UPDATE, forLoop.getForUpdate(), other.getForUpdate()); + biScan(spoon.reflect.path.CtRole.BODY, forLoop.getBody(), other.getBody()); + biScan(spoon.reflect.path.CtRole.COMMENT, forLoop.getComments(), other.getComments()); exit(forLoop); } @@ -351,11 +351,11 @@ public void visitCtFor(final spoon.reflect.code.CtFor forLoop) { public void visitCtForEach(final spoon.reflect.code.CtForEach foreach) { spoon.reflect.code.CtForEach other = ((spoon.reflect.code.CtForEach) (this.stack.peek())); enter(foreach); - biScan(foreach.getAnnotations(), other.getAnnotations()); - biScan(foreach.getVariable(), other.getVariable()); - biScan(foreach.getExpression(), other.getExpression()); - biScan(foreach.getBody(), other.getBody()); - biScan(foreach.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, foreach.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.FOREACH_VARIABLE, foreach.getVariable(), other.getVariable()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, foreach.getExpression(), other.getExpression()); + biScan(spoon.reflect.path.CtRole.BODY, foreach.getBody(), other.getBody()); + biScan(spoon.reflect.path.CtRole.COMMENT, foreach.getComments(), other.getComments()); exit(foreach); } @@ -363,11 +363,11 @@ public void visitCtForEach(final spoon.reflect.code.CtForEach foreach) { public void visitCtIf(final spoon.reflect.code.CtIf ifElement) { spoon.reflect.code.CtIf other = ((spoon.reflect.code.CtIf) (this.stack.peek())); enter(ifElement); - biScan(ifElement.getAnnotations(), other.getAnnotations()); - biScan(ifElement.getCondition(), other.getCondition()); - biScan(((spoon.reflect.code.CtStatement) (ifElement.getThenStatement())), other.getThenStatement()); - biScan(((spoon.reflect.code.CtStatement) (ifElement.getElseStatement())), other.getElseStatement()); - biScan(ifElement.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, ifElement.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.CONDITION, ifElement.getCondition(), other.getCondition()); + biScan(spoon.reflect.path.CtRole.THEN, ((spoon.reflect.code.CtStatement) (ifElement.getThenStatement())), other.getThenStatement()); + biScan(spoon.reflect.path.CtRole.ELSE, ((spoon.reflect.code.CtStatement) (ifElement.getElseStatement())), other.getElseStatement()); + biScan(spoon.reflect.path.CtRole.COMMENT, ifElement.getComments(), other.getComments()); exit(ifElement); } @@ -375,11 +375,11 @@ public void visitCtIf(final spoon.reflect.code.CtIf ifElement) { public void visitCtInterface(final spoon.reflect.declaration.CtInterface intrface) { spoon.reflect.declaration.CtInterface other = ((spoon.reflect.declaration.CtInterface) (this.stack.peek())); enter(intrface); - biScan(intrface.getAnnotations(), other.getAnnotations()); - biScan(intrface.getSuperInterfaces(), other.getSuperInterfaces()); - biScan(intrface.getFormalCtTypeParameters(), other.getFormalCtTypeParameters()); - biScan(intrface.getTypeMembers(), other.getTypeMembers()); - biScan(intrface.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, intrface.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.INTERFACE, intrface.getSuperInterfaces(), other.getSuperInterfaces()); + biScan(spoon.reflect.path.CtRole.TYPE_PARAMETER, intrface.getFormalCtTypeParameters(), other.getFormalCtTypeParameters()); + biScan(spoon.reflect.path.CtRole.TYPE_MEMBER, intrface.getTypeMembers(), other.getTypeMembers()); + biScan(spoon.reflect.path.CtRole.COMMENT, intrface.getComments(), other.getComments()); exit(intrface); } @@ -387,12 +387,12 @@ public void visitCtInterface(final spoon.reflect.declaration.CtInterface public void visitCtInvocation(final spoon.reflect.code.CtInvocation invocation) { spoon.reflect.code.CtInvocation other = ((spoon.reflect.code.CtInvocation) (this.stack.peek())); enter(invocation); - biScan(invocation.getAnnotations(), other.getAnnotations()); - biScan(invocation.getTypeCasts(), other.getTypeCasts()); - biScan(invocation.getTarget(), other.getTarget()); - biScan(invocation.getExecutable(), other.getExecutable()); - biScan(invocation.getArguments(), other.getArguments()); - biScan(invocation.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, invocation.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.CAST, invocation.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.TARGET, invocation.getTarget(), other.getTarget()); + biScan(spoon.reflect.path.CtRole.EXECUTABLE_REF, invocation.getExecutable(), other.getExecutable()); + biScan(spoon.reflect.path.CtRole.ARGUMENT, invocation.getArguments(), other.getArguments()); + biScan(spoon.reflect.path.CtRole.COMMENT, invocation.getComments(), other.getComments()); exit(invocation); } @@ -400,10 +400,10 @@ public void visitCtInvocation(final spoon.reflect.code.CtInvocation invoc public void visitCtLiteral(final spoon.reflect.code.CtLiteral literal) { spoon.reflect.code.CtLiteral other = ((spoon.reflect.code.CtLiteral) (this.stack.peek())); enter(literal); - biScan(literal.getAnnotations(), other.getAnnotations()); - biScan(literal.getType(), other.getType()); - biScan(literal.getTypeCasts(), other.getTypeCasts()); - biScan(literal.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, literal.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, literal.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.CAST, literal.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.COMMENT, literal.getComments(), other.getComments()); exit(literal); } @@ -411,10 +411,10 @@ public void visitCtLiteral(final spoon.reflect.code.CtLiteral literal) { public void visitCtLocalVariable(final spoon.reflect.code.CtLocalVariable localVariable) { spoon.reflect.code.CtLocalVariable other = ((spoon.reflect.code.CtLocalVariable) (this.stack.peek())); enter(localVariable); - biScan(localVariable.getAnnotations(), other.getAnnotations()); - biScan(localVariable.getType(), other.getType()); - biScan(localVariable.getDefaultExpression(), other.getDefaultExpression()); - biScan(localVariable.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, localVariable.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, localVariable.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.DEFAULT_EXPRESSION, localVariable.getDefaultExpression(), other.getDefaultExpression()); + biScan(spoon.reflect.path.CtRole.COMMENT, localVariable.getComments(), other.getComments()); exit(localVariable); } @@ -422,8 +422,8 @@ public void visitCtLocalVariable(final spoon.reflect.code.CtLocalVariable public void visitCtLocalVariableReference(final spoon.reflect.reference.CtLocalVariableReference reference) { spoon.reflect.reference.CtLocalVariableReference other = ((spoon.reflect.reference.CtLocalVariableReference) (this.stack.peek())); enter(reference); - biScan(reference.getType(), other.getType()); - biScan(reference.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, reference.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, reference.getAnnotations(), other.getAnnotations()); exit(reference); } @@ -431,9 +431,9 @@ public void visitCtLocalVariableReference(final spoon.reflect.reference.CtLo public void visitCtCatchVariable(final spoon.reflect.code.CtCatchVariable catchVariable) { spoon.reflect.code.CtCatchVariable other = ((spoon.reflect.code.CtCatchVariable) (this.stack.peek())); enter(catchVariable); - biScan(catchVariable.getComments(), other.getComments()); - biScan(catchVariable.getAnnotations(), other.getAnnotations()); - biScan(catchVariable.getMultiTypes(), other.getMultiTypes()); + biScan(spoon.reflect.path.CtRole.COMMENT, catchVariable.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, catchVariable.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, catchVariable.getMultiTypes(), other.getMultiTypes()); exit(catchVariable); } @@ -441,9 +441,9 @@ public void visitCtCatchVariable(final spoon.reflect.code.CtCatchVariable public void visitCtCatchVariableReference(final spoon.reflect.reference.CtCatchVariableReference reference) { spoon.reflect.reference.CtCatchVariableReference other = ((spoon.reflect.reference.CtCatchVariableReference) (this.stack.peek())); enter(reference); - biScan(reference.getComments(), other.getComments()); - biScan(reference.getType(), other.getType()); - biScan(reference.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.COMMENT, reference.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.TYPE, reference.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, reference.getAnnotations(), other.getAnnotations()); exit(reference); } @@ -451,13 +451,13 @@ public void visitCtCatchVariableReference(final spoon.reflect.reference.CtCa public void visitCtMethod(final spoon.reflect.declaration.CtMethod m) { spoon.reflect.declaration.CtMethod other = ((spoon.reflect.declaration.CtMethod) (this.stack.peek())); enter(m); - biScan(m.getAnnotations(), other.getAnnotations()); - biScan(m.getFormalCtTypeParameters(), other.getFormalCtTypeParameters()); - biScan(m.getType(), other.getType()); - biScan(m.getParameters(), other.getParameters()); - biScan(m.getThrownTypes(), other.getThrownTypes()); - biScan(m.getBody(), other.getBody()); - biScan(m.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, m.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE_PARAMETER, m.getFormalCtTypeParameters(), other.getFormalCtTypeParameters()); + biScan(spoon.reflect.path.CtRole.TYPE, m.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.PARAMETER, m.getParameters(), other.getParameters()); + biScan(spoon.reflect.path.CtRole.THROWN, m.getThrownTypes(), other.getThrownTypes()); + biScan(spoon.reflect.path.CtRole.BODY, m.getBody(), other.getBody()); + biScan(spoon.reflect.path.CtRole.COMMENT, m.getComments(), other.getComments()); exit(m); } @@ -466,10 +466,10 @@ public void visitCtMethod(final spoon.reflect.declaration.CtMethod m) { public void visitCtAnnotationMethod(spoon.reflect.declaration.CtAnnotationMethod annotationMethod) { spoon.reflect.declaration.CtAnnotationMethod other = ((spoon.reflect.declaration.CtAnnotationMethod) (this.stack.peek())); enter(annotationMethod); - biScan(annotationMethod.getAnnotations(), other.getAnnotations()); - biScan(annotationMethod.getType(), other.getType()); - biScan(annotationMethod.getDefaultExpression(), other.getDefaultExpression()); - biScan(annotationMethod.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, annotationMethod.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, annotationMethod.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.DEFAULT_EXPRESSION, annotationMethod.getDefaultExpression(), other.getDefaultExpression()); + biScan(spoon.reflect.path.CtRole.COMMENT, annotationMethod.getComments(), other.getComments()); exit(annotationMethod); } @@ -477,12 +477,12 @@ public void visitCtAnnotationMethod(spoon.reflect.declaration.CtAnnotationMe public void visitCtNewArray(final spoon.reflect.code.CtNewArray newArray) { spoon.reflect.code.CtNewArray other = ((spoon.reflect.code.CtNewArray) (this.stack.peek())); enter(newArray); - biScan(newArray.getAnnotations(), other.getAnnotations()); - biScan(newArray.getType(), other.getType()); - biScan(newArray.getTypeCasts(), other.getTypeCasts()); - biScan(newArray.getElements(), other.getElements()); - biScan(newArray.getDimensionExpressions(), other.getDimensionExpressions()); - biScan(newArray.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, newArray.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, newArray.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.CAST, newArray.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, newArray.getElements(), other.getElements()); + biScan(spoon.reflect.path.CtRole.DIMENSION, newArray.getDimensionExpressions(), other.getDimensionExpressions()); + biScan(spoon.reflect.path.CtRole.COMMENT, newArray.getComments(), other.getComments()); exit(newArray); } @@ -491,12 +491,12 @@ public void visitCtNewArray(final spoon.reflect.code.CtNewArray newArray) public void visitCtConstructorCall(final spoon.reflect.code.CtConstructorCall ctConstructorCall) { spoon.reflect.code.CtConstructorCall other = ((spoon.reflect.code.CtConstructorCall) (this.stack.peek())); enter(ctConstructorCall); - biScan(ctConstructorCall.getAnnotations(), other.getAnnotations()); - biScan(ctConstructorCall.getTypeCasts(), other.getTypeCasts()); - biScan(ctConstructorCall.getExecutable(), other.getExecutable()); - biScan(ctConstructorCall.getTarget(), other.getTarget()); - biScan(ctConstructorCall.getArguments(), other.getArguments()); - biScan(ctConstructorCall.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, ctConstructorCall.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.CAST, ctConstructorCall.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.EXECUTABLE_REF, ctConstructorCall.getExecutable(), other.getExecutable()); + biScan(spoon.reflect.path.CtRole.TARGET, ctConstructorCall.getTarget(), other.getTarget()); + biScan(spoon.reflect.path.CtRole.ARGUMENT, ctConstructorCall.getArguments(), other.getArguments()); + biScan(spoon.reflect.path.CtRole.COMMENT, ctConstructorCall.getComments(), other.getComments()); exit(ctConstructorCall); } @@ -504,13 +504,13 @@ public void visitCtConstructorCall(final spoon.reflect.code.CtConstructorCal public void visitCtNewClass(final spoon.reflect.code.CtNewClass newClass) { spoon.reflect.code.CtNewClass other = ((spoon.reflect.code.CtNewClass) (this.stack.peek())); enter(newClass); - biScan(newClass.getAnnotations(), other.getAnnotations()); - biScan(newClass.getTypeCasts(), other.getTypeCasts()); - biScan(newClass.getExecutable(), other.getExecutable()); - biScan(newClass.getTarget(), other.getTarget()); - biScan(newClass.getArguments(), other.getArguments()); - biScan(newClass.getAnonymousClass(), other.getAnonymousClass()); - biScan(newClass.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, newClass.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.CAST, newClass.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.EXECUTABLE_REF, newClass.getExecutable(), other.getExecutable()); + biScan(spoon.reflect.path.CtRole.TARGET, newClass.getTarget(), other.getTarget()); + biScan(spoon.reflect.path.CtRole.ARGUMENT, newClass.getArguments(), other.getArguments()); + biScan(spoon.reflect.path.CtRole.NESTED_TYPE, newClass.getAnonymousClass(), other.getAnonymousClass()); + biScan(spoon.reflect.path.CtRole.COMMENT, newClass.getComments(), other.getComments()); exit(newClass); } @@ -519,14 +519,14 @@ public void visitCtNewClass(final spoon.reflect.code.CtNewClass newClass) public void visitCtLambda(final spoon.reflect.code.CtLambda lambda) { spoon.reflect.code.CtLambda other = ((spoon.reflect.code.CtLambda) (this.stack.peek())); enter(lambda); - biScan(lambda.getAnnotations(), other.getAnnotations()); - biScan(lambda.getType(), other.getType()); - biScan(lambda.getTypeCasts(), other.getTypeCasts()); - biScan(lambda.getParameters(), other.getParameters()); - biScan(lambda.getThrownTypes(), other.getThrownTypes()); - biScan(lambda.getBody(), other.getBody()); - biScan(lambda.getExpression(), other.getExpression()); - biScan(lambda.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, lambda.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, lambda.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.CAST, lambda.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.PARAMETER, lambda.getParameters(), other.getParameters()); + biScan(spoon.reflect.path.CtRole.THROWN, lambda.getThrownTypes(), other.getThrownTypes()); + biScan(spoon.reflect.path.CtRole.BODY, lambda.getBody(), other.getBody()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, lambda.getExpression(), other.getExpression()); + biScan(spoon.reflect.path.CtRole.COMMENT, lambda.getComments(), other.getComments()); exit(lambda); } @@ -535,12 +535,12 @@ public void visitCtLambda(final spoon.reflect.code.CtLambda lambda) { public > void visitCtExecutableReferenceExpression(final spoon.reflect.code.CtExecutableReferenceExpression expression) { spoon.reflect.code.CtExecutableReferenceExpression other = ((spoon.reflect.code.CtExecutableReferenceExpression) (this.stack.peek())); enter(expression); - biScan(expression.getComments(), other.getComments()); - biScan(expression.getAnnotations(), other.getAnnotations()); - biScan(expression.getType(), other.getType()); - biScan(expression.getTypeCasts(), other.getTypeCasts()); - biScan(expression.getExecutable(), other.getExecutable()); - biScan(expression.getTarget(), other.getTarget()); + biScan(spoon.reflect.path.CtRole.COMMENT, expression.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, expression.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, expression.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.CAST, expression.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.EXECUTABLE_REF, expression.getExecutable(), other.getExecutable()); + biScan(spoon.reflect.path.CtRole.TARGET, expression.getTarget(), other.getTarget()); exit(expression); } @@ -548,12 +548,12 @@ public > void visitCtExecutableR public void visitCtOperatorAssignment(final spoon.reflect.code.CtOperatorAssignment assignment) { spoon.reflect.code.CtOperatorAssignment other = ((spoon.reflect.code.CtOperatorAssignment) (this.stack.peek())); enter(assignment); - biScan(assignment.getAnnotations(), other.getAnnotations()); - biScan(assignment.getType(), other.getType()); - biScan(assignment.getTypeCasts(), other.getTypeCasts()); - biScan(assignment.getAssigned(), other.getAssigned()); - biScan(assignment.getAssignment(), other.getAssignment()); - biScan(assignment.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, assignment.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, assignment.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.CAST, assignment.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.ASSIGNED, assignment.getAssigned(), other.getAssigned()); + biScan(spoon.reflect.path.CtRole.ASSIGNMENT, assignment.getAssignment(), other.getAssignment()); + biScan(spoon.reflect.path.CtRole.COMMENT, assignment.getComments(), other.getComments()); exit(assignment); } @@ -561,10 +561,10 @@ public void visitCtOperatorAssignment(final spoon.reflect.code. public void visitCtPackage(final spoon.reflect.declaration.CtPackage ctPackage) { spoon.reflect.declaration.CtPackage other = ((spoon.reflect.declaration.CtPackage) (this.stack.peek())); enter(ctPackage); - biScan(ctPackage.getAnnotations(), other.getAnnotations()); - biScan(ctPackage.getPackages(), other.getPackages()); - biScan(ctPackage.getTypes(), other.getTypes()); - biScan(ctPackage.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, ctPackage.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.SUB_PACKAGE, ctPackage.getPackages(), other.getPackages()); + biScan(spoon.reflect.path.CtRole.CONTAINED_TYPE, ctPackage.getTypes(), other.getTypes()); + biScan(spoon.reflect.path.CtRole.COMMENT, ctPackage.getComments(), other.getComments()); exit(ctPackage); } @@ -572,7 +572,7 @@ public void visitCtPackage(final spoon.reflect.declaration.CtPackage ctPackage) public void visitCtPackageReference(final spoon.reflect.reference.CtPackageReference reference) { spoon.reflect.reference.CtPackageReference other = ((spoon.reflect.reference.CtPackageReference) (this.stack.peek())); enter(reference); - biScan(reference.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, reference.getAnnotations(), other.getAnnotations()); exit(reference); } @@ -580,9 +580,9 @@ public void visitCtPackageReference(final spoon.reflect.reference.CtPackageRefer public void visitCtParameter(final spoon.reflect.declaration.CtParameter parameter) { spoon.reflect.declaration.CtParameter other = ((spoon.reflect.declaration.CtParameter) (this.stack.peek())); enter(parameter); - biScan(parameter.getAnnotations(), other.getAnnotations()); - biScan(parameter.getType(), other.getType()); - biScan(parameter.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, parameter.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, parameter.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.COMMENT, parameter.getComments(), other.getComments()); exit(parameter); } @@ -590,9 +590,9 @@ public void visitCtParameter(final spoon.reflect.declaration.CtParameter public void visitCtParameterReference(final spoon.reflect.reference.CtParameterReference reference) { spoon.reflect.reference.CtParameterReference other = ((spoon.reflect.reference.CtParameterReference) (this.stack.peek())); enter(reference); - biScan(reference.getType(), other.getType()); - biScan(reference.getAnnotations(), other.getAnnotations()); - biScan(reference.getDeclaringExecutable(), other.getDeclaringExecutable()); + biScan(spoon.reflect.path.CtRole.TYPE, reference.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, reference.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.EXECUTABLE_REF, reference.getDeclaringExecutable(), other.getDeclaringExecutable()); exit(reference); } @@ -600,9 +600,9 @@ public void visitCtParameterReference(final spoon.reflect.reference.CtParame public void visitCtReturn(final spoon.reflect.code.CtReturn returnStatement) { spoon.reflect.code.CtReturn other = ((spoon.reflect.code.CtReturn) (this.stack.peek())); enter(returnStatement); - biScan(returnStatement.getAnnotations(), other.getAnnotations()); - biScan(returnStatement.getReturnedExpression(), other.getReturnedExpression()); - biScan(returnStatement.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, returnStatement.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, returnStatement.getReturnedExpression(), other.getReturnedExpression()); + biScan(spoon.reflect.path.CtRole.COMMENT, returnStatement.getComments(), other.getComments()); exit(returnStatement); } @@ -610,9 +610,9 @@ public void visitCtReturn(final spoon.reflect.code.CtReturn returnStateme public void visitCtStatementList(final spoon.reflect.code.CtStatementList statements) { spoon.reflect.code.CtStatementList other = ((spoon.reflect.code.CtStatementList) (this.stack.peek())); enter(statements); - biScan(statements.getAnnotations(), other.getAnnotations()); - biScan(statements.getStatements(), other.getStatements()); - biScan(statements.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, statements.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.STATEMENT, statements.getStatements(), other.getStatements()); + biScan(spoon.reflect.path.CtRole.COMMENT, statements.getComments(), other.getComments()); exit(statements); } @@ -620,10 +620,10 @@ public void visitCtStatementList(final spoon.reflect.code.CtStatementList st public void visitCtSwitch(final spoon.reflect.code.CtSwitch switchStatement) { spoon.reflect.code.CtSwitch other = ((spoon.reflect.code.CtSwitch) (this.stack.peek())); enter(switchStatement); - biScan(switchStatement.getAnnotations(), other.getAnnotations()); - biScan(switchStatement.getSelector(), other.getSelector()); - biScan(switchStatement.getCases(), other.getCases()); - biScan(switchStatement.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, switchStatement.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, switchStatement.getSelector(), other.getSelector()); + biScan(spoon.reflect.path.CtRole.CASE, switchStatement.getCases(), other.getCases()); + biScan(spoon.reflect.path.CtRole.COMMENT, switchStatement.getComments(), other.getComments()); exit(switchStatement); } @@ -631,10 +631,10 @@ public void visitCtSwitch(final spoon.reflect.code.CtSwitch switchStateme public void visitCtSynchronized(final spoon.reflect.code.CtSynchronized synchro) { spoon.reflect.code.CtSynchronized other = ((spoon.reflect.code.CtSynchronized) (this.stack.peek())); enter(synchro); - biScan(synchro.getAnnotations(), other.getAnnotations()); - biScan(synchro.getExpression(), other.getExpression()); - biScan(synchro.getBlock(), other.getBlock()); - biScan(synchro.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, synchro.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, synchro.getExpression(), other.getExpression()); + biScan(spoon.reflect.path.CtRole.BODY, synchro.getBlock(), other.getBlock()); + biScan(spoon.reflect.path.CtRole.COMMENT, synchro.getComments(), other.getComments()); exit(synchro); } @@ -642,9 +642,9 @@ public void visitCtSynchronized(final spoon.reflect.code.CtSynchronized synchro) public void visitCtThrow(final spoon.reflect.code.CtThrow throwStatement) { spoon.reflect.code.CtThrow other = ((spoon.reflect.code.CtThrow) (this.stack.peek())); enter(throwStatement); - biScan(throwStatement.getAnnotations(), other.getAnnotations()); - biScan(throwStatement.getThrownExpression(), other.getThrownExpression()); - biScan(throwStatement.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, throwStatement.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, throwStatement.getThrownExpression(), other.getThrownExpression()); + biScan(spoon.reflect.path.CtRole.COMMENT, throwStatement.getComments(), other.getComments()); exit(throwStatement); } @@ -652,11 +652,11 @@ public void visitCtThrow(final spoon.reflect.code.CtThrow throwStatement) { public void visitCtTry(final spoon.reflect.code.CtTry tryBlock) { spoon.reflect.code.CtTry other = ((spoon.reflect.code.CtTry) (this.stack.peek())); enter(tryBlock); - biScan(tryBlock.getAnnotations(), other.getAnnotations()); - biScan(tryBlock.getBody(), other.getBody()); - biScan(tryBlock.getCatchers(), other.getCatchers()); - biScan(tryBlock.getFinalizer(), other.getFinalizer()); - biScan(tryBlock.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, tryBlock.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.BODY, tryBlock.getBody(), other.getBody()); + biScan(spoon.reflect.path.CtRole.CATCH, tryBlock.getCatchers(), other.getCatchers()); + biScan(spoon.reflect.path.CtRole.FINALIZER, tryBlock.getFinalizer(), other.getFinalizer()); + biScan(spoon.reflect.path.CtRole.COMMENT, tryBlock.getComments(), other.getComments()); exit(tryBlock); } @@ -665,12 +665,12 @@ public void visitCtTry(final spoon.reflect.code.CtTry tryBlock) { public void visitCtTryWithResource(final spoon.reflect.code.CtTryWithResource tryWithResource) { spoon.reflect.code.CtTryWithResource other = ((spoon.reflect.code.CtTryWithResource) (this.stack.peek())); enter(tryWithResource); - biScan(tryWithResource.getAnnotations(), other.getAnnotations()); - biScan(tryWithResource.getResources(), other.getResources()); - biScan(tryWithResource.getBody(), other.getBody()); - biScan(tryWithResource.getCatchers(), other.getCatchers()); - biScan(tryWithResource.getFinalizer(), other.getFinalizer()); - biScan(tryWithResource.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, tryWithResource.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TRY_RESOURCE, tryWithResource.getResources(), other.getResources()); + biScan(spoon.reflect.path.CtRole.BODY, tryWithResource.getBody(), other.getBody()); + biScan(spoon.reflect.path.CtRole.CATCH, tryWithResource.getCatchers(), other.getCatchers()); + biScan(spoon.reflect.path.CtRole.FINALIZER, tryWithResource.getFinalizer(), other.getFinalizer()); + biScan(spoon.reflect.path.CtRole.COMMENT, tryWithResource.getComments(), other.getComments()); exit(tryWithResource); } @@ -678,10 +678,10 @@ public void visitCtTryWithResource(final spoon.reflect.code.CtTryWithResource tr public void visitCtTypeParameterReference(final spoon.reflect.reference.CtTypeParameterReference ref) { spoon.reflect.reference.CtTypeParameterReference other = ((spoon.reflect.reference.CtTypeParameterReference) (this.stack.peek())); enter(ref); - biScan(ref.getPackage(), other.getPackage()); - biScan(ref.getDeclaringType(), other.getDeclaringType()); - biScan(ref.getAnnotations(), other.getAnnotations()); - biScan(ref.getBoundingType(), other.getBoundingType()); + biScan(spoon.reflect.path.CtRole.PACKAGE_REF, ref.getPackage(), other.getPackage()); + biScan(spoon.reflect.path.CtRole.DECLARING_TYPE, ref.getDeclaringType(), other.getDeclaringType()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, ref.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.BOUNDING_TYPE, ref.getBoundingType(), other.getBoundingType()); exit(ref); } @@ -690,10 +690,10 @@ public void visitCtTypeParameterReference(final spoon.reflect.reference.CtTypePa public void visitCtWildcardReference(spoon.reflect.reference.CtWildcardReference wildcardReference) { spoon.reflect.reference.CtWildcardReference other = ((spoon.reflect.reference.CtWildcardReference) (this.stack.peek())); enter(wildcardReference); - biScan(wildcardReference.getPackage(), other.getPackage()); - biScan(wildcardReference.getDeclaringType(), other.getDeclaringType()); - biScan(wildcardReference.getAnnotations(), other.getAnnotations()); - biScan(wildcardReference.getBoundingType(), other.getBoundingType()); + biScan(spoon.reflect.path.CtRole.PACKAGE_REF, wildcardReference.getPackage(), other.getPackage()); + biScan(spoon.reflect.path.CtRole.DECLARING_TYPE, wildcardReference.getDeclaringType(), other.getDeclaringType()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, wildcardReference.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.BOUNDING_TYPE, wildcardReference.getBoundingType(), other.getBoundingType()); exit(wildcardReference); } @@ -702,12 +702,12 @@ public void visitCtWildcardReference(spoon.reflect.reference.CtWildcardReference public void visitCtIntersectionTypeReference(final spoon.reflect.reference.CtIntersectionTypeReference reference) { spoon.reflect.reference.CtIntersectionTypeReference other = ((spoon.reflect.reference.CtIntersectionTypeReference) (this.stack.peek())); enter(reference); - biScan(reference.getPackage(), other.getPackage()); - biScan(reference.getDeclaringType(), other.getDeclaringType()); + biScan(spoon.reflect.path.CtRole.PACKAGE_REF, reference.getPackage(), other.getPackage()); + biScan(spoon.reflect.path.CtRole.DECLARING_TYPE, reference.getDeclaringType(), other.getDeclaringType()); // TypeReferenceTest fails if actual type arguments are really not set-able on CtIntersectionTypeReference - biScan(reference.getActualTypeArguments(), other.getActualTypeArguments()); - biScan(reference.getAnnotations(), other.getAnnotations()); - biScan(reference.getBounds(), other.getBounds()); + biScan(spoon.reflect.path.CtRole.TYPE_ARGUMENT, reference.getActualTypeArguments(), other.getActualTypeArguments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, reference.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.BOUND, reference.getBounds(), other.getBounds()); exit(reference); } @@ -715,11 +715,11 @@ public void visitCtIntersectionTypeReference(final spoon.reflect.reference.C public void visitCtTypeReference(final spoon.reflect.reference.CtTypeReference reference) { spoon.reflect.reference.CtTypeReference other = ((spoon.reflect.reference.CtTypeReference) (this.stack.peek())); enter(reference); - biScan(reference.getPackage(), other.getPackage()); - biScan(reference.getDeclaringType(), other.getDeclaringType()); - biScan(reference.getActualTypeArguments(), other.getActualTypeArguments()); - biScan(reference.getAnnotations(), other.getAnnotations()); - biScan(reference.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.PACKAGE_REF, reference.getPackage(), other.getPackage()); + biScan(spoon.reflect.path.CtRole.DECLARING_TYPE, reference.getDeclaringType(), other.getDeclaringType()); + biScan(spoon.reflect.path.CtRole.TYPE_ARGUMENT, reference.getActualTypeArguments(), other.getActualTypeArguments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, reference.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.COMMENT, reference.getComments(), other.getComments()); exit(reference); } @@ -728,10 +728,10 @@ public void visitCtTypeReference(final spoon.reflect.reference.CtTypeReferen public void visitCtTypeAccess(final spoon.reflect.code.CtTypeAccess typeAccess) { spoon.reflect.code.CtTypeAccess other = ((spoon.reflect.code.CtTypeAccess) (this.stack.peek())); enter(typeAccess); - biScan(typeAccess.getAnnotations(), other.getAnnotations()); - biScan(typeAccess.getTypeCasts(), other.getTypeCasts()); - biScan(typeAccess.getAccessedType(), other.getAccessedType()); - biScan(typeAccess.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, typeAccess.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.CAST, typeAccess.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.ACCESSED_TYPE, typeAccess.getAccessedType(), other.getAccessedType()); + biScan(spoon.reflect.path.CtRole.COMMENT, typeAccess.getComments(), other.getComments()); exit(typeAccess); } @@ -739,11 +739,11 @@ public void visitCtTypeAccess(final spoon.reflect.code.CtTypeAccess typeA public void visitCtUnaryOperator(final spoon.reflect.code.CtUnaryOperator operator) { spoon.reflect.code.CtUnaryOperator other = ((spoon.reflect.code.CtUnaryOperator) (this.stack.peek())); enter(operator); - biScan(operator.getAnnotations(), other.getAnnotations()); - biScan(operator.getType(), other.getType()); - biScan(operator.getTypeCasts(), other.getTypeCasts()); - biScan(operator.getOperand(), other.getOperand()); - biScan(operator.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, operator.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.TYPE, operator.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.CAST, operator.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, operator.getOperand(), other.getOperand()); + biScan(spoon.reflect.path.CtRole.COMMENT, operator.getComments(), other.getComments()); exit(operator); } @@ -752,10 +752,10 @@ public void visitCtUnaryOperator(final spoon.reflect.code.CtUnaryOperator public void visitCtVariableRead(final spoon.reflect.code.CtVariableRead variableRead) { spoon.reflect.code.CtVariableRead other = ((spoon.reflect.code.CtVariableRead) (this.stack.peek())); enter(variableRead); - biScan(variableRead.getAnnotations(), other.getAnnotations()); - biScan(variableRead.getTypeCasts(), other.getTypeCasts()); - biScan(variableRead.getVariable(), other.getVariable()); - biScan(variableRead.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, variableRead.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.CAST, variableRead.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.VARIABLE, variableRead.getVariable(), other.getVariable()); + biScan(spoon.reflect.path.CtRole.COMMENT, variableRead.getComments(), other.getComments()); exit(variableRead); } @@ -764,10 +764,10 @@ public void visitCtVariableRead(final spoon.reflect.code.CtVariableRead v public void visitCtVariableWrite(final spoon.reflect.code.CtVariableWrite variableWrite) { spoon.reflect.code.CtVariableWrite other = ((spoon.reflect.code.CtVariableWrite) (this.stack.peek())); enter(variableWrite); - biScan(variableWrite.getAnnotations(), other.getAnnotations()); - biScan(variableWrite.getTypeCasts(), other.getTypeCasts()); - biScan(variableWrite.getVariable(), other.getVariable()); - biScan(variableWrite.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, variableWrite.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.CAST, variableWrite.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.VARIABLE, variableWrite.getVariable(), other.getVariable()); + biScan(spoon.reflect.path.CtRole.COMMENT, variableWrite.getComments(), other.getComments()); exit(variableWrite); } @@ -775,10 +775,10 @@ public void visitCtVariableWrite(final spoon.reflect.code.CtVariableWrite public void visitCtWhile(final spoon.reflect.code.CtWhile whileLoop) { spoon.reflect.code.CtWhile other = ((spoon.reflect.code.CtWhile) (this.stack.peek())); enter(whileLoop); - biScan(whileLoop.getAnnotations(), other.getAnnotations()); - biScan(whileLoop.getLoopingExpression(), other.getLoopingExpression()); - biScan(whileLoop.getBody(), other.getBody()); - biScan(whileLoop.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, whileLoop.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.EXPRESSION, whileLoop.getLoopingExpression(), other.getLoopingExpression()); + biScan(spoon.reflect.path.CtRole.BODY, whileLoop.getBody(), other.getBody()); + biScan(spoon.reflect.path.CtRole.COMMENT, whileLoop.getComments(), other.getComments()); exit(whileLoop); } @@ -786,10 +786,10 @@ public void visitCtWhile(final spoon.reflect.code.CtWhile whileLoop) { public void visitCtCodeSnippetExpression(final spoon.reflect.code.CtCodeSnippetExpression expression) { spoon.reflect.code.CtCodeSnippetExpression other = ((spoon.reflect.code.CtCodeSnippetExpression) (this.stack.peek())); enter(expression); - biScan(expression.getType(), other.getType()); - biScan(expression.getComments(), other.getComments()); - biScan(expression.getAnnotations(), other.getAnnotations()); - biScan(expression.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.TYPE, expression.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.COMMENT, expression.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, expression.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.CAST, expression.getTypeCasts(), other.getTypeCasts()); exit(expression); } @@ -797,8 +797,8 @@ public void visitCtCodeSnippetExpression(final spoon.reflect.code.CtCodeSnip public void visitCtCodeSnippetStatement(final spoon.reflect.code.CtCodeSnippetStatement statement) { spoon.reflect.code.CtCodeSnippetStatement other = ((spoon.reflect.code.CtCodeSnippetStatement) (this.stack.peek())); enter(statement); - biScan(statement.getComments(), other.getComments()); - biScan(statement.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.COMMENT, statement.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, statement.getAnnotations(), other.getAnnotations()); exit(statement); } @@ -806,7 +806,7 @@ public void visitCtCodeSnippetStatement(final spoon.reflect.code.CtCodeSnippetSt public void visitCtUnboundVariableReference(final spoon.reflect.reference.CtUnboundVariableReference reference) { spoon.reflect.reference.CtUnboundVariableReference other = ((spoon.reflect.reference.CtUnboundVariableReference) (this.stack.peek())); enter(reference); - biScan(reference.getType(), other.getType()); + biScan(spoon.reflect.path.CtRole.TYPE, reference.getType(), other.getType()); exit(reference); } @@ -815,11 +815,11 @@ public void visitCtUnboundVariableReference(final spoon.reflect.reference.Ct public void visitCtFieldRead(final spoon.reflect.code.CtFieldRead fieldRead) { spoon.reflect.code.CtFieldRead other = ((spoon.reflect.code.CtFieldRead) (this.stack.peek())); enter(fieldRead); - biScan(fieldRead.getAnnotations(), other.getAnnotations()); - biScan(fieldRead.getTypeCasts(), other.getTypeCasts()); - biScan(fieldRead.getTarget(), other.getTarget()); - biScan(fieldRead.getVariable(), other.getVariable()); - biScan(fieldRead.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, fieldRead.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.CAST, fieldRead.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.TARGET, fieldRead.getTarget(), other.getTarget()); + biScan(spoon.reflect.path.CtRole.VARIABLE, fieldRead.getVariable(), other.getVariable()); + biScan(spoon.reflect.path.CtRole.COMMENT, fieldRead.getComments(), other.getComments()); exit(fieldRead); } @@ -828,11 +828,11 @@ public void visitCtFieldRead(final spoon.reflect.code.CtFieldRead fieldRe public void visitCtFieldWrite(final spoon.reflect.code.CtFieldWrite fieldWrite) { spoon.reflect.code.CtFieldWrite other = ((spoon.reflect.code.CtFieldWrite) (this.stack.peek())); enter(fieldWrite); - biScan(fieldWrite.getAnnotations(), other.getAnnotations()); - biScan(fieldWrite.getTypeCasts(), other.getTypeCasts()); - biScan(fieldWrite.getTarget(), other.getTarget()); - biScan(fieldWrite.getVariable(), other.getVariable()); - biScan(fieldWrite.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, fieldWrite.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.CAST, fieldWrite.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.TARGET, fieldWrite.getTarget(), other.getTarget()); + biScan(spoon.reflect.path.CtRole.VARIABLE, fieldWrite.getVariable(), other.getVariable()); + biScan(spoon.reflect.path.CtRole.COMMENT, fieldWrite.getComments(), other.getComments()); exit(fieldWrite); } @@ -841,11 +841,11 @@ public void visitCtFieldWrite(final spoon.reflect.code.CtFieldWrite field public void visitCtSuperAccess(final spoon.reflect.code.CtSuperAccess f) { spoon.reflect.code.CtSuperAccess other = ((spoon.reflect.code.CtSuperAccess) (this.stack.peek())); enter(f); - biScan(f.getComments(), other.getComments()); - biScan(f.getAnnotations(), other.getAnnotations()); - biScan(f.getTypeCasts(), other.getTypeCasts()); - biScan(f.getTarget(), other.getTarget()); - biScan(f.getVariable(), other.getVariable()); + biScan(spoon.reflect.path.CtRole.COMMENT, f.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, f.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.CAST, f.getTypeCasts(), other.getTypeCasts()); + biScan(spoon.reflect.path.CtRole.TARGET, f.getTarget(), other.getTarget()); + biScan(spoon.reflect.path.CtRole.VARIABLE, f.getVariable(), other.getVariable()); exit(f); } @@ -854,8 +854,8 @@ public void visitCtSuperAccess(final spoon.reflect.code.CtSuperAccess f) public void visitCtComment(final spoon.reflect.code.CtComment comment) { spoon.reflect.code.CtComment other = ((spoon.reflect.code.CtComment) (this.stack.peek())); enter(comment); - biScan(comment.getComments(), other.getComments()); - biScan(comment.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.COMMENT, comment.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, comment.getAnnotations(), other.getAnnotations()); exit(comment); } @@ -864,9 +864,9 @@ public void visitCtComment(final spoon.reflect.code.CtComment comment) { public void visitCtJavaDoc(final spoon.reflect.code.CtJavaDoc javaDoc) { spoon.reflect.code.CtJavaDoc other = ((spoon.reflect.code.CtJavaDoc) (this.stack.peek())); enter(javaDoc); - biScan(javaDoc.getComments(), other.getComments()); - biScan(javaDoc.getAnnotations(), other.getAnnotations()); - biScan(javaDoc.getTags(), other.getTags()); + biScan(spoon.reflect.path.CtRole.COMMENT, javaDoc.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, javaDoc.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.COMMENT_TAG, javaDoc.getTags(), other.getTags()); exit(javaDoc); } @@ -875,8 +875,8 @@ public void visitCtJavaDoc(final spoon.reflect.code.CtJavaDoc javaDoc) { public void visitCtJavaDocTag(final spoon.reflect.code.CtJavaDocTag docTag) { spoon.reflect.code.CtJavaDocTag other = ((spoon.reflect.code.CtJavaDocTag) (this.stack.peek())); enter(docTag); - biScan(docTag.getComments(), other.getComments()); - biScan(docTag.getAnnotations(), other.getAnnotations()); + biScan(spoon.reflect.path.CtRole.COMMENT, docTag.getComments(), other.getComments()); + biScan(spoon.reflect.path.CtRole.ANNOTATION, docTag.getAnnotations(), other.getAnnotations()); exit(docTag); } } diff --git a/src/main/java/spoon/reflect/visitor/CtScanner.java b/src/main/java/spoon/reflect/visitor/CtScanner.java index f5720f5d962..04c3fff4e22 100644 --- a/src/main/java/spoon/reflect/visitor/CtScanner.java +++ b/src/main/java/spoon/reflect/visitor/CtScanner.java @@ -16,6 +16,11 @@ */ package spoon.reflect.visitor; + +import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; import spoon.reflect.code.CtAnnotationFieldAccess; import spoon.reflect.code.CtArrayRead; import spoon.reflect.code.CtArrayWrite; @@ -80,6 +85,7 @@ import spoon.reflect.declaration.CtPackage; import spoon.reflect.declaration.CtParameter; import spoon.reflect.declaration.CtTypeParameter; +import spoon.reflect.path.CtRole; import spoon.reflect.reference.CtArrayTypeReference; import spoon.reflect.reference.CtCatchVariableReference; import spoon.reflect.reference.CtExecutableReference; @@ -93,10 +99,6 @@ import spoon.reflect.reference.CtUnboundVariableReference; import spoon.reflect.reference.CtWildcardReference; -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; /** * This visitor implements a deep-search scan on the model. @@ -131,34 +133,40 @@ protected void exit(CtElement e) { /** * Generically scans a collection of meta-model elements. */ - public void scan(Collection elements) { - if ((elements != null)) { + public void scan(CtRole role, Collection elements) { + if (elements != null) { // we use defensive copy so as to be able to change the class while scanning // otherwise one gets a ConcurrentModificationException for (CtElement e : new ArrayList<>(elements)) { - scan(e); + scan(role, e); } } + } + public void scan(Collection elements) { + scan(null, elements); } /** * Generically scans a meta-model element. */ + public void scan(CtRole role, CtElement element) { + scan(element); + } + public void scan(CtElement element) { - if ((element != null)) { + if (element != null) { element.accept(this); } } - public void visitCtAnnotation( - final CtAnnotation annotation) { + public void visitCtAnnotation(final CtAnnotation annotation) { enter(annotation); - scan(annotation.getType()); - scan(annotation.getComments()); - scan(annotation.getAnnotationType()); - scan(annotation.getAnnotations()); - scan(annotation.getValues()); + scan(CtRole.TYPE, annotation.getType()); + scan(CtRole.COMMENT, annotation.getComments()); + scan(CtRole.ANNOTATION_TYPE, annotation.getAnnotationType()); + scan(CtRole.ANNOTATION, annotation.getAnnotations()); + scan(CtRole.VALUE, annotation.getValues()); exit(annotation); } @@ -166,721 +174,714 @@ public void visitCtAnnotation( * Generically scans an object that can be an element, a reference, or a * collection of those. */ - public void scan(Object o) { + public void scan(CtRole role, Object o) { if (o instanceof CtElement) { - scan((CtElement) o); + scan(role, ((CtElement) (o))); } if (o instanceof Collection) { - for (Object obj : (Collection) o) { - scan(obj); + for (Object obj : ((Collection) (o))) { + scan(role, obj); } } if (o instanceof Map) { - for (Object obj : ((Map) o).values()) { - scan(obj); + for (Object obj : ((Map) (o)).values()) { + scan(role, obj); } } } - public void visitCtAnnotationType( - final CtAnnotationType annotationType) { + public void visitCtAnnotationType(final CtAnnotationType annotationType) { enter(annotationType); - scan(annotationType.getAnnotations()); - scan(annotationType.getTypeMembers()); - scan(annotationType.getComments()); + scan(CtRole.ANNOTATION, annotationType.getAnnotations()); + scan(CtRole.TYPE_MEMBER, annotationType.getTypeMembers()); + scan(CtRole.COMMENT, annotationType.getComments()); exit(annotationType); } public void visitCtAnonymousExecutable(final CtAnonymousExecutable anonymousExec) { enter(anonymousExec); - scan(anonymousExec.getAnnotations()); - scan(anonymousExec.getBody()); - scan(anonymousExec.getComments()); + scan(CtRole.ANNOTATION, anonymousExec.getAnnotations()); + scan(CtRole.BODY, anonymousExec.getBody()); + scan(CtRole.COMMENT, anonymousExec.getComments()); exit(anonymousExec); } @Override public void visitCtArrayRead(final CtArrayRead arrayRead) { enter(arrayRead); - scan(arrayRead.getAnnotations()); - scan(arrayRead.getType()); - scan(arrayRead.getTypeCasts()); - scan(arrayRead.getTarget()); - scan(arrayRead.getIndexExpression()); - scan(arrayRead.getComments()); + scan(CtRole.ANNOTATION, arrayRead.getAnnotations()); + scan(CtRole.TYPE, arrayRead.getType()); + scan(CtRole.CAST, arrayRead.getTypeCasts()); + scan(CtRole.TARGET, arrayRead.getTarget()); + scan(CtRole.EXPRESSION, arrayRead.getIndexExpression()); + scan(CtRole.COMMENT, arrayRead.getComments()); exit(arrayRead); } @Override public void visitCtArrayWrite(final CtArrayWrite arrayWrite) { enter(arrayWrite); - scan(arrayWrite.getAnnotations()); - scan(arrayWrite.getType()); - scan(arrayWrite.getTypeCasts()); - scan(arrayWrite.getTarget()); - scan(arrayWrite.getIndexExpression()); - scan(arrayWrite.getComments()); + scan(CtRole.ANNOTATION, arrayWrite.getAnnotations()); + scan(CtRole.TYPE, arrayWrite.getType()); + scan(CtRole.CAST, arrayWrite.getTypeCasts()); + scan(CtRole.TARGET, arrayWrite.getTarget()); + scan(CtRole.EXPRESSION, arrayWrite.getIndexExpression()); + scan(CtRole.COMMENT, arrayWrite.getComments()); exit(arrayWrite); } public void visitCtArrayTypeReference(final CtArrayTypeReference reference) { enter(reference); - scan(reference.getComments()); - scan(reference.getPackage()); - scan(reference.getDeclaringType()); - scan(reference.getComponentType()); - scan(reference.getActualTypeArguments()); - scan(reference.getAnnotations()); + scan(CtRole.COMMENT, reference.getComments()); + scan(CtRole.PACKAGE_REF, reference.getPackage()); + scan(CtRole.DECLARING_TYPE, reference.getDeclaringType()); + scan(CtRole.TYPE, reference.getComponentType()); + scan(CtRole.TYPE_ARGUMENT, reference.getActualTypeArguments()); + scan(CtRole.ANNOTATION, reference.getAnnotations()); exit(reference); } public void visitCtAssert(final CtAssert asserted) { enter(asserted); - scan(asserted.getAnnotations()); - scan(asserted.getAssertExpression()); - scan(asserted.getExpression()); - scan(asserted.getComments()); + scan(CtRole.ANNOTATION, asserted.getAnnotations()); + scan(CtRole.CONDITION, asserted.getAssertExpression()); + scan(CtRole.EXPRESSION, asserted.getExpression()); + scan(CtRole.COMMENT, asserted.getComments()); exit(asserted); } - public void visitCtAssignment( - final CtAssignment assignement) { + public void visitCtAssignment(final CtAssignment assignement) { enter(assignement); - scan(assignement.getAnnotations()); - scan(assignement.getType()); - scan(assignement.getTypeCasts()); - scan(assignement.getAssigned()); - scan(assignement.getAssignment()); - scan(assignement.getComments()); + scan(CtRole.ANNOTATION, assignement.getAnnotations()); + scan(CtRole.TYPE, assignement.getType()); + scan(CtRole.CAST, assignement.getTypeCasts()); + scan(CtRole.ASSIGNED, assignement.getAssigned()); + scan(CtRole.ASSIGNMENT, assignement.getAssignment()); + scan(CtRole.COMMENT, assignement.getComments()); exit(assignement); } public void visitCtBinaryOperator(final CtBinaryOperator operator) { enter(operator); - scan(operator.getAnnotations()); - scan(operator.getType()); - scan(operator.getTypeCasts()); - scan(operator.getLeftHandOperand()); - scan(operator.getRightHandOperand()); - scan(operator.getComments()); + scan(CtRole.ANNOTATION, operator.getAnnotations()); + scan(CtRole.TYPE, operator.getType()); + scan(CtRole.CAST, operator.getTypeCasts()); + scan(CtRole.LEFT_OPERAND, operator.getLeftHandOperand()); + scan(CtRole.RIGHT_OPERAND, operator.getRightHandOperand()); + scan(CtRole.COMMENT, operator.getComments()); exit(operator); } public void visitCtBlock(final CtBlock block) { enter(block); - scan(block.getAnnotations()); - scan(block.getStatements()); - scan(block.getComments()); + scan(CtRole.ANNOTATION, block.getAnnotations()); + scan(CtRole.STATEMENT, block.getStatements()); + scan(CtRole.COMMENT, block.getComments()); exit(block); } public void visitCtBreak(final CtBreak breakStatement) { enter(breakStatement); - scan(breakStatement.getAnnotations()); - scan(breakStatement.getComments()); + scan(CtRole.ANNOTATION, breakStatement.getAnnotations()); + scan(CtRole.COMMENT, breakStatement.getComments()); exit(breakStatement); } public void visitCtCase(final CtCase caseStatement) { enter(caseStatement); - scan(caseStatement.getAnnotations()); - scan(caseStatement.getCaseExpression()); - scan(caseStatement.getStatements()); - scan(caseStatement.getComments()); + scan(CtRole.ANNOTATION, caseStatement.getAnnotations()); + scan(CtRole.EXPRESSION, caseStatement.getCaseExpression()); + scan(CtRole.STATEMENT, caseStatement.getStatements()); + scan(CtRole.COMMENT, caseStatement.getComments()); exit(caseStatement); } public void visitCtCatch(final CtCatch catchBlock) { enter(catchBlock); - scan(catchBlock.getAnnotations()); - scan(catchBlock.getParameter()); - scan(catchBlock.getBody()); - scan(catchBlock.getComments()); + scan(CtRole.ANNOTATION, catchBlock.getAnnotations()); + scan(CtRole.PARAMETER, catchBlock.getParameter()); + scan(CtRole.BODY, catchBlock.getBody()); + scan(CtRole.COMMENT, catchBlock.getComments()); exit(catchBlock); } public void visitCtClass(final CtClass ctClass) { enter(ctClass); - scan(ctClass.getAnnotations()); - scan(ctClass.getSuperclass()); - scan(ctClass.getSuperInterfaces()); - scan(ctClass.getFormalCtTypeParameters()); - scan(ctClass.getTypeMembers()); - scan(ctClass.getComments()); + scan(CtRole.ANNOTATION, ctClass.getAnnotations()); + scan(CtRole.SUPER_TYPE, ctClass.getSuperclass()); + scan(CtRole.INTERFACE, ctClass.getSuperInterfaces()); + scan(CtRole.TYPE_PARAMETER, ctClass.getFormalCtTypeParameters()); + scan(CtRole.TYPE_MEMBER, ctClass.getTypeMembers()); + scan(CtRole.COMMENT, ctClass.getComments()); exit(ctClass); } @Override public void visitCtTypeParameter(CtTypeParameter typeParameter) { enter(typeParameter); - scan(typeParameter.getAnnotations()); - scan(typeParameter.getSuperclass()); - scan(typeParameter.getComments()); + scan(CtRole.ANNOTATION, typeParameter.getAnnotations()); + scan(CtRole.SUPER_TYPE, typeParameter.getSuperclass()); + scan(CtRole.COMMENT, typeParameter.getComments()); exit(typeParameter); } public void visitCtConditional(final CtConditional conditional) { enter(conditional); - scan(conditional.getType()); - scan(conditional.getAnnotations()); - scan(conditional.getCondition()); - scan(conditional.getThenExpression()); - scan(conditional.getElseExpression()); - scan(conditional.getComments()); - scan(conditional.getTypeCasts()); + scan(CtRole.TYPE, conditional.getType()); + scan(CtRole.ANNOTATION, conditional.getAnnotations()); + scan(CtRole.CONDITION, conditional.getCondition()); + scan(CtRole.THEN, conditional.getThenExpression()); + scan(CtRole.ELSE, conditional.getElseExpression()); + scan(CtRole.COMMENT, conditional.getComments()); + scan(CtRole.CAST, conditional.getTypeCasts()); exit(conditional); } public void visitCtConstructor(final CtConstructor c) { enter(c); - scan(c.getAnnotations()); - scan(c.getParameters()); - scan(c.getThrownTypes()); - scan(c.getFormalCtTypeParameters()); - scan(c.getBody()); - scan(c.getComments()); + scan(CtRole.ANNOTATION, c.getAnnotations()); + scan(CtRole.PARAMETER, c.getParameters()); + scan(CtRole.THROWN, c.getThrownTypes()); + scan(CtRole.TYPE_PARAMETER, c.getFormalCtTypeParameters()); + scan(CtRole.BODY, c.getBody()); + scan(CtRole.COMMENT, c.getComments()); exit(c); } public void visitCtContinue(final CtContinue continueStatement) { enter(continueStatement); - scan(continueStatement.getAnnotations()); - scan(continueStatement.getComments()); + scan(CtRole.ANNOTATION, continueStatement.getAnnotations()); + scan(CtRole.COMMENT, continueStatement.getComments()); exit(continueStatement); } public void visitCtDo(final CtDo doLoop) { enter(doLoop); - scan(doLoop.getAnnotations()); - scan(doLoop.getLoopingExpression()); - scan(doLoop.getBody()); - scan(doLoop.getComments()); + scan(CtRole.ANNOTATION, doLoop.getAnnotations()); + scan(CtRole.EXPRESSION, doLoop.getLoopingExpression()); + scan(CtRole.BODY, doLoop.getBody()); + scan(CtRole.COMMENT, doLoop.getComments()); exit(doLoop); } public > void visitCtEnum(final CtEnum ctEnum) { enter(ctEnum); - scan(ctEnum.getAnnotations()); - scan(ctEnum.getSuperInterfaces()); - scan(ctEnum.getTypeMembers()); - scan(ctEnum.getEnumValues()); - scan(ctEnum.getComments()); + scan(CtRole.ANNOTATION, ctEnum.getAnnotations()); + scan(CtRole.INTERFACE, ctEnum.getSuperInterfaces()); + scan(CtRole.TYPE_MEMBER, ctEnum.getTypeMembers()); + scan(CtRole.VALUE, ctEnum.getEnumValues()); + scan(CtRole.COMMENT, ctEnum.getComments()); exit(ctEnum); } - public void visitCtExecutableReference( - final CtExecutableReference reference) { + public void visitCtExecutableReference(final CtExecutableReference reference) { enter(reference); - scan(reference.getDeclaringType()); - scan(reference.getType()); - scan(reference.getParameters()); - scan(reference.getActualTypeArguments()); - scan(reference.getAnnotations()); - scan(reference.getComments()); + scan(CtRole.DECLARING_TYPE, reference.getDeclaringType()); + scan(CtRole.TYPE, reference.getType()); + scan(CtRole.ARGUMENT_TYPE, reference.getParameters()); + scan(CtRole.TYPE_ARGUMENT, reference.getActualTypeArguments()); + scan(CtRole.ANNOTATION, reference.getAnnotations()); + scan(CtRole.COMMENT, reference.getComments()); exit(reference); } public void visitCtField(final CtField f) { enter(f); - scan(f.getAnnotations()); - scan(f.getType()); - scan(f.getDefaultExpression()); - scan(f.getComments()); + scan(CtRole.ANNOTATION, f.getAnnotations()); + scan(CtRole.TYPE, f.getType()); + scan(CtRole.DEFAULT_EXPRESSION, f.getDefaultExpression()); + scan(CtRole.COMMENT, f.getComments()); exit(f); } @Override public void visitCtEnumValue(final CtEnumValue enumValue) { enter(enumValue); - scan(enumValue.getAnnotations()); - scan(enumValue.getType()); - scan(enumValue.getDefaultExpression()); - scan(enumValue.getComments()); + scan(CtRole.ANNOTATION, enumValue.getAnnotations()); + scan(CtRole.TYPE, enumValue.getType()); + scan(CtRole.DEFAULT_EXPRESSION, enumValue.getDefaultExpression()); + scan(CtRole.COMMENT, enumValue.getComments()); exit(enumValue); } @Override public void visitCtThisAccess(final CtThisAccess thisAccess) { enter(thisAccess); - scan(thisAccess.getComments()); - scan(thisAccess.getAnnotations()); - scan(thisAccess.getType()); - scan(thisAccess.getTypeCasts()); - scan(thisAccess.getTarget()); + scan(CtRole.COMMENT, thisAccess.getComments()); + scan(CtRole.ANNOTATION, thisAccess.getAnnotations()); + scan(CtRole.TYPE, thisAccess.getType()); + scan(CtRole.CAST, thisAccess.getTypeCasts()); + scan(CtRole.TARGET, thisAccess.getTarget()); exit(thisAccess); } - public void visitCtAnnotationFieldAccess( - final CtAnnotationFieldAccess annotationFieldAccess) { + public void visitCtAnnotationFieldAccess(final CtAnnotationFieldAccess annotationFieldAccess) { enter(annotationFieldAccess); - scan(annotationFieldAccess.getComments()); - scan(annotationFieldAccess.getAnnotations()); - scan(annotationFieldAccess.getTypeCasts()); - scan(annotationFieldAccess.getTarget()); - scan(annotationFieldAccess.getVariable()); + scan(CtRole.COMMENT, annotationFieldAccess.getComments()); + scan(CtRole.ANNOTATION, annotationFieldAccess.getAnnotations()); + scan(CtRole.CAST, annotationFieldAccess.getTypeCasts()); + scan(CtRole.TARGET, annotationFieldAccess.getTarget()); + scan(CtRole.VARIABLE, annotationFieldAccess.getVariable()); exit(annotationFieldAccess); } public void visitCtFieldReference(final CtFieldReference reference) { enter(reference); - scan(reference.getDeclaringType()); - scan(reference.getType()); - scan(reference.getAnnotations()); + scan(CtRole.DECLARING_TYPE, reference.getDeclaringType()); + scan(CtRole.TYPE, reference.getType()); + scan(CtRole.ANNOTATION, reference.getAnnotations()); exit(reference); } public void visitCtFor(final CtFor forLoop) { enter(forLoop); - scan(forLoop.getAnnotations()); - scan(forLoop.getForInit()); - scan(forLoop.getExpression()); - scan(forLoop.getForUpdate()); - scan(forLoop.getBody()); - scan(forLoop.getComments()); + scan(CtRole.ANNOTATION, forLoop.getAnnotations()); + scan(CtRole.FOR_INIT, forLoop.getForInit()); + scan(CtRole.EXPRESSION, forLoop.getExpression()); + scan(CtRole.FOR_UPDATE, forLoop.getForUpdate()); + scan(CtRole.BODY, forLoop.getBody()); + scan(CtRole.COMMENT, forLoop.getComments()); exit(forLoop); } public void visitCtForEach(final CtForEach foreach) { enter(foreach); - scan(foreach.getAnnotations()); - scan(foreach.getVariable()); - scan(foreach.getExpression()); - scan(foreach.getBody()); - scan(foreach.getComments()); + scan(CtRole.ANNOTATION, foreach.getAnnotations()); + scan(CtRole.FOREACH_VARIABLE, foreach.getVariable()); + scan(CtRole.EXPRESSION, foreach.getExpression()); + scan(CtRole.BODY, foreach.getBody()); + scan(CtRole.COMMENT, foreach.getComments()); exit(foreach); } public void visitCtIf(final CtIf ifElement) { enter(ifElement); - scan(ifElement.getAnnotations()); - scan(ifElement.getCondition()); - scan((CtStatement) ifElement.getThenStatement()); - scan((CtStatement) ifElement.getElseStatement()); - scan(ifElement.getComments()); + scan(CtRole.ANNOTATION, ifElement.getAnnotations()); + scan(CtRole.CONDITION, ifElement.getCondition()); + scan(CtRole.THEN, ((CtStatement) (ifElement.getThenStatement()))); + scan(CtRole.ELSE, ((CtStatement) (ifElement.getElseStatement()))); + scan(CtRole.COMMENT, ifElement.getComments()); exit(ifElement); } public void visitCtInterface(final CtInterface intrface) { enter(intrface); - scan(intrface.getAnnotations()); - scan(intrface.getSuperInterfaces()); - scan(intrface.getFormalCtTypeParameters()); - scan(intrface.getTypeMembers()); - scan(intrface.getComments()); + scan(CtRole.ANNOTATION, intrface.getAnnotations()); + scan(CtRole.INTERFACE, intrface.getSuperInterfaces()); + scan(CtRole.TYPE_PARAMETER, intrface.getFormalCtTypeParameters()); + scan(CtRole.TYPE_MEMBER, intrface.getTypeMembers()); + scan(CtRole.COMMENT, intrface.getComments()); exit(intrface); } public void visitCtInvocation(final CtInvocation invocation) { enter(invocation); - scan(invocation.getAnnotations()); - scan(invocation.getTypeCasts()); - scan(invocation.getTarget()); - scan(invocation.getExecutable()); - scan(invocation.getArguments()); - scan(invocation.getComments()); + scan(CtRole.ANNOTATION, invocation.getAnnotations()); + scan(CtRole.CAST, invocation.getTypeCasts()); + scan(CtRole.TARGET, invocation.getTarget()); + scan(CtRole.EXECUTABLE_REF, invocation.getExecutable()); + scan(CtRole.ARGUMENT, invocation.getArguments()); + scan(CtRole.COMMENT, invocation.getComments()); exit(invocation); } public void visitCtLiteral(final CtLiteral literal) { enter(literal); - scan(literal.getAnnotations()); - scan(literal.getType()); - scan(literal.getTypeCasts()); - scan(literal.getComments()); + scan(CtRole.ANNOTATION, literal.getAnnotations()); + scan(CtRole.TYPE, literal.getType()); + scan(CtRole.CAST, literal.getTypeCasts()); + scan(CtRole.COMMENT, literal.getComments()); exit(literal); } public void visitCtLocalVariable(final CtLocalVariable localVariable) { enter(localVariable); - scan(localVariable.getAnnotations()); - scan(localVariable.getType()); - scan(localVariable.getDefaultExpression()); - scan(localVariable.getComments()); + scan(CtRole.ANNOTATION, localVariable.getAnnotations()); + scan(CtRole.TYPE, localVariable.getType()); + scan(CtRole.DEFAULT_EXPRESSION, localVariable.getDefaultExpression()); + scan(CtRole.COMMENT, localVariable.getComments()); exit(localVariable); } - public void visitCtLocalVariableReference( - final CtLocalVariableReference reference) { + public void visitCtLocalVariableReference(final CtLocalVariableReference reference) { enter(reference); - scan(reference.getType()); - scan(reference.getAnnotations()); + scan(CtRole.TYPE, reference.getType()); + scan(CtRole.ANNOTATION, reference.getAnnotations()); exit(reference); } public void visitCtCatchVariable(final CtCatchVariable catchVariable) { enter(catchVariable); - scan(catchVariable.getComments()); - scan(catchVariable.getAnnotations()); - scan(catchVariable.getMultiTypes()); + scan(CtRole.COMMENT, catchVariable.getComments()); + scan(CtRole.ANNOTATION, catchVariable.getAnnotations()); + scan(CtRole.TYPE, catchVariable.getMultiTypes()); exit(catchVariable); } public void visitCtCatchVariableReference(final CtCatchVariableReference reference) { enter(reference); - scan(reference.getComments()); - scan(reference.getType()); - scan(reference.getAnnotations()); + scan(CtRole.COMMENT, reference.getComments()); + scan(CtRole.TYPE, reference.getType()); + scan(CtRole.ANNOTATION, reference.getAnnotations()); exit(reference); } public void visitCtMethod(final CtMethod m) { enter(m); - scan(m.getAnnotations()); - scan(m.getFormalCtTypeParameters()); - scan(m.getType()); - scan(m.getParameters()); - scan(m.getThrownTypes()); - scan(m.getBody()); - scan(m.getComments()); + scan(CtRole.ANNOTATION, m.getAnnotations()); + scan(CtRole.TYPE_PARAMETER, m.getFormalCtTypeParameters()); + scan(CtRole.TYPE, m.getType()); + scan(CtRole.PARAMETER, m.getParameters()); + scan(CtRole.THROWN, m.getThrownTypes()); + scan(CtRole.BODY, m.getBody()); + scan(CtRole.COMMENT, m.getComments()); exit(m); } @Override public void visitCtAnnotationMethod(CtAnnotationMethod annotationMethod) { enter(annotationMethod); - scan(annotationMethod.getAnnotations()); - scan(annotationMethod.getType()); - scan(annotationMethod.getDefaultExpression()); - scan(annotationMethod.getComments()); + scan(CtRole.ANNOTATION, annotationMethod.getAnnotations()); + scan(CtRole.TYPE, annotationMethod.getType()); + scan(CtRole.DEFAULT_EXPRESSION, annotationMethod.getDefaultExpression()); + scan(CtRole.COMMENT, annotationMethod.getComments()); exit(annotationMethod); } public void visitCtNewArray(final CtNewArray newArray) { enter(newArray); - scan(newArray.getAnnotations()); - scan(newArray.getType()); - scan(newArray.getTypeCasts()); - scan(newArray.getElements()); - scan(newArray.getDimensionExpressions()); - scan(newArray.getComments()); + scan(CtRole.ANNOTATION, newArray.getAnnotations()); + scan(CtRole.TYPE, newArray.getType()); + scan(CtRole.CAST, newArray.getTypeCasts()); + scan(CtRole.EXPRESSION, newArray.getElements()); + scan(CtRole.DIMENSION, newArray.getDimensionExpressions()); + scan(CtRole.COMMENT, newArray.getComments()); exit(newArray); } @Override public void visitCtConstructorCall(final CtConstructorCall ctConstructorCall) { enter(ctConstructorCall); - scan(ctConstructorCall.getAnnotations()); - scan(ctConstructorCall.getTypeCasts()); - scan(ctConstructorCall.getExecutable()); - scan(ctConstructorCall.getTarget()); - scan(ctConstructorCall.getArguments()); - scan(ctConstructorCall.getComments()); + scan(CtRole.ANNOTATION, ctConstructorCall.getAnnotations()); + scan(CtRole.CAST, ctConstructorCall.getTypeCasts()); + scan(CtRole.EXECUTABLE_REF, ctConstructorCall.getExecutable()); + scan(CtRole.TARGET, ctConstructorCall.getTarget()); + scan(CtRole.ARGUMENT, ctConstructorCall.getArguments()); + scan(CtRole.COMMENT, ctConstructorCall.getComments()); exit(ctConstructorCall); } public void visitCtNewClass(final CtNewClass newClass) { enter(newClass); - scan(newClass.getAnnotations()); - scan(newClass.getTypeCasts()); - scan(newClass.getExecutable()); - scan(newClass.getTarget()); - scan(newClass.getArguments()); - scan(newClass.getAnonymousClass()); - scan(newClass.getComments()); + scan(CtRole.ANNOTATION, newClass.getAnnotations()); + scan(CtRole.CAST, newClass.getTypeCasts()); + scan(CtRole.EXECUTABLE_REF, newClass.getExecutable()); + scan(CtRole.TARGET, newClass.getTarget()); + scan(CtRole.ARGUMENT, newClass.getArguments()); + scan(CtRole.NESTED_TYPE, newClass.getAnonymousClass()); + scan(CtRole.COMMENT, newClass.getComments()); exit(newClass); } @Override public void visitCtLambda(final CtLambda lambda) { enter(lambda); - scan(lambda.getAnnotations()); - scan(lambda.getType()); - scan(lambda.getTypeCasts()); - scan(lambda.getParameters()); - scan(lambda.getThrownTypes()); - scan(lambda.getBody()); - scan(lambda.getExpression()); - scan(lambda.getComments()); + scan(CtRole.ANNOTATION, lambda.getAnnotations()); + scan(CtRole.TYPE, lambda.getType()); + scan(CtRole.CAST, lambda.getTypeCasts()); + scan(CtRole.PARAMETER, lambda.getParameters()); + scan(CtRole.THROWN, lambda.getThrownTypes()); + scan(CtRole.BODY, lambda.getBody()); + scan(CtRole.EXPRESSION, lambda.getExpression()); + scan(CtRole.COMMENT, lambda.getComments()); exit(lambda); } @Override - public > void visitCtExecutableReferenceExpression( - final CtExecutableReferenceExpression expression) { + public > void visitCtExecutableReferenceExpression(final CtExecutableReferenceExpression expression) { enter(expression); - scan(expression.getComments()); - scan(expression.getAnnotations()); - scan(expression.getType()); - scan(expression.getTypeCasts()); - scan(expression.getExecutable()); - scan(expression.getTarget()); + scan(CtRole.COMMENT, expression.getComments()); + scan(CtRole.ANNOTATION, expression.getAnnotations()); + scan(CtRole.TYPE, expression.getType()); + scan(CtRole.CAST, expression.getTypeCasts()); + scan(CtRole.EXECUTABLE_REF, expression.getExecutable()); + scan(CtRole.TARGET, expression.getTarget()); exit(expression); } - public void visitCtOperatorAssignment( - final CtOperatorAssignment assignment) { + public void visitCtOperatorAssignment(final CtOperatorAssignment assignment) { enter(assignment); - scan(assignment.getAnnotations()); - scan(assignment.getType()); - scan(assignment.getTypeCasts()); - scan(assignment.getAssigned()); - scan(assignment.getAssignment()); - scan(assignment.getComments()); + scan(CtRole.ANNOTATION, assignment.getAnnotations()); + scan(CtRole.TYPE, assignment.getType()); + scan(CtRole.CAST, assignment.getTypeCasts()); + scan(CtRole.ASSIGNED, assignment.getAssigned()); + scan(CtRole.ASSIGNMENT, assignment.getAssignment()); + scan(CtRole.COMMENT, assignment.getComments()); exit(assignment); } public void visitCtPackage(final CtPackage ctPackage) { enter(ctPackage); - scan(ctPackage.getAnnotations()); - scan(ctPackage.getPackages()); - scan(ctPackage.getTypes()); - scan(ctPackage.getComments()); + scan(CtRole.ANNOTATION, ctPackage.getAnnotations()); + scan(CtRole.SUB_PACKAGE, ctPackage.getPackages()); + scan(CtRole.CONTAINED_TYPE, ctPackage.getTypes()); + scan(CtRole.COMMENT, ctPackage.getComments()); exit(ctPackage); } public void visitCtPackageReference(final CtPackageReference reference) { enter(reference); - scan(reference.getAnnotations()); + scan(CtRole.ANNOTATION, reference.getAnnotations()); exit(reference); } public void visitCtParameter(final CtParameter parameter) { enter(parameter); - scan(parameter.getAnnotations()); - scan(parameter.getType()); - scan(parameter.getComments()); + scan(CtRole.ANNOTATION, parameter.getAnnotations()); + scan(CtRole.TYPE, parameter.getType()); + scan(CtRole.COMMENT, parameter.getComments()); exit(parameter); } public void visitCtParameterReference(final CtParameterReference reference) { enter(reference); - scan(reference.getType()); - scan(reference.getAnnotations()); - scan(reference.getDeclaringExecutable()); + scan(CtRole.TYPE, reference.getType()); + scan(CtRole.ANNOTATION, reference.getAnnotations()); + scan(CtRole.EXECUTABLE_REF, reference.getDeclaringExecutable()); exit(reference); } public void visitCtReturn(final CtReturn returnStatement) { enter(returnStatement); - scan(returnStatement.getAnnotations()); - scan(returnStatement.getReturnedExpression()); - scan(returnStatement.getComments()); + scan(CtRole.ANNOTATION, returnStatement.getAnnotations()); + scan(CtRole.EXPRESSION, returnStatement.getReturnedExpression()); + scan(CtRole.COMMENT, returnStatement.getComments()); exit(returnStatement); } public void visitCtStatementList(final CtStatementList statements) { enter(statements); - scan(statements.getAnnotations()); - scan(statements.getStatements()); - scan(statements.getComments()); + scan(CtRole.ANNOTATION, statements.getAnnotations()); + scan(CtRole.STATEMENT, statements.getStatements()); + scan(CtRole.COMMENT, statements.getComments()); exit(statements); } public void visitCtSwitch(final CtSwitch switchStatement) { enter(switchStatement); - scan(switchStatement.getAnnotations()); - scan(switchStatement.getSelector()); - scan(switchStatement.getCases()); - scan(switchStatement.getComments()); + scan(CtRole.ANNOTATION, switchStatement.getAnnotations()); + scan(CtRole.EXPRESSION, switchStatement.getSelector()); + scan(CtRole.CASE, switchStatement.getCases()); + scan(CtRole.COMMENT, switchStatement.getComments()); exit(switchStatement); } public void visitCtSynchronized(final CtSynchronized synchro) { enter(synchro); - scan(synchro.getAnnotations()); - scan(synchro.getExpression()); - scan(synchro.getBlock()); - scan(synchro.getComments()); + scan(CtRole.ANNOTATION, synchro.getAnnotations()); + scan(CtRole.EXPRESSION, synchro.getExpression()); + scan(CtRole.BODY, synchro.getBlock()); + scan(CtRole.COMMENT, synchro.getComments()); exit(synchro); } public void visitCtThrow(final CtThrow throwStatement) { enter(throwStatement); - scan(throwStatement.getAnnotations()); - scan(throwStatement.getThrownExpression()); - scan(throwStatement.getComments()); + scan(CtRole.ANNOTATION, throwStatement.getAnnotations()); + scan(CtRole.EXPRESSION, throwStatement.getThrownExpression()); + scan(CtRole.COMMENT, throwStatement.getComments()); exit(throwStatement); } public void visitCtTry(final CtTry tryBlock) { enter(tryBlock); - scan(tryBlock.getAnnotations()); - scan(tryBlock.getBody()); - scan(tryBlock.getCatchers()); - scan(tryBlock.getFinalizer()); - scan(tryBlock.getComments()); + scan(CtRole.ANNOTATION, tryBlock.getAnnotations()); + scan(CtRole.BODY, tryBlock.getBody()); + scan(CtRole.CATCH, tryBlock.getCatchers()); + scan(CtRole.FINALIZER, tryBlock.getFinalizer()); + scan(CtRole.COMMENT, tryBlock.getComments()); exit(tryBlock); } @Override public void visitCtTryWithResource(final CtTryWithResource tryWithResource) { enter(tryWithResource); - scan(tryWithResource.getAnnotations()); - scan(tryWithResource.getResources()); - scan(tryWithResource.getBody()); - scan(tryWithResource.getCatchers()); - scan(tryWithResource.getFinalizer()); - scan(tryWithResource.getComments()); + scan(CtRole.ANNOTATION, tryWithResource.getAnnotations()); + scan(CtRole.TRY_RESOURCE, tryWithResource.getResources()); + scan(CtRole.BODY, tryWithResource.getBody()); + scan(CtRole.CATCH, tryWithResource.getCatchers()); + scan(CtRole.FINALIZER, tryWithResource.getFinalizer()); + scan(CtRole.COMMENT, tryWithResource.getComments()); exit(tryWithResource); } public void visitCtTypeParameterReference(final CtTypeParameterReference ref) { enter(ref); - scan(ref.getPackage()); - scan(ref.getDeclaringType()); - scan(ref.getAnnotations()); - scan(ref.getBoundingType()); + scan(CtRole.PACKAGE_REF, ref.getPackage()); + scan(CtRole.DECLARING_TYPE, ref.getDeclaringType()); + scan(CtRole.ANNOTATION, ref.getAnnotations()); + scan(CtRole.BOUNDING_TYPE, ref.getBoundingType()); exit(ref); } @Override public void visitCtWildcardReference(CtWildcardReference wildcardReference) { enter(wildcardReference); - scan(wildcardReference.getPackage()); - scan(wildcardReference.getDeclaringType()); - scan(wildcardReference.getAnnotations()); - scan(wildcardReference.getBoundingType()); + scan(CtRole.PACKAGE_REF, wildcardReference.getPackage()); + scan(CtRole.DECLARING_TYPE, wildcardReference.getDeclaringType()); + scan(CtRole.ANNOTATION, wildcardReference.getAnnotations()); + scan(CtRole.BOUNDING_TYPE, wildcardReference.getBoundingType()); exit(wildcardReference); } @Override public void visitCtIntersectionTypeReference(final CtIntersectionTypeReference reference) { enter(reference); - scan(reference.getPackage()); - scan(reference.getDeclaringType()); - //TypeReferenceTest fails if actual type arguments are really not set-able on CtIntersectionTypeReference - scan(reference.getActualTypeArguments()); - scan(reference.getAnnotations()); - scan(reference.getBounds()); + scan(CtRole.PACKAGE_REF, reference.getPackage()); + scan(CtRole.DECLARING_TYPE, reference.getDeclaringType()); + // TypeReferenceTest fails if actual type arguments are really not set-able on CtIntersectionTypeReference + scan(CtRole.TYPE_ARGUMENT, reference.getActualTypeArguments()); + scan(CtRole.ANNOTATION, reference.getAnnotations()); + scan(CtRole.BOUND, reference.getBounds()); exit(reference); } public void visitCtTypeReference(final CtTypeReference reference) { enter(reference); - scan(reference.getPackage()); - scan(reference.getDeclaringType()); - scan(reference.getActualTypeArguments()); - scan(reference.getAnnotations()); - scan(reference.getComments()); + scan(CtRole.PACKAGE_REF, reference.getPackage()); + scan(CtRole.DECLARING_TYPE, reference.getDeclaringType()); + scan(CtRole.TYPE_ARGUMENT, reference.getActualTypeArguments()); + scan(CtRole.ANNOTATION, reference.getAnnotations()); + scan(CtRole.COMMENT, reference.getComments()); exit(reference); } @Override public void visitCtTypeAccess(final CtTypeAccess typeAccess) { enter(typeAccess); - scan(typeAccess.getAnnotations()); - scan(typeAccess.getTypeCasts()); - scan(typeAccess.getAccessedType()); - scan(typeAccess.getComments()); + scan(CtRole.ANNOTATION, typeAccess.getAnnotations()); + scan(CtRole.CAST, typeAccess.getTypeCasts()); + scan(CtRole.ACCESSED_TYPE, typeAccess.getAccessedType()); + scan(CtRole.COMMENT, typeAccess.getComments()); exit(typeAccess); } public void visitCtUnaryOperator(final CtUnaryOperator operator) { enter(operator); - scan(operator.getAnnotations()); - scan(operator.getType()); - scan(operator.getTypeCasts()); - scan(operator.getOperand()); - scan(operator.getComments()); + scan(CtRole.ANNOTATION, operator.getAnnotations()); + scan(CtRole.TYPE, operator.getType()); + scan(CtRole.CAST, operator.getTypeCasts()); + scan(CtRole.EXPRESSION, operator.getOperand()); + scan(CtRole.COMMENT, operator.getComments()); exit(operator); } @Override public void visitCtVariableRead(final CtVariableRead variableRead) { enter(variableRead); - scan(variableRead.getAnnotations()); - scan(variableRead.getTypeCasts()); - scan(variableRead.getVariable()); - scan(variableRead.getComments()); + scan(CtRole.ANNOTATION, variableRead.getAnnotations()); + scan(CtRole.CAST, variableRead.getTypeCasts()); + scan(CtRole.VARIABLE, variableRead.getVariable()); + scan(CtRole.COMMENT, variableRead.getComments()); exit(variableRead); } @Override public void visitCtVariableWrite(final CtVariableWrite variableWrite) { enter(variableWrite); - scan(variableWrite.getAnnotations()); - scan(variableWrite.getTypeCasts()); - scan(variableWrite.getVariable()); - scan(variableWrite.getComments()); + scan(CtRole.ANNOTATION, variableWrite.getAnnotations()); + scan(CtRole.CAST, variableWrite.getTypeCasts()); + scan(CtRole.VARIABLE, variableWrite.getVariable()); + scan(CtRole.COMMENT, variableWrite.getComments()); exit(variableWrite); } public void visitCtWhile(final CtWhile whileLoop) { enter(whileLoop); - scan(whileLoop.getAnnotations()); - scan(whileLoop.getLoopingExpression()); - scan(whileLoop.getBody()); - scan(whileLoop.getComments()); + scan(CtRole.ANNOTATION, whileLoop.getAnnotations()); + scan(CtRole.EXPRESSION, whileLoop.getLoopingExpression()); + scan(CtRole.BODY, whileLoop.getBody()); + scan(CtRole.COMMENT, whileLoop.getComments()); exit(whileLoop); } public void visitCtCodeSnippetExpression(final CtCodeSnippetExpression expression) { enter(expression); - scan(expression.getType()); - scan(expression.getComments()); - scan(expression.getAnnotations()); - scan(expression.getTypeCasts()); + scan(CtRole.TYPE, expression.getType()); + scan(CtRole.COMMENT, expression.getComments()); + scan(CtRole.ANNOTATION, expression.getAnnotations()); + scan(CtRole.CAST, expression.getTypeCasts()); exit(expression); } public void visitCtCodeSnippetStatement(final CtCodeSnippetStatement statement) { enter(statement); - scan(statement.getComments()); - scan(statement.getAnnotations()); + scan(CtRole.COMMENT, statement.getComments()); + scan(CtRole.ANNOTATION, statement.getAnnotations()); exit(statement); } public void visitCtUnboundVariableReference(final CtUnboundVariableReference reference) { enter(reference); - scan(reference.getType()); + scan(CtRole.TYPE, reference.getType()); exit(reference); } @Override public void visitCtFieldRead(final CtFieldRead fieldRead) { enter(fieldRead); - scan(fieldRead.getAnnotations()); - scan(fieldRead.getTypeCasts()); - scan(fieldRead.getTarget()); - scan(fieldRead.getVariable()); - scan(fieldRead.getComments()); + scan(CtRole.ANNOTATION, fieldRead.getAnnotations()); + scan(CtRole.CAST, fieldRead.getTypeCasts()); + scan(CtRole.TARGET, fieldRead.getTarget()); + scan(CtRole.VARIABLE, fieldRead.getVariable()); + scan(CtRole.COMMENT, fieldRead.getComments()); exit(fieldRead); } @Override public void visitCtFieldWrite(final CtFieldWrite fieldWrite) { enter(fieldWrite); - scan(fieldWrite.getAnnotations()); - scan(fieldWrite.getTypeCasts()); - scan(fieldWrite.getTarget()); - scan(fieldWrite.getVariable()); - scan(fieldWrite.getComments()); + scan(CtRole.ANNOTATION, fieldWrite.getAnnotations()); + scan(CtRole.CAST, fieldWrite.getTypeCasts()); + scan(CtRole.TARGET, fieldWrite.getTarget()); + scan(CtRole.VARIABLE, fieldWrite.getVariable()); + scan(CtRole.COMMENT, fieldWrite.getComments()); exit(fieldWrite); } @Override public void visitCtSuperAccess(final CtSuperAccess f) { enter(f); - scan(f.getComments()); - scan(f.getAnnotations()); - scan(f.getTypeCasts()); - scan(f.getTarget()); - scan(f.getVariable()); + scan(CtRole.COMMENT, f.getComments()); + scan(CtRole.ANNOTATION, f.getAnnotations()); + scan(CtRole.CAST, f.getTypeCasts()); + scan(CtRole.TARGET, f.getTarget()); + scan(CtRole.VARIABLE, f.getVariable()); exit(f); } @Override public void visitCtComment(final CtComment comment) { enter(comment); - scan(comment.getComments()); - scan(comment.getAnnotations()); + scan(CtRole.COMMENT, comment.getComments()); + scan(CtRole.ANNOTATION, comment.getAnnotations()); exit(comment); } @Override public void visitCtJavaDoc(final CtJavaDoc javaDoc) { enter(javaDoc); - scan(javaDoc.getComments()); - scan(javaDoc.getAnnotations()); - scan(javaDoc.getTags()); + scan(CtRole.COMMENT, javaDoc.getComments()); + scan(CtRole.ANNOTATION, javaDoc.getAnnotations()); + scan(CtRole.COMMENT_TAG, javaDoc.getTags()); exit(javaDoc); } @Override public void visitCtJavaDocTag(final CtJavaDocTag docTag) { enter(docTag); - scan(docTag.getComments()); - scan(docTag.getAnnotations()); + scan(CtRole.COMMENT, docTag.getComments()); + scan(CtRole.ANNOTATION, docTag.getAnnotations()); exit(docTag); } } diff --git a/src/main/java/spoon/reflect/visitor/EarlyTerminatingScanner.java b/src/main/java/spoon/reflect/visitor/EarlyTerminatingScanner.java index b57c313e168..b691d82fd2d 100644 --- a/src/main/java/spoon/reflect/visitor/EarlyTerminatingScanner.java +++ b/src/main/java/spoon/reflect/visitor/EarlyTerminatingScanner.java @@ -17,6 +17,7 @@ package spoon.reflect.visitor; import spoon.reflect.declaration.CtElement; +import spoon.reflect.path.CtRole; import spoon.reflect.visitor.chain.CtScannerListener; import spoon.reflect.visitor.chain.ScanningMode; @@ -78,14 +79,14 @@ public EarlyTerminatingScanner setListener(CtScannerListener listener) { } @Override - public void scan(Collection elements) { + public void scan(CtRole role, Collection elements) { if (isTerminated() || elements == null) { return; } // we use defensive copy so as to be able to change the class while scanning // otherwise one gets a ConcurrentModificationException for (CtElement e : new ArrayList<>(elements)) { - scan(e); + scan(role, e); if (isTerminated()) { return; } @@ -122,17 +123,17 @@ protected void doScan(CtElement element, ScanningMode mode) { } @Override - public void scan(Object o) { + public void scan(CtRole role, Object o) { if (isTerminated() || o == null) { return; } if (o instanceof CtElement) { - scan((CtElement) o); + scan(role, (CtElement) o); } else if (o instanceof Collection) { - scan((Collection) o); + scan(role, (Collection) o); } else if (o instanceof Map) { for (Object obj : ((Map) o).values()) { - scan(obj); + scan(role, obj); if (isTerminated()) { return; } diff --git a/src/main/java/spoon/support/template/SubstitutionVisitor.java b/src/main/java/spoon/support/template/SubstitutionVisitor.java index 3b3ac93534c..20924cff0ce 100644 --- a/src/main/java/spoon/support/template/SubstitutionVisitor.java +++ b/src/main/java/spoon/support/template/SubstitutionVisitor.java @@ -17,7 +17,6 @@ package spoon.support.template; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.IdentityHashMap; import java.util.LinkedHashMap; @@ -381,15 +380,6 @@ public SubstitutionVisitor addGeneratedBy(boolean addGeneratedBy) { } - /** - * Override to scan on collection copies and avoid potential concurrent - * modification exceptions. - */ - @Override - public void scan(Collection elements) { - super.scan(new ArrayList<>(elements)); - } - @Override public void scan(CtElement element) { try { diff --git a/src/main/java/spoon/support/visitor/ProcessingVisitor.java b/src/main/java/spoon/support/visitor/ProcessingVisitor.java index 07212e59266..9a66664b83e 100644 --- a/src/main/java/spoon/support/visitor/ProcessingVisitor.java +++ b/src/main/java/spoon/support/visitor/ProcessingVisitor.java @@ -16,9 +16,6 @@ */ package spoon.support.visitor; -import java.util.ArrayList; -import java.util.Collection; - import spoon.processing.Processor; import spoon.processing.TraversalStrategy; import spoon.reflect.declaration.CtElement; @@ -58,15 +55,6 @@ public Processor getProcessor() { return processor; } - @Override - public void scan(Collection elements) { - if ((elements != null)) { - for (CtElement e : new ArrayList<>(elements)) { - scan(e); - } - } - } - /** * Applies the processing to the given element. To apply the processing, * this method upcalls, for all the registered processor in, the diff --git a/src/test/java/spoon/reflect/visitor/CtScannerTest.java b/src/test/java/spoon/reflect/visitor/CtScannerTest.java index c1187ed6e4e..7b65fae3675 100644 --- a/src/test/java/spoon/reflect/visitor/CtScannerTest.java +++ b/src/test/java/spoon/reflect/visitor/CtScannerTest.java @@ -24,11 +24,14 @@ import spoon.metamodel.MMTypeKind; import spoon.metamodel.MMMethod; import spoon.metamodel.SpoonMetaModel; +import spoon.reflect.code.CtFieldRead; import spoon.reflect.code.CtInvocation; import spoon.reflect.declaration.CtClass; import spoon.reflect.declaration.CtElement; import spoon.reflect.declaration.CtMethod; import spoon.reflect.declaration.CtParameter; +import spoon.reflect.path.CtRole; +import spoon.reflect.reference.CtFieldReference; import spoon.reflect.reference.CtTypeReference; import spoon.reflect.visitor.filter.TypeFilter; import spoon.reflect.visitor.processors.CheckScannerTestProcessor; @@ -99,7 +102,7 @@ private String computeSimpleSignature(CtMethod m) { @Test public void testScannerCallsAllProperties() throws Exception { - // contract: CtScanner must visit all metamodel properties + // contract: CtScanner must visit all metamodel properties and use correct CtRole final Launcher launcher = new Launcher(); launcher.addInputResource("./src/main/java/spoon/reflect/"); launcher.run(); @@ -160,6 +163,13 @@ public boolean matches(CtInvocation element) { if (invocation == null) { problems.add("no "+m.getSignature() +" in "+visitMethod); } + //check that method is called next to expected CtRole + CtRole expectedRole = metaModel.getRoleOfMethod((CtMethod)invocation.getExecutable().getDeclaration()); + CtInvocation scanInvocation = invocation.getParent(CtInvocation.class); + String realRoleName = ((CtFieldRead) scanInvocation.getArguments().get(0)).getVariable().getSimpleName(); + if(expectedRole.name().equals(realRoleName) == false) { + problems.add("Wrong role " + realRoleName + " used in " + scanInvocation.getPosition()); + } }); calledMethods.removeAll(checkedMethods); if (calledMethods.size() > 0) { diff --git a/src/test/java/spoon/test/SpoonTestHelpers.java b/src/test/java/spoon/test/SpoonTestHelpers.java index ded3c804774..52ab78680bb 100644 --- a/src/test/java/spoon/test/SpoonTestHelpers.java +++ b/src/test/java/spoon/test/SpoonTestHelpers.java @@ -18,7 +18,13 @@ public class SpoonTestHelpers { private SpoonTestHelpers(){ } + public static List> getAllInstantiableMetamodelClasses() { + return getAllInstantiableMetamodelTypes(false, true); + } public static List> getAllInstantiableMetamodelInterfaces() { + return getAllInstantiableMetamodelTypes(true, false); + } + private static List> getAllInstantiableMetamodelTypes(boolean addInterfaces, boolean addClasses) { List> result = new ArrayList<>(); SpoonAPI interfaces = new Launcher(); interfaces.addInputResource("src/main/java/spoon/reflect/declaration"); @@ -36,7 +42,12 @@ public static List> getAllInstantiableMetamodelInter String impl = itf.getQualifiedName().replace("spoon.reflect", "spoon.support.reflect")+"Impl"; CtType implClass = implementations.getFactory().Type().get(impl); if (implClass != null && !implClass.hasModifier(ModifierKind.ABSTRACT)) { - result.add((CtType) itf); + if (addClasses) { + result.add((CtType) implClass); + } + if (addInterfaces) { + result.add((CtType) itf); + } } } return result; @@ -86,8 +97,16 @@ public static List> getAllMetamodelMethods(CtType baseType) { result.add(m); } } + CtTypeReference superClass = baseType.getSuperclass(); + if (superClass != null) { + for (CtMethod up : getAllMetamodelMethods(superClass.getTypeDeclaration())) { + if (!containsMethodBasedOnName(result, up)) { + result.add(up); + } + } + } for (CtTypeReference itf : baseType.getSuperInterfaces()) { - for (CtMethod up : getAllSetters(itf.getTypeDeclaration())) { + for (CtMethod up : getAllMetamodelMethods(itf.getTypeDeclaration())) { if (!containsMethodBasedOnName(result, up)) { result.add(up); } @@ -143,6 +162,7 @@ public static CtMethod getSetterOf(CtType baseType, CtMethod getter) { public static boolean isMetamodelProperty(CtType baseType, CtMethod m) { return m.getSimpleName().startsWith("get") + && m.getSimpleName().equals("getParent") == false && m.getParameters().size() == 0 // a getter has no parameter && m.getAnnotation(DerivedProperty.class) == null &&