From 017167f30fa5686578e9fc42de9998b2bc8b3b7f Mon Sep 17 00:00:00 2001 From: Martin Monperrus Date: Sat, 19 Nov 2016 00:58:24 +0100 Subject: [PATCH] fix(equal): regenerate EqualVisitor based on new Scanner, which fixes a number of bugs incl. #978 --- .../generating/CloneVisitorGenerator.java | 5 +- .../generating/CtBiScannerGenerator.java | 98 +-- .../generating/EqualsVisitorGenerator.java | 96 --- .../equals/EqualsVisitorTemplate.java | 44 -- .../spoon/reflect/declaration/CtElement.java | 2 - .../reference/CtActualTypeContainer.java | 3 - .../reference/CtArrayTypeReference.java | 1 + .../reference/CtExecutableReference.java | 2 - .../reflect/visitor/CtAbstractBiScanner.java | 2 +- .../reflect/visitor/CtBiScannerDefault.java | 113 ++- .../java/spoon/reflect/visitor/CtScanner.java | 1 + .../support/compiler/FileSystemFolder.java | 3 + .../spoon/support/compiler/VirtualFolder.java | 2 +- .../support/visitor/clone/CloneVisitor.java | 1 + .../support/visitor/equals/EqualsVisitor.java | 684 +----------------- .../visitor/equals/IgnoredByEquals.java | 27 - .../visitor/replace/ReplacementVisitor.java | 1 + .../java/spoon/testing/utils/ModelUtils.java | 2 +- .../spoon/processing/CtGenerationTest.java | 45 +- .../SpoonArchitectureEnforcer.java | 9 +- .../java/spoon/test/comparison/EqualTest.java | 25 + .../test/reference/VariableAccessTest.java | 2 +- 22 files changed, 235 insertions(+), 933 deletions(-) delete mode 100644 src/main/java/spoon/generating/EqualsVisitorGenerator.java delete mode 100644 src/main/java/spoon/generating/equals/EqualsVisitorTemplate.java delete mode 100644 src/main/java/spoon/support/visitor/equals/IgnoredByEquals.java diff --git a/src/main/java/spoon/generating/CloneVisitorGenerator.java b/src/main/java/spoon/generating/CloneVisitorGenerator.java index b2f48cfbe98..9b89bbc4122 100644 --- a/src/main/java/spoon/generating/CloneVisitorGenerator.java +++ b/src/main/java/spoon/generating/CloneVisitorGenerator.java @@ -300,9 +300,12 @@ private CtExpression createBinaryConditions(List> methodsAvo * Query to get all methods which throw an UnsupportedOperationException. We must avoid to call these methods during a clone process. */ private List> getCtMethodThrowUnsupportedOperation(CtMethod method) { + final List> avoid = new ArrayList<>(); final CtInterface ctInterface = getInterfaceOf(method.getDeclaringType()); + if (ctInterface == null) { + return avoid; + } final CtMethod declarationMethod = getMethodByCtMethod(ctInterface, method); - final List> avoid = new ArrayList<>(); for (CtMethod ctMethod : Query.getElements(factory, new OverridingMethodFilter(declarationMethod))) { if (!avoidThrowUnsupportedOperationException(ctMethod)) { avoid.add(ctMethod); diff --git a/src/main/java/spoon/generating/CtBiScannerGenerator.java b/src/main/java/spoon/generating/CtBiScannerGenerator.java index bb0a42b435b..08159cd3885 100644 --- a/src/main/java/spoon/generating/CtBiScannerGenerator.java +++ b/src/main/java/spoon/generating/CtBiScannerGenerator.java @@ -16,7 +16,8 @@ */ package spoon.generating; -import spoon.processing.AbstractProcessor; +import spoon.processing.AbstractManualProcessor; +import spoon.reflect.code.CtComment; import spoon.reflect.code.CtExpression; import spoon.reflect.code.CtInvocation; import spoon.reflect.code.CtLocalVariable; @@ -24,7 +25,7 @@ import spoon.reflect.declaration.CtClass; import spoon.reflect.declaration.CtMethod; import spoon.reflect.declaration.CtPackage; -import spoon.reflect.declaration.CtType; +import spoon.reflect.declaration.CtTypeMember; import spoon.reflect.declaration.ModifierKind; import spoon.reflect.factory.Factory; import spoon.reflect.reference.CtTypeReference; @@ -33,69 +34,67 @@ import java.util.List; -public class CtBiScannerGenerator extends AbstractProcessor> { +public class CtBiScannerGenerator extends AbstractManualProcessor { private static final String TARGET_BISCANNER_PACKAGE = "spoon.reflect.visitor"; private static final String GENERATING_BISCANNER_PACKAGE = "spoon.generating.scanner"; private static final String GENERATING_BISCANNER = GENERATING_BISCANNER_PACKAGE + ".CtBiScannerTemplate"; - @Override - public boolean isToBeProcessed(CtType candidate) { - return CtScanner.class.getName().equals(candidate.getQualifiedName()) && super.isToBeProcessed(candidate); - } + public void process() { - @Override - public void process(CtType element) { final CtLocalVariable peekElement = getFactory().Class() .get(GENERATING_BISCANNER_PACKAGE + ".PeekElementTemplate") .getMethod("statement") .getBody().getStatement(0); final CtClass target = createBiScanner(); - new CtScanner() { - @Override - public void visitCtMethod(CtMethod element) { - if (!element.getSimpleName().startsWith("visitCt")) { - return; + for (CtTypeMember tm : getFactory().Class().get(CtScanner.class).getTypeMembers()) { + if (!(tm instanceof CtMethod)) { + continue; + } + CtMethod element = (CtMethod) tm; + if (!element.getSimpleName().startsWith("visitCt")) { + continue; + } + + Factory factory = element.getFactory(); + CtMethod clone = factory.Core().clone(element); + clone.addComment(getFactory().Code().createComment("autogenerated by " + getClass().getSimpleName(), CtComment.CommentType.INLINE)); + + // Peek element from Stack. + final CtLocalVariable peek = factory.Core().clone(peekElement); + final CtTypeReference type = factory.Core().clone(clone.getParameters().get(0).getType()); + type.getActualTypeArguments().clear(); + peek.getDefaultExpression().addTypeCast(type); + peek.setType(type); + 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); + if ("getValue".equals(targetInvocation.getExecutable().getSimpleName()) && "CtLiteral".equals(targetInvocation.getExecutable().getDeclaringType().getSimpleName())) { + clone.getBody().getStatement(i--).delete(); + continue; } + CtInvocation replace = (CtInvocation) factory.Core().clone(clone.getBody().getStatement(i)); - Factory factory = element.getFactory(); - CtMethod clone = factory.Core().clone(element); - - // Peek element from Stack. - final CtLocalVariable peek = factory.Core().clone(peekElement); - final CtTypeReference type = factory.Core().clone(clone.getParameters().get(0).getType()); - type.getActualTypeArguments().clear(); - peek.getDefaultExpression().addTypeCast(type); - peek.setType(type); - 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); - if ("getValue".equals(targetInvocation.getExecutable().getSimpleName()) && "CtLiteral".equals(targetInvocation.getExecutable().getDeclaringType().getSimpleName())) { - clone.getBody().getStatement(i--).delete(); - continue; - } - CtInvocation replace = (CtInvocation) factory.Core().clone(clone.getBody().getStatement(i)); - - // Changes to biScan method. - replace.getExecutable().setSimpleName("biScan"); - - // Creates other inv. - final CtVariableAccess otherRead = factory.Code().createVariableRead(peek.getReference(), false); - replace.addArgument(factory.Code().createInvocation(otherRead, ((CtInvocation) replace.getArguments().get(0)).getExecutable())); - - if ("Map".equals(targetInvocation.getExecutable().getType().getSimpleName())) { - ((CtExpression) replace.getArguments().get(0)).replace(factory.Code().createInvocation(targetInvocation, factory.Executable().createReference("List Map#values()"))); - replace.getArguments().add(1, factory.Code().createInvocation((CtExpression) replace.getArguments().get(1), factory.Executable().createReference("List Map#values()"))); - replace.getArguments().remove(2); - } - - clone.getBody().getStatement(i).replace(replace); + // Changes to biScan method. + replace.getExecutable().setSimpleName("biScan"); + + // Creates other inv. + final CtVariableAccess otherRead = factory.Code().createVariableRead(peek.getReference(), false); + replace.addArgument(factory.Code().createInvocation(otherRead, ((CtInvocation) replace.getArguments().get(0)).getExecutable())); + + if ("Map".equals(targetInvocation.getExecutable().getType().getSimpleName())) { + ((CtExpression) replace.getArguments().get(0)).replace(factory.Code().createInvocation(targetInvocation, factory.Executable().createReference("List Map#values()"))); + replace.getArguments().add(1, factory.Code().createInvocation((CtExpression) replace.getArguments().get(1), factory.Executable().createReference("List Map#values()"))); + replace.getArguments().remove(2); } - target.addMethod(clone); + clone.getBody().getStatement(i).replace(replace); } - }.scan(getFactory().Class().get(CtScanner.class)); + + target.addMethod(clone); + } + } private CtClass createBiScanner() { @@ -104,6 +103,7 @@ private CtClass createBiScanner() { target.setSimpleName("CtBiScannerDefault"); target.addModifier(ModifierKind.PUBLIC); aPackage.addType(target); + target.addComment(getFactory().Code().createComment("autogenerated by " + getClass().getSimpleName(), CtComment.CommentType.INLINE)); final List references = target.getReferences(new ReferenceFilter() { @Override public boolean matches(CtTypeReference reference) { diff --git a/src/main/java/spoon/generating/EqualsVisitorGenerator.java b/src/main/java/spoon/generating/EqualsVisitorGenerator.java deleted file mode 100644 index 7b880d036ea..00000000000 --- a/src/main/java/spoon/generating/EqualsVisitorGenerator.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Copyright (C) 2006-2016 INRIA and contributors - * Spoon - http://spoon.gforge.inria.fr/ - * - * This software is governed by the CeCILL-C License under French law and - * abiding by the rules of distribution of free software. You can use, modify - * and/or redistribute the software under the terms of the CeCILL-C license as - * circulated by CEA, CNRS and INRIA at http://www.cecill.info. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-C license and that you accept its terms. - */ -package spoon.generating; - -import spoon.processing.AbstractManualProcessor; -import spoon.reflect.code.CtInvocation; -import spoon.reflect.declaration.CtAnnotation; -import spoon.reflect.declaration.CtClass; -import spoon.reflect.declaration.CtMethod; -import spoon.reflect.declaration.CtPackage; -import spoon.reflect.declaration.ModifierKind; -import spoon.reflect.factory.Factory; -import spoon.reflect.reference.CtTypeReference; -import spoon.reflect.visitor.CtAbstractBiScanner; -import spoon.reflect.visitor.CtBiScannerDefault; -import spoon.reflect.visitor.CtScanner; -import spoon.reflect.visitor.ReferenceFilter; -import spoon.support.visitor.equals.IgnoredByEquals; - -import java.util.List; - -public class EqualsVisitorGenerator extends AbstractManualProcessor { - private static final String TARGET_EQUALS_PACKAGE = "spoon.support.visitor.equals"; - private static final String GENERATING_EQUALS_PACKAGE = "spoon.generating.equals"; - private static final String GENERATING_EQUALS = GENERATING_EQUALS_PACKAGE + ".EqualsVisitorTemplate"; - - @Override - public void process() { - final CtClass target = createEqualsVisitor(); - new CtScanner() { - @Override - public void visitCtMethod(CtMethod element) { - if (!element.getSimpleName().startsWith("visitCt")) { - return; - } - - Factory factory = element.getFactory(); - CtMethod clone = factory.Core().clone(element); - - final CtAnnotation ignoredAnnotation = factory.Core().createAnnotation(); - ignoredAnnotation.setAnnotationType(factory.Type().createReference(IgnoredByEquals.class)); - - for (int i = 2; i < clone.getBody().getStatements().size() - 1; i++) { - final CtInvocation targetInvocation = (CtInvocation) ((CtInvocation) clone.getBody().getStatement(i)).getArguments().get(0); - if (targetInvocation.getExecutable().getExecutableDeclaration().getAnnotations().contains(ignoredAnnotation)) { - clone.getBody().getStatement(i--).delete(); - continue; - } - CtInvocation replace = (CtInvocation) factory.Core().clone(clone.getBody().getStatement(i)); - clone.getBody().getStatement(i).replace(replace); - } - - target.addMethod(clone); - } - }.scan(getFactory().Class().get(CtBiScannerDefault.class)); - } - - private CtClass createEqualsVisitor() { - final CtPackage aPackage = getFactory().Package().getOrCreate(TARGET_EQUALS_PACKAGE); - final CtClass target = getFactory().Class().get(GENERATING_EQUALS); - target.setSimpleName("EqualsVisitor"); - target.addModifier(ModifierKind.PUBLIC); - target.setSuperclass(getFactory().Type().createReference(CtAbstractBiScanner.class)); - aPackage.addType(target); - final List references = target.getReferences(new ReferenceFilter() { - @Override - public boolean matches(CtTypeReference reference) { - return reference != null && GENERATING_EQUALS.equals(reference.getQualifiedName()); - } - - @Override - public Class getType() { - return CtTypeReference.class; - } - }); - for (CtTypeReference reference : references) { - reference.setSimpleName("EqualsVisitor"); - reference.setPackage(aPackage.getReference()); - } - return target; - } -} diff --git a/src/main/java/spoon/generating/equals/EqualsVisitorTemplate.java b/src/main/java/spoon/generating/equals/EqualsVisitorTemplate.java deleted file mode 100644 index e3108632617..00000000000 --- a/src/main/java/spoon/generating/equals/EqualsVisitorTemplate.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (C) 2006-2016 INRIA and contributors - * Spoon - http://spoon.gforge.inria.fr/ - * - * This software is governed by the CeCILL-C License under French law and - * abiding by the rules of distribution of free software. You can use, modify - * and/or redistribute the software under the terms of the CeCILL-C license as - * circulated by CEA, CNRS and INRIA at http://www.cecill.info. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-C license and that you accept its terms. - */ -package spoon.generating.equals; - -import spoon.reflect.declaration.CtElement; -import spoon.reflect.visitor.CtBiScannerDefault; -import spoon.support.visitor.equals.EqualsChecker; - -/** - * Used to check equality between an element and another one. - * - * This class is generated automatically by the processor {@link spoon.generating.EqualsVisitorGenerator}. - */ -class EqualsVisitorTemplate extends CtBiScannerDefault { - public static boolean equals(CtElement element, CtElement other) { - return !new EqualsVisitorTemplate().biScan(element, other); - } - - private final EqualsChecker checker = new EqualsChecker(); - - @Override - protected void enter(CtElement e) { - super.enter(e); - checker.setOther(stack.peek()); - checker.scan(e); - if (checker.isNotEqual()) { - fail(); - } - } -} diff --git a/src/main/java/spoon/reflect/declaration/CtElement.java b/src/main/java/spoon/reflect/declaration/CtElement.java index e3e305e5ec3..8bc7f15e551 100644 --- a/src/main/java/spoon/reflect/declaration/CtElement.java +++ b/src/main/java/spoon/reflect/declaration/CtElement.java @@ -26,7 +26,6 @@ import spoon.reflect.visitor.ReferenceFilter; import spoon.reflect.visitor.Root; import spoon.support.DerivedProperty; -import spoon.support.visitor.equals.IgnoredByEquals; import java.lang.annotation.Annotation; import java.util.List; @@ -265,7 +264,6 @@ List getAnnotatedChildren( * The list of comments * @return the list of comment */ - @IgnoredByEquals List getComments(); /** diff --git a/src/main/java/spoon/reflect/reference/CtActualTypeContainer.java b/src/main/java/spoon/reflect/reference/CtActualTypeContainer.java index 39f1d07b055..f6303c24843 100644 --- a/src/main/java/spoon/reflect/reference/CtActualTypeContainer.java +++ b/src/main/java/spoon/reflect/reference/CtActualTypeContainer.java @@ -16,8 +16,6 @@ */ package spoon.reflect.reference; -import spoon.support.visitor.equals.IgnoredByEquals; - import java.util.List; /** @@ -27,7 +25,6 @@ public interface CtActualTypeContainer { /** * Gets the type arguments. */ - @IgnoredByEquals List> getActualTypeArguments(); /** diff --git a/src/main/java/spoon/reflect/reference/CtArrayTypeReference.java b/src/main/java/spoon/reflect/reference/CtArrayTypeReference.java index 78d2dff7c00..6904c466c80 100644 --- a/src/main/java/spoon/reflect/reference/CtArrayTypeReference.java +++ b/src/main/java/spoon/reflect/reference/CtArrayTypeReference.java @@ -58,4 +58,5 @@ public interface CtArrayTypeReference extends CtTypeReference { @Override CtArrayTypeReference clone(); + } diff --git a/src/main/java/spoon/reflect/reference/CtExecutableReference.java b/src/main/java/spoon/reflect/reference/CtExecutableReference.java index b4c0624886a..77536d9631d 100644 --- a/src/main/java/spoon/reflect/reference/CtExecutableReference.java +++ b/src/main/java/spoon/reflect/reference/CtExecutableReference.java @@ -18,7 +18,6 @@ import spoon.reflect.declaration.CtExecutable; import spoon.support.DerivedProperty; -import spoon.support.visitor.equals.IgnoredByEquals; import java.lang.reflect.Constructor; import java.lang.reflect.Method; @@ -80,7 +79,6 @@ public interface CtExecutableReference extends CtReference, CtActualTypeConta /** * Gets the return type of the executable (may be null in noclasspath mode). */ - @IgnoredByEquals CtTypeReference getType(); /** diff --git a/src/main/java/spoon/reflect/visitor/CtAbstractBiScanner.java b/src/main/java/spoon/reflect/visitor/CtAbstractBiScanner.java index 01103d76bc1..db4c18d2f24 100644 --- a/src/main/java/spoon/reflect/visitor/CtAbstractBiScanner.java +++ b/src/main/java/spoon/reflect/visitor/CtAbstractBiScanner.java @@ -26,7 +26,7 @@ /** * This abstract bi scanner class declares all scan methods useful for CtBiScannerDefault */ -public abstract class CtAbstractBiScanner implements CtVisitor { +public abstract class CtAbstractBiScanner extends CtAbstractVisitor { protected Deque stack = new ArrayDeque<>(); protected void enter(CtElement e) { diff --git a/src/main/java/spoon/reflect/visitor/CtBiScannerDefault.java b/src/main/java/spoon/reflect/visitor/CtBiScannerDefault.java index 284b9f669ac..173f478d873 100644 --- a/src/main/java/spoon/reflect/visitor/CtBiScannerDefault.java +++ b/src/main/java/spoon/reflect/visitor/CtBiScannerDefault.java @@ -29,16 +29,21 @@ * * Is used by EqualsVisitor. */ +// autogenerated by CtBiScannerGenerator public abstract class CtBiScannerDefault extends spoon.reflect.visitor.CtAbstractBiScanner { + // autogenerated by CtBiScannerGenerator public void visitCtAnnotation(final spoon.reflect.declaration.CtAnnotation annotation) { spoon.reflect.declaration.CtAnnotation other = ((spoon.reflect.declaration.CtAnnotation) (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()); exit(annotation); } + // autogenerated by CtBiScannerGenerator public void visitCtAnnotationType(final spoon.reflect.declaration.CtAnnotationType annotationType) { spoon.reflect.declaration.CtAnnotationType other = ((spoon.reflect.declaration.CtAnnotationType) (stack.peek())); enter(annotationType); @@ -48,6 +53,7 @@ public void visitCtAnnotationType(fi exit(annotationType); } + // autogenerated by CtBiScannerGenerator public void visitCtAnonymousExecutable(final spoon.reflect.declaration.CtAnonymousExecutable anonymousExec) { spoon.reflect.declaration.CtAnonymousExecutable other = ((spoon.reflect.declaration.CtAnonymousExecutable) (stack.peek())); enter(anonymousExec); @@ -57,6 +63,7 @@ public void visitCtAnonymousExecutable(final spoon.reflect.declaration.CtAnonymo exit(anonymousExec); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtArrayRead(final spoon.reflect.code.CtArrayRead arrayRead) { spoon.reflect.code.CtArrayRead other = ((spoon.reflect.code.CtArrayRead) (stack.peek())); @@ -70,6 +77,7 @@ public void visitCtArrayRead(final spoon.reflect.code.CtArrayRead arrayRe exit(arrayRead); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtArrayWrite(final spoon.reflect.code.CtArrayWrite arrayWrite) { spoon.reflect.code.CtArrayWrite other = ((spoon.reflect.code.CtArrayWrite) (stack.peek())); @@ -83,17 +91,20 @@ public void visitCtArrayWrite(final spoon.reflect.code.CtArrayWrite array exit(arrayWrite); } + // autogenerated by CtBiScannerGenerator public void visitCtArrayTypeReference(final spoon.reflect.reference.CtArrayTypeReference reference) { spoon.reflect.reference.CtArrayTypeReference other = ((spoon.reflect.reference.CtArrayTypeReference) (stack.peek())); enter(reference); - biScan(reference.getDeclaringType(), other.getDeclaringType()); + 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()); exit(reference); } + // autogenerated by CtBiScannerGenerator public void visitCtAssert(final spoon.reflect.code.CtAssert asserted) { spoon.reflect.code.CtAssert other = ((spoon.reflect.code.CtAssert) (stack.peek())); enter(asserted); @@ -104,6 +115,7 @@ public void visitCtAssert(final spoon.reflect.code.CtAssert asserted) { exit(asserted); } + // autogenerated by CtBiScannerGenerator public void visitCtAssignment(final spoon.reflect.code.CtAssignment assignement) { spoon.reflect.code.CtAssignment other = ((spoon.reflect.code.CtAssignment) (stack.peek())); enter(assignement); @@ -116,6 +128,7 @@ public void visitCtAssignment(final spoon.reflect.code.CtAssign exit(assignement); } + // autogenerated by CtBiScannerGenerator public void visitCtBinaryOperator(final spoon.reflect.code.CtBinaryOperator operator) { spoon.reflect.code.CtBinaryOperator other = ((spoon.reflect.code.CtBinaryOperator) (stack.peek())); enter(operator); @@ -128,6 +141,7 @@ public void visitCtBinaryOperator(final spoon.reflect.code.CtBinaryOperator< exit(operator); } + // autogenerated by CtBiScannerGenerator public void visitCtBlock(final spoon.reflect.code.CtBlock block) { spoon.reflect.code.CtBlock other = ((spoon.reflect.code.CtBlock) (stack.peek())); enter(block); @@ -137,6 +151,7 @@ public void visitCtBlock(final spoon.reflect.code.CtBlock block) { exit(block); } + // autogenerated by CtBiScannerGenerator public void visitCtBreak(final spoon.reflect.code.CtBreak breakStatement) { spoon.reflect.code.CtBreak other = ((spoon.reflect.code.CtBreak) (stack.peek())); enter(breakStatement); @@ -145,6 +160,7 @@ public void visitCtBreak(final spoon.reflect.code.CtBreak breakStatement) { exit(breakStatement); } + // autogenerated by CtBiScannerGenerator public void visitCtCase(final spoon.reflect.code.CtCase caseStatement) { spoon.reflect.code.CtCase other = ((spoon.reflect.code.CtCase) (stack.peek())); enter(caseStatement); @@ -155,6 +171,7 @@ public void visitCtCase(final spoon.reflect.code.CtCase caseStatement) { exit(caseStatement); } + // autogenerated by CtBiScannerGenerator public void visitCtCatch(final spoon.reflect.code.CtCatch catchBlock) { spoon.reflect.code.CtCatch other = ((spoon.reflect.code.CtCatch) (stack.peek())); enter(catchBlock); @@ -165,6 +182,7 @@ public void visitCtCatch(final spoon.reflect.code.CtCatch catchBlock) { exit(catchBlock); } + // autogenerated by CtBiScannerGenerator public void visitCtClass(final spoon.reflect.declaration.CtClass ctClass) { spoon.reflect.declaration.CtClass other = ((spoon.reflect.declaration.CtClass) (stack.peek())); enter(ctClass); @@ -177,6 +195,7 @@ public void visitCtClass(final spoon.reflect.declaration.CtClass ctClass) exit(ctClass); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtTypeParameter(spoon.reflect.declaration.CtTypeParameter typeParameter) { spoon.reflect.declaration.CtTypeParameter other = ((spoon.reflect.declaration.CtTypeParameter) (stack.peek())); @@ -187,9 +206,11 @@ public void visitCtTypeParameter(spoon.reflect.declaration.CtTypeParameter typeP exit(typeParameter); } + // autogenerated by CtBiScannerGenerator public void visitCtConditional(final spoon.reflect.code.CtConditional conditional) { spoon.reflect.code.CtConditional other = ((spoon.reflect.code.CtConditional) (stack.peek())); enter(conditional); + biScan(conditional.getType(), other.getType()); biScan(conditional.getAnnotations(), other.getAnnotations()); biScan(conditional.getCondition(), other.getCondition()); biScan(conditional.getThenExpression(), other.getThenExpression()); @@ -199,6 +220,7 @@ public void visitCtConditional(final spoon.reflect.code.CtConditional con exit(conditional); } + // autogenerated by CtBiScannerGenerator public void visitCtConstructor(final spoon.reflect.declaration.CtConstructor c) { spoon.reflect.declaration.CtConstructor other = ((spoon.reflect.declaration.CtConstructor) (stack.peek())); enter(c); @@ -211,6 +233,7 @@ public void visitCtConstructor(final spoon.reflect.declaration.CtConstructor exit(c); } + // autogenerated by CtBiScannerGenerator public void visitCtContinue(final spoon.reflect.code.CtContinue continueStatement) { spoon.reflect.code.CtContinue other = ((spoon.reflect.code.CtContinue) (stack.peek())); enter(continueStatement); @@ -220,6 +243,7 @@ public void visitCtContinue(final spoon.reflect.code.CtContinue continueStatemen exit(continueStatement); } + // autogenerated by CtBiScannerGenerator public void visitCtDo(final spoon.reflect.code.CtDo doLoop) { spoon.reflect.code.CtDo other = ((spoon.reflect.code.CtDo) (stack.peek())); enter(doLoop); @@ -230,6 +254,7 @@ public void visitCtDo(final spoon.reflect.code.CtDo doLoop) { exit(doLoop); } + // autogenerated by CtBiScannerGenerator public > void visitCtEnum(final spoon.reflect.declaration.CtEnum ctEnum) { spoon.reflect.declaration.CtEnum other = ((spoon.reflect.declaration.CtEnum) (stack.peek())); enter(ctEnum); @@ -241,6 +266,7 @@ public > void visitCtEnum(final spoon.reflect.declar exit(ctEnum); } + // autogenerated by CtBiScannerGenerator public void visitCtExecutableReference(final spoon.reflect.reference.CtExecutableReference reference) { spoon.reflect.reference.CtExecutableReference other = ((spoon.reflect.reference.CtExecutableReference) (stack.peek())); enter(reference); @@ -253,6 +279,7 @@ public void visitCtExecutableReference(final spoon.reflect.reference.CtExecu exit(reference); } + // autogenerated by CtBiScannerGenerator public void visitCtField(final spoon.reflect.declaration.CtField f) { spoon.reflect.declaration.CtField other = ((spoon.reflect.declaration.CtField) (stack.peek())); enter(f); @@ -263,6 +290,7 @@ public void visitCtField(final spoon.reflect.declaration.CtField f) { exit(f); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtEnumValue(final spoon.reflect.declaration.CtEnumValue enumValue) { spoon.reflect.declaration.CtEnumValue other = ((spoon.reflect.declaration.CtEnumValue) (stack.peek())); @@ -274,29 +302,33 @@ public void visitCtEnumValue(final spoon.reflect.declaration.CtEnumValue exit(enumValue); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtThisAccess(final spoon.reflect.code.CtThisAccess thisAccess) { spoon.reflect.code.CtThisAccess other = ((spoon.reflect.code.CtThisAccess) (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(thisAccess.getComments(), other.getComments()); exit(thisAccess); } + // autogenerated by CtBiScannerGenerator public void visitCtAnnotationFieldAccess(final spoon.reflect.code.CtAnnotationFieldAccess annotationFieldAccess) { spoon.reflect.code.CtAnnotationFieldAccess other = ((spoon.reflect.code.CtAnnotationFieldAccess) (stack.peek())); enter(annotationFieldAccess); + biScan(annotationFieldAccess.getComments(), other.getComments()); biScan(annotationFieldAccess.getAnnotations(), other.getAnnotations()); - biScan(annotationFieldAccess.getType(), other.getType()); biScan(annotationFieldAccess.getTypeCasts(), other.getTypeCasts()); biScan(annotationFieldAccess.getTarget(), other.getTarget()); + biScan(annotationFieldAccess.getType(), other.getType()); biScan(annotationFieldAccess.getVariable(), other.getVariable()); - biScan(annotationFieldAccess.getComments(), other.getComments()); exit(annotationFieldAccess); } + // autogenerated by CtBiScannerGenerator public void visitCtFieldReference(final spoon.reflect.reference.CtFieldReference reference) { spoon.reflect.reference.CtFieldReference other = ((spoon.reflect.reference.CtFieldReference) (stack.peek())); enter(reference); @@ -306,6 +338,7 @@ public void visitCtFieldReference(final spoon.reflect.reference.CtFieldRefer exit(reference); } + // autogenerated by CtBiScannerGenerator public void visitCtFor(final spoon.reflect.code.CtFor forLoop) { spoon.reflect.code.CtFor other = ((spoon.reflect.code.CtFor) (stack.peek())); enter(forLoop); @@ -318,6 +351,7 @@ public void visitCtFor(final spoon.reflect.code.CtFor forLoop) { exit(forLoop); } + // autogenerated by CtBiScannerGenerator public void visitCtForEach(final spoon.reflect.code.CtForEach foreach) { spoon.reflect.code.CtForEach other = ((spoon.reflect.code.CtForEach) (stack.peek())); enter(foreach); @@ -329,6 +363,7 @@ public void visitCtForEach(final spoon.reflect.code.CtForEach foreach) { exit(foreach); } + // autogenerated by CtBiScannerGenerator public void visitCtIf(final spoon.reflect.code.CtIf ifElement) { spoon.reflect.code.CtIf other = ((spoon.reflect.code.CtIf) (stack.peek())); enter(ifElement); @@ -340,6 +375,7 @@ public void visitCtIf(final spoon.reflect.code.CtIf ifElement) { exit(ifElement); } + // autogenerated by CtBiScannerGenerator public void visitCtInterface(final spoon.reflect.declaration.CtInterface intrface) { spoon.reflect.declaration.CtInterface other = ((spoon.reflect.declaration.CtInterface) (stack.peek())); enter(intrface); @@ -351,6 +387,7 @@ public void visitCtInterface(final spoon.reflect.declaration.CtInterface exit(intrface); } + // autogenerated by CtBiScannerGenerator public void visitCtInvocation(final spoon.reflect.code.CtInvocation invocation) { spoon.reflect.code.CtInvocation other = ((spoon.reflect.code.CtInvocation) (stack.peek())); enter(invocation); @@ -363,6 +400,7 @@ public void visitCtInvocation(final spoon.reflect.code.CtInvocation invoc exit(invocation); } + // autogenerated by CtBiScannerGenerator public void visitCtLiteral(final spoon.reflect.code.CtLiteral literal) { spoon.reflect.code.CtLiteral other = ((spoon.reflect.code.CtLiteral) (stack.peek())); enter(literal); @@ -373,6 +411,7 @@ public void visitCtLiteral(final spoon.reflect.code.CtLiteral literal) { exit(literal); } + // autogenerated by CtBiScannerGenerator public void visitCtLocalVariable(final spoon.reflect.code.CtLocalVariable localVariable) { spoon.reflect.code.CtLocalVariable other = ((spoon.reflect.code.CtLocalVariable) (stack.peek())); enter(localVariable); @@ -383,6 +422,7 @@ public void visitCtLocalVariable(final spoon.reflect.code.CtLocalVariable exit(localVariable); } + // autogenerated by CtBiScannerGenerator public void visitCtLocalVariableReference(final spoon.reflect.reference.CtLocalVariableReference reference) { spoon.reflect.reference.CtLocalVariableReference other = ((spoon.reflect.reference.CtLocalVariableReference) (stack.peek())); enter(reference); @@ -391,23 +431,29 @@ public void visitCtLocalVariableReference(final spoon.reflect.reference.CtLo exit(reference); } + // autogenerated by CtBiScannerGenerator public void visitCtCatchVariable(final spoon.reflect.code.CtCatchVariable catchVariable) { spoon.reflect.code.CtCatchVariable other = ((spoon.reflect.code.CtCatchVariable) (stack.peek())); enter(catchVariable); + biScan(catchVariable.getComments(), other.getComments()); biScan(catchVariable.getAnnotations(), other.getAnnotations()); + biScan(catchVariable.getDefaultExpression(), other.getDefaultExpression()); biScan(catchVariable.getType(), other.getType()); - biScan(catchVariable.getComments(), other.getComments()); + biScan(catchVariable.getMultiTypes(), other.getMultiTypes()); exit(catchVariable); } + // autogenerated by CtBiScannerGenerator public void visitCtCatchVariableReference(final spoon.reflect.reference.CtCatchVariableReference reference) { spoon.reflect.reference.CtCatchVariableReference other = ((spoon.reflect.reference.CtCatchVariableReference) (stack.peek())); enter(reference); + biScan(reference.getComments(), other.getComments()); biScan(reference.getType(), other.getType()); biScan(reference.getAnnotations(), other.getAnnotations()); exit(reference); } + // autogenerated by CtBiScannerGenerator public void visitCtMethod(final spoon.reflect.declaration.CtMethod m) { spoon.reflect.declaration.CtMethod other = ((spoon.reflect.declaration.CtMethod) (stack.peek())); enter(m); @@ -421,6 +467,7 @@ public void visitCtMethod(final spoon.reflect.declaration.CtMethod m) { exit(m); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtAnnotationMethod(spoon.reflect.declaration.CtAnnotationMethod annotationMethod) { spoon.reflect.declaration.CtAnnotationMethod other = ((spoon.reflect.declaration.CtAnnotationMethod) (stack.peek())); @@ -432,6 +479,7 @@ public void visitCtAnnotationMethod(spoon.reflect.declaration.CtAnnotationMe exit(annotationMethod); } + // autogenerated by CtBiScannerGenerator public void visitCtNewArray(final spoon.reflect.code.CtNewArray newArray) { spoon.reflect.code.CtNewArray other = ((spoon.reflect.code.CtNewArray) (stack.peek())); enter(newArray); @@ -444,6 +492,7 @@ public void visitCtNewArray(final spoon.reflect.code.CtNewArray newArray) exit(newArray); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtConstructorCall(final spoon.reflect.code.CtConstructorCall ctConstructorCall) { spoon.reflect.code.CtConstructorCall other = ((spoon.reflect.code.CtConstructorCall) (stack.peek())); @@ -457,6 +506,7 @@ public void visitCtConstructorCall(final spoon.reflect.code.CtConstructorCal exit(ctConstructorCall); } + // autogenerated by CtBiScannerGenerator public void visitCtNewClass(final spoon.reflect.code.CtNewClass newClass) { spoon.reflect.code.CtNewClass other = ((spoon.reflect.code.CtNewClass) (stack.peek())); enter(newClass); @@ -470,6 +520,7 @@ public void visitCtNewClass(final spoon.reflect.code.CtNewClass newClass) exit(newClass); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtLambda(final spoon.reflect.code.CtLambda lambda) { spoon.reflect.code.CtLambda other = ((spoon.reflect.code.CtLambda) (stack.peek())); @@ -478,16 +529,20 @@ public void visitCtLambda(final spoon.reflect.code.CtLambda lambda) { 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()); exit(lambda); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public > void visitCtExecutableReferenceExpression(final spoon.reflect.code.CtExecutableReferenceExpression expression) { spoon.reflect.code.CtExecutableReferenceExpression other = ((spoon.reflect.code.CtExecutableReferenceExpression) (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()); @@ -495,6 +550,7 @@ public > void visitCtExecutableR exit(expression); } + // autogenerated by CtBiScannerGenerator public void visitCtOperatorAssignment(final spoon.reflect.code.CtOperatorAssignment assignment) { spoon.reflect.code.CtOperatorAssignment other = ((spoon.reflect.code.CtOperatorAssignment) (stack.peek())); enter(assignment); @@ -507,6 +563,7 @@ public void visitCtOperatorAssignment(final spoon.reflect.code. exit(assignment); } + // autogenerated by CtBiScannerGenerator public void visitCtPackage(final spoon.reflect.declaration.CtPackage ctPackage) { spoon.reflect.declaration.CtPackage other = ((spoon.reflect.declaration.CtPackage) (stack.peek())); enter(ctPackage); @@ -517,12 +574,15 @@ public void visitCtPackage(final spoon.reflect.declaration.CtPackage ctPackage) exit(ctPackage); } + // autogenerated by CtBiScannerGenerator public void visitCtPackageReference(final spoon.reflect.reference.CtPackageReference reference) { spoon.reflect.reference.CtPackageReference other = ((spoon.reflect.reference.CtPackageReference) (stack.peek())); enter(reference); + biScan(reference.getAnnotations(), other.getAnnotations()); exit(reference); } + // autogenerated by CtBiScannerGenerator public void visitCtParameter(final spoon.reflect.declaration.CtParameter parameter) { spoon.reflect.declaration.CtParameter other = ((spoon.reflect.declaration.CtParameter) (stack.peek())); enter(parameter); @@ -532,6 +592,7 @@ public void visitCtParameter(final spoon.reflect.declaration.CtParameter exit(parameter); } + // autogenerated by CtBiScannerGenerator public void visitCtParameterReference(final spoon.reflect.reference.CtParameterReference reference) { spoon.reflect.reference.CtParameterReference other = ((spoon.reflect.reference.CtParameterReference) (stack.peek())); enter(reference); @@ -541,6 +602,7 @@ public void visitCtParameterReference(final spoon.reflect.reference.CtParame exit(reference); } + // autogenerated by CtBiScannerGenerator public void visitCtReturn(final spoon.reflect.code.CtReturn returnStatement) { spoon.reflect.code.CtReturn other = ((spoon.reflect.code.CtReturn) (stack.peek())); enter(returnStatement); @@ -550,6 +612,7 @@ public void visitCtReturn(final spoon.reflect.code.CtReturn returnStateme exit(returnStatement); } + // autogenerated by CtBiScannerGenerator public void visitCtStatementList(final spoon.reflect.code.CtStatementList statements) { spoon.reflect.code.CtStatementList other = ((spoon.reflect.code.CtStatementList) (stack.peek())); enter(statements); @@ -559,6 +622,7 @@ public void visitCtStatementList(final spoon.reflect.code.CtStatementList st exit(statements); } + // autogenerated by CtBiScannerGenerator public void visitCtSwitch(final spoon.reflect.code.CtSwitch switchStatement) { spoon.reflect.code.CtSwitch other = ((spoon.reflect.code.CtSwitch) (stack.peek())); enter(switchStatement); @@ -569,6 +633,7 @@ public void visitCtSwitch(final spoon.reflect.code.CtSwitch switchStateme exit(switchStatement); } + // autogenerated by CtBiScannerGenerator public void visitCtSynchronized(final spoon.reflect.code.CtSynchronized synchro) { spoon.reflect.code.CtSynchronized other = ((spoon.reflect.code.CtSynchronized) (stack.peek())); enter(synchro); @@ -579,6 +644,7 @@ public void visitCtSynchronized(final spoon.reflect.code.CtSynchronized synchro) exit(synchro); } + // autogenerated by CtBiScannerGenerator public void visitCtThrow(final spoon.reflect.code.CtThrow throwStatement) { spoon.reflect.code.CtThrow other = ((spoon.reflect.code.CtThrow) (stack.peek())); enter(throwStatement); @@ -588,6 +654,7 @@ public void visitCtThrow(final spoon.reflect.code.CtThrow throwStatement) { exit(throwStatement); } + // autogenerated by CtBiScannerGenerator public void visitCtTry(final spoon.reflect.code.CtTry tryBlock) { spoon.reflect.code.CtTry other = ((spoon.reflect.code.CtTry) (stack.peek())); enter(tryBlock); @@ -599,6 +666,7 @@ public void visitCtTry(final spoon.reflect.code.CtTry tryBlock) { exit(tryBlock); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtTryWithResource(final spoon.reflect.code.CtTryWithResource tryWithResource) { spoon.reflect.code.CtTryWithResource other = ((spoon.reflect.code.CtTryWithResource) (stack.peek())); @@ -612,6 +680,7 @@ public void visitCtTryWithResource(final spoon.reflect.code.CtTryWithResource tr exit(tryWithResource); } + // autogenerated by CtBiScannerGenerator public void visitCtTypeParameterReference(final spoon.reflect.reference.CtTypeParameterReference ref) { spoon.reflect.reference.CtTypeParameterReference other = ((spoon.reflect.reference.CtTypeParameterReference) (stack.peek())); enter(ref); @@ -622,23 +691,31 @@ public void visitCtTypeParameterReference(final spoon.reflect.reference.CtTypePa exit(ref); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtWildcardReference(spoon.reflect.reference.CtWildcardReference wildcardReference) { spoon.reflect.reference.CtWildcardReference other = ((spoon.reflect.reference.CtWildcardReference) (stack.peek())); enter(wildcardReference); + biScan(wildcardReference.getPackage(), other.getPackage()); + biScan(wildcardReference.getDeclaringType(), other.getDeclaringType()); biScan(wildcardReference.getAnnotations(), other.getAnnotations()); biScan(wildcardReference.getBoundingType(), other.getBoundingType()); exit(wildcardReference); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtIntersectionTypeReference(final spoon.reflect.reference.CtIntersectionTypeReference reference) { spoon.reflect.reference.CtIntersectionTypeReference other = ((spoon.reflect.reference.CtIntersectionTypeReference) (stack.peek())); enter(reference); + biScan(reference.getPackage(), other.getPackage()); + biScan(reference.getDeclaringType(), other.getDeclaringType()); + biScan(reference.getAnnotations(), other.getAnnotations()); biScan(reference.getBounds(), other.getBounds()); exit(reference); } + // autogenerated by CtBiScannerGenerator public void visitCtTypeReference(final spoon.reflect.reference.CtTypeReference reference) { spoon.reflect.reference.CtTypeReference other = ((spoon.reflect.reference.CtTypeReference) (stack.peek())); enter(reference); @@ -650,6 +727,7 @@ public void visitCtTypeReference(final spoon.reflect.reference.CtTypeReferen exit(reference); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtTypeAccess(final spoon.reflect.code.CtTypeAccess typeAccess) { spoon.reflect.code.CtTypeAccess other = ((spoon.reflect.code.CtTypeAccess) (stack.peek())); @@ -661,6 +739,7 @@ public void visitCtTypeAccess(final spoon.reflect.code.CtTypeAccess typeA exit(typeAccess); } + // autogenerated by CtBiScannerGenerator public void visitCtUnaryOperator(final spoon.reflect.code.CtUnaryOperator operator) { spoon.reflect.code.CtUnaryOperator other = ((spoon.reflect.code.CtUnaryOperator) (stack.peek())); enter(operator); @@ -672,6 +751,7 @@ public void visitCtUnaryOperator(final spoon.reflect.code.CtUnaryOperator exit(operator); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtVariableRead(final spoon.reflect.code.CtVariableRead variableRead) { spoon.reflect.code.CtVariableRead other = ((spoon.reflect.code.CtVariableRead) (stack.peek())); @@ -683,6 +763,7 @@ public void visitCtVariableRead(final spoon.reflect.code.CtVariableRead v exit(variableRead); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtVariableWrite(final spoon.reflect.code.CtVariableWrite variableWrite) { spoon.reflect.code.CtVariableWrite other = ((spoon.reflect.code.CtVariableWrite) (stack.peek())); @@ -694,6 +775,7 @@ public void visitCtVariableWrite(final spoon.reflect.code.CtVariableWrite exit(variableWrite); } + // autogenerated by CtBiScannerGenerator public void visitCtWhile(final spoon.reflect.code.CtWhile whileLoop) { spoon.reflect.code.CtWhile other = ((spoon.reflect.code.CtWhile) (stack.peek())); enter(whileLoop); @@ -704,24 +786,35 @@ public void visitCtWhile(final spoon.reflect.code.CtWhile whileLoop) { exit(whileLoop); } + // autogenerated by CtBiScannerGenerator public void visitCtCodeSnippetExpression(final spoon.reflect.code.CtCodeSnippetExpression expression) { spoon.reflect.code.CtCodeSnippetExpression other = ((spoon.reflect.code.CtCodeSnippetExpression) (stack.peek())); enter(expression); + biScan(expression.getType(), other.getType()); + biScan(expression.getComments(), other.getComments()); + biScan(expression.getAnnotations(), other.getAnnotations()); + biScan(expression.getTypeCasts(), other.getTypeCasts()); exit(expression); } + // autogenerated by CtBiScannerGenerator public void visitCtCodeSnippetStatement(final spoon.reflect.code.CtCodeSnippetStatement statement) { spoon.reflect.code.CtCodeSnippetStatement other = ((spoon.reflect.code.CtCodeSnippetStatement) (stack.peek())); enter(statement); + biScan(statement.getComments(), other.getComments()); + biScan(statement.getAnnotations(), other.getAnnotations()); exit(statement); } + // autogenerated by CtBiScannerGenerator public void visitCtUnboundVariableReference(final spoon.reflect.reference.CtUnboundVariableReference reference) { spoon.reflect.reference.CtUnboundVariableReference other = ((spoon.reflect.reference.CtUnboundVariableReference) (stack.peek())); enter(reference); + biScan(reference.getType(), other.getType()); exit(reference); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtFieldRead(final spoon.reflect.code.CtFieldRead fieldRead) { spoon.reflect.code.CtFieldRead other = ((spoon.reflect.code.CtFieldRead) (stack.peek())); @@ -734,6 +827,7 @@ public void visitCtFieldRead(final spoon.reflect.code.CtFieldRead fieldRe exit(fieldRead); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtFieldWrite(final spoon.reflect.code.CtFieldWrite fieldWrite) { spoon.reflect.code.CtFieldWrite other = ((spoon.reflect.code.CtFieldWrite) (stack.peek())); @@ -746,22 +840,27 @@ public void visitCtFieldWrite(final spoon.reflect.code.CtFieldWrite field exit(fieldWrite); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtSuperAccess(final spoon.reflect.code.CtSuperAccess f) { spoon.reflect.code.CtSuperAccess other = ((spoon.reflect.code.CtSuperAccess) (stack.peek())); enter(f); - biScan(f.getAnnotations(), other.getAnnotations()); biScan(f.getType(), other.getType()); + biScan(f.getComments(), other.getComments()); + biScan(f.getAnnotations(), other.getAnnotations()); biScan(f.getTypeCasts(), other.getTypeCasts()); biScan(f.getTarget(), other.getTarget()); - biScan(f.getComments(), other.getComments()); + biScan(f.getVariable(), other.getVariable()); exit(f); } + // autogenerated by CtBiScannerGenerator @java.lang.Override public void visitCtComment(final spoon.reflect.code.CtComment comment) { spoon.reflect.code.CtComment other = ((spoon.reflect.code.CtComment) (stack.peek())); enter(comment); + biScan(comment.getComments(), other.getComments()); + biScan(comment.getAnnotations(), other.getAnnotations()); exit(comment); } } diff --git a/src/main/java/spoon/reflect/visitor/CtScanner.java b/src/main/java/spoon/reflect/visitor/CtScanner.java index 616b198c433..07677a615a8 100644 --- a/src/main/java/spoon/reflect/visitor/CtScanner.java +++ b/src/main/java/spoon/reflect/visitor/CtScanner.java @@ -412,6 +412,7 @@ public void visitCtAnnotationFieldAccess( scan(annotationFieldAccess.getComments()); scan(annotationFieldAccess.getAnnotations()); scan(annotationFieldAccess.getTypeCasts()); + scan(annotationFieldAccess.getTarget()); scan(annotationFieldAccess.getType()); scan(annotationFieldAccess.getVariable()); exit(annotationFieldAccess); diff --git a/src/main/java/spoon/support/compiler/FileSystemFolder.java b/src/main/java/spoon/support/compiler/FileSystemFolder.java index 1aece2af7fc..e9cdeafffb2 100644 --- a/src/main/java/spoon/support/compiler/FileSystemFolder.java +++ b/src/main/java/spoon/support/compiler/FileSystemFolder.java @@ -137,6 +137,9 @@ public File toFile() { @Override public boolean equals(Object obj) { + if (obj == null) { + return false; + } return toString().equals(obj.toString()); } diff --git a/src/main/java/spoon/support/compiler/VirtualFolder.java b/src/main/java/spoon/support/compiler/VirtualFolder.java index 94e7760385e..5bc0e098778 100644 --- a/src/main/java/spoon/support/compiler/VirtualFolder.java +++ b/src/main/java/spoon/support/compiler/VirtualFolder.java @@ -89,7 +89,7 @@ public List getSubFolders() { List result = new ArrayList<>(); for (SpoonFile f : getAllFiles()) { SpoonFolder folder = f.getParent(); - if (!result.contains(folder)) { + if (folder != null && !result.contains(folder)) { result.add(folder); } } diff --git a/src/main/java/spoon/support/visitor/clone/CloneVisitor.java b/src/main/java/spoon/support/visitor/clone/CloneVisitor.java index 4429208e419..42a146b16df 100644 --- a/src/main/java/spoon/support/visitor/clone/CloneVisitor.java +++ b/src/main/java/spoon/support/visitor/clone/CloneVisitor.java @@ -299,6 +299,7 @@ public void visitCtAnnotationFieldAccess(final spoon.reflect.code.CtAnnotati aCtAnnotationFieldAccess.setComments(spoon.support.visitor.equals.CloneHelper.clone(annotationFieldAccess.getComments())); aCtAnnotationFieldAccess.setAnnotations(spoon.support.visitor.equals.CloneHelper.clone(annotationFieldAccess.getAnnotations())); aCtAnnotationFieldAccess.setTypeCasts(spoon.support.visitor.equals.CloneHelper.clone(annotationFieldAccess.getTypeCasts())); + aCtAnnotationFieldAccess.setTarget(spoon.support.visitor.equals.CloneHelper.clone(annotationFieldAccess.getTarget())); aCtAnnotationFieldAccess.setType(spoon.support.visitor.equals.CloneHelper.clone(annotationFieldAccess.getType())); aCtAnnotationFieldAccess.setVariable(spoon.support.visitor.equals.CloneHelper.clone(annotationFieldAccess.getVariable())); this.other = aCtAnnotationFieldAccess; diff --git a/src/main/java/spoon/support/visitor/equals/EqualsVisitor.java b/src/main/java/spoon/support/visitor/equals/EqualsVisitor.java index 15857e34fb7..322843c26a6 100644 --- a/src/main/java/spoon/support/visitor/equals/EqualsVisitor.java +++ b/src/main/java/spoon/support/visitor/equals/EqualsVisitor.java @@ -19,20 +19,22 @@ package spoon.support.visitor.equals; +import spoon.reflect.declaration.CtElement; +import spoon.reflect.visitor.CtBiScannerDefault; + /** * Used to check equality between an element and another one. * - * This class is generated automatically by the processor {@link spoon.generating.EqualsVisitorGenerator}. */ -public class EqualsVisitor extends spoon.reflect.visitor.CtAbstractBiScanner { - public static boolean equals(spoon.reflect.declaration.CtElement element, spoon.reflect.declaration.CtElement other) { - return !(new spoon.support.visitor.equals.EqualsVisitor().biScan(element, other)); +public class EqualsVisitor extends CtBiScannerDefault { + public static boolean equals(CtElement element, CtElement other) { + return !new EqualsVisitor().biScan(element, other); } - private final spoon.support.visitor.equals.EqualsChecker checker = new spoon.support.visitor.equals.EqualsChecker(); + private final EqualsChecker checker = new EqualsChecker(); - @java.lang.Override - protected void enter(spoon.reflect.declaration.CtElement e) { + @Override + protected void enter(CtElement e) { super.enter(e); checker.setOther(stack.peek()); checker.scan(e); @@ -41,679 +43,49 @@ protected void enter(spoon.reflect.declaration.CtElement e) { } } - public void visitCtAnnotation(final spoon.reflect.declaration.CtAnnotation annotation) { - spoon.reflect.declaration.CtAnnotation other = ((spoon.reflect.declaration.CtAnnotation) (stack.peek())); - enter(annotation); - biScan(annotation.getAnnotationType(), other.getAnnotationType()); - biScan(annotation.getAnnotations(), other.getAnnotations()); - biScan(annotation.getValues().values(), other.getValues().values()); - exit(annotation); - } - - public void visitCtAnnotationType(final spoon.reflect.declaration.CtAnnotationType annotationType) { - spoon.reflect.declaration.CtAnnotationType other = ((spoon.reflect.declaration.CtAnnotationType) (stack.peek())); - enter(annotationType); - biScan(annotationType.getAnnotations(), other.getAnnotations()); - biScan(annotationType.getTypeMembers(), other.getTypeMembers()); - exit(annotationType); - } + @Override + public void visitCtTypeReference(final spoon.reflect.reference.CtTypeReference reference) { + spoon.reflect.reference.CtTypeReference other = ((spoon.reflect.reference.CtTypeReference) (stack.peek())); + enter(reference); + biScan(reference.getPackage(), other.getPackage()); + biScan(reference.getDeclaringType(), other.getDeclaringType()); - public void visitCtAnonymousExecutable(final spoon.reflect.declaration.CtAnonymousExecutable anonymousExec) { - spoon.reflect.declaration.CtAnonymousExecutable other = ((spoon.reflect.declaration.CtAnonymousExecutable) (stack.peek())); - enter(anonymousExec); - biScan(anonymousExec.getAnnotations(), other.getAnnotations()); - biScan(anonymousExec.getBody(), other.getBody()); - exit(anonymousExec); - } + //biScan(reference.getActualTypeArguments(), other.getActualTypeArguments()); // required to be commented - @java.lang.Override - public void visitCtArrayRead(final spoon.reflect.code.CtArrayRead arrayRead) { - spoon.reflect.code.CtArrayRead other = ((spoon.reflect.code.CtArrayRead) (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()); - exit(arrayRead); - } - - @java.lang.Override - public void visitCtArrayWrite(final spoon.reflect.code.CtArrayWrite arrayWrite) { - spoon.reflect.code.CtArrayWrite other = ((spoon.reflect.code.CtArrayWrite) (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()); - exit(arrayWrite); + biScan(reference.getAnnotations(), other.getAnnotations()); + biScan(reference.getComments(), other.getComments()); + exit(reference); } + @Override public void visitCtArrayTypeReference(final spoon.reflect.reference.CtArrayTypeReference reference) { spoon.reflect.reference.CtArrayTypeReference other = ((spoon.reflect.reference.CtArrayTypeReference) (stack.peek())); enter(reference); - biScan(reference.getDeclaringType(), other.getDeclaringType()); + biScan(reference.getComments(), other.getComments()); biScan(reference.getPackage(), other.getPackage()); + biScan(reference.getDeclaringType(), other.getDeclaringType()); biScan(reference.getComponentType(), other.getComponentType()); - biScan(reference.getAnnotations(), other.getAnnotations()); - exit(reference); - } - - public void visitCtAssert(final spoon.reflect.code.CtAssert asserted) { - spoon.reflect.code.CtAssert other = ((spoon.reflect.code.CtAssert) (stack.peek())); - enter(asserted); - biScan(asserted.getAnnotations(), other.getAnnotations()); - biScan(asserted.getAssertExpression(), other.getAssertExpression()); - biScan(asserted.getExpression(), other.getExpression()); - exit(asserted); - } - - public void visitCtAssignment(final spoon.reflect.code.CtAssignment assignement) { - spoon.reflect.code.CtAssignment other = ((spoon.reflect.code.CtAssignment) (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()); - exit(assignement); - } - - public void visitCtBinaryOperator(final spoon.reflect.code.CtBinaryOperator operator) { - spoon.reflect.code.CtBinaryOperator other = ((spoon.reflect.code.CtBinaryOperator) (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()); - exit(operator); - } - - public void visitCtBlock(final spoon.reflect.code.CtBlock block) { - spoon.reflect.code.CtBlock other = ((spoon.reflect.code.CtBlock) (stack.peek())); - enter(block); - biScan(block.getAnnotations(), other.getAnnotations()); - biScan(block.getStatements(), other.getStatements()); - exit(block); - } - - public void visitCtBreak(final spoon.reflect.code.CtBreak breakStatement) { - spoon.reflect.code.CtBreak other = ((spoon.reflect.code.CtBreak) (stack.peek())); - enter(breakStatement); - biScan(breakStatement.getAnnotations(), other.getAnnotations()); - exit(breakStatement); - } - - public void visitCtCase(final spoon.reflect.code.CtCase caseStatement) { - spoon.reflect.code.CtCase other = ((spoon.reflect.code.CtCase) (stack.peek())); - enter(caseStatement); - biScan(caseStatement.getAnnotations(), other.getAnnotations()); - biScan(caseStatement.getCaseExpression(), other.getCaseExpression()); - biScan(caseStatement.getStatements(), other.getStatements()); - exit(caseStatement); - } - - public void visitCtCatch(final spoon.reflect.code.CtCatch catchBlock) { - spoon.reflect.code.CtCatch other = ((spoon.reflect.code.CtCatch) (stack.peek())); - enter(catchBlock); - biScan(catchBlock.getAnnotations(), other.getAnnotations()); - biScan(catchBlock.getParameter(), other.getParameter()); - biScan(catchBlock.getBody(), other.getBody()); - exit(catchBlock); - } - - public void visitCtClass(final spoon.reflect.declaration.CtClass ctClass) { - spoon.reflect.declaration.CtClass other = ((spoon.reflect.declaration.CtClass) (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()); - exit(ctClass); - } - - @java.lang.Override - public void visitCtTypeParameter(spoon.reflect.declaration.CtTypeParameter typeParameter) { - spoon.reflect.declaration.CtTypeParameter other = ((spoon.reflect.declaration.CtTypeParameter) (stack.peek())); - enter(typeParameter); - biScan(typeParameter.getAnnotations(), other.getAnnotations()); - biScan(typeParameter.getSuperclass(), other.getSuperclass()); - exit(typeParameter); - } - - public void visitCtConditional(final spoon.reflect.code.CtConditional conditional) { - spoon.reflect.code.CtConditional other = ((spoon.reflect.code.CtConditional) (stack.peek())); - enter(conditional); - biScan(conditional.getAnnotations(), other.getAnnotations()); - biScan(conditional.getCondition(), other.getCondition()); - biScan(conditional.getThenExpression(), other.getThenExpression()); - biScan(conditional.getElseExpression(), other.getElseExpression()); - biScan(conditional.getTypeCasts(), other.getTypeCasts()); - exit(conditional); - } - - public void visitCtConstructor(final spoon.reflect.declaration.CtConstructor c) { - spoon.reflect.declaration.CtConstructor other = ((spoon.reflect.declaration.CtConstructor) (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()); - exit(c); - } - - public void visitCtContinue(final spoon.reflect.code.CtContinue continueStatement) { - spoon.reflect.code.CtContinue other = ((spoon.reflect.code.CtContinue) (stack.peek())); - enter(continueStatement); - biScan(continueStatement.getAnnotations(), other.getAnnotations()); - biScan(continueStatement.getLabelledStatement(), other.getLabelledStatement()); - exit(continueStatement); - } - public void visitCtDo(final spoon.reflect.code.CtDo doLoop) { - spoon.reflect.code.CtDo other = ((spoon.reflect.code.CtDo) (stack.peek())); - enter(doLoop); - biScan(doLoop.getAnnotations(), other.getAnnotations()); - biScan(doLoop.getLoopingExpression(), other.getLoopingExpression()); - biScan(doLoop.getBody(), other.getBody()); - exit(doLoop); - } + //biScan(reference.getActualTypeArguments(), other.getActualTypeArguments()); // required to be commented - public > void visitCtEnum(final spoon.reflect.declaration.CtEnum ctEnum) { - spoon.reflect.declaration.CtEnum other = ((spoon.reflect.declaration.CtEnum) (stack.peek())); - enter(ctEnum); - biScan(ctEnum.getAnnotations(), other.getAnnotations()); - biScan(ctEnum.getSuperInterfaces(), other.getSuperInterfaces()); - biScan(ctEnum.getTypeMembers(), other.getTypeMembers()); - biScan(ctEnum.getEnumValues(), other.getEnumValues()); - exit(ctEnum); + biScan(reference.getAnnotations(), other.getAnnotations()); + exit(reference); } + @Override public void visitCtExecutableReference(final spoon.reflect.reference.CtExecutableReference reference) { spoon.reflect.reference.CtExecutableReference other = ((spoon.reflect.reference.CtExecutableReference) (stack.peek())); enter(reference); biScan(reference.getDeclaringType(), other.getDeclaringType()); biScan(reference.getParameters(), other.getParameters()); - biScan(reference.getAnnotations(), other.getAnnotations()); - exit(reference); - } - - public void visitCtField(final spoon.reflect.declaration.CtField f) { - spoon.reflect.declaration.CtField other = ((spoon.reflect.declaration.CtField) (stack.peek())); - enter(f); - biScan(f.getAnnotations(), other.getAnnotations()); - biScan(f.getType(), other.getType()); - biScan(f.getDefaultExpression(), other.getDefaultExpression()); - exit(f); - } - - @java.lang.Override - public void visitCtEnumValue(final spoon.reflect.declaration.CtEnumValue enumValue) { - spoon.reflect.declaration.CtEnumValue other = ((spoon.reflect.declaration.CtEnumValue) (stack.peek())); - enter(enumValue); - biScan(enumValue.getAnnotations(), other.getAnnotations()); - biScan(enumValue.getType(), other.getType()); - biScan(enumValue.getDefaultExpression(), other.getDefaultExpression()); - exit(enumValue); - } - - @java.lang.Override - public void visitCtThisAccess(final spoon.reflect.code.CtThisAccess thisAccess) { - spoon.reflect.code.CtThisAccess other = ((spoon.reflect.code.CtThisAccess) (stack.peek())); - enter(thisAccess); - biScan(thisAccess.getType(), other.getType()); - biScan(thisAccess.getTypeCasts(), other.getTypeCasts()); - biScan(thisAccess.getTarget(), other.getTarget()); - exit(thisAccess); - } - - public void visitCtAnnotationFieldAccess(final spoon.reflect.code.CtAnnotationFieldAccess annotationFieldAccess) { - spoon.reflect.code.CtAnnotationFieldAccess other = ((spoon.reflect.code.CtAnnotationFieldAccess) (stack.peek())); - enter(annotationFieldAccess); - biScan(annotationFieldAccess.getAnnotations(), other.getAnnotations()); - biScan(annotationFieldAccess.getType(), other.getType()); - biScan(annotationFieldAccess.getTypeCasts(), other.getTypeCasts()); - biScan(annotationFieldAccess.getTarget(), other.getTarget()); - biScan(annotationFieldAccess.getVariable(), other.getVariable()); - exit(annotationFieldAccess); - } - - public void visitCtFieldReference(final spoon.reflect.reference.CtFieldReference reference) { - spoon.reflect.reference.CtFieldReference other = ((spoon.reflect.reference.CtFieldReference) (stack.peek())); - enter(reference); - biScan(reference.getDeclaringType(), other.getDeclaringType()); - biScan(reference.getType(), other.getType()); - biScan(reference.getAnnotations(), other.getAnnotations()); - exit(reference); - } - - public void visitCtFor(final spoon.reflect.code.CtFor forLoop) { - spoon.reflect.code.CtFor other = ((spoon.reflect.code.CtFor) (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()); - exit(forLoop); - } - - public void visitCtForEach(final spoon.reflect.code.CtForEach foreach) { - spoon.reflect.code.CtForEach other = ((spoon.reflect.code.CtForEach) (stack.peek())); - enter(foreach); - biScan(foreach.getAnnotations(), other.getAnnotations()); - biScan(foreach.getVariable(), other.getVariable()); - biScan(foreach.getExpression(), other.getExpression()); - biScan(foreach.getBody(), other.getBody()); - exit(foreach); - } - - public void visitCtIf(final spoon.reflect.code.CtIf ifElement) { - spoon.reflect.code.CtIf other = ((spoon.reflect.code.CtIf) (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()); - exit(ifElement); - } - - public void visitCtInterface(final spoon.reflect.declaration.CtInterface intrface) { - spoon.reflect.declaration.CtInterface other = ((spoon.reflect.declaration.CtInterface) (stack.peek())); - enter(intrface); - biScan(intrface.getAnnotations(), other.getAnnotations()); - biScan(intrface.getSuperInterfaces(), other.getSuperInterfaces()); - biScan(intrface.getFormalCtTypeParameters(), other.getFormalCtTypeParameters()); - biScan(intrface.getTypeMembers(), other.getTypeMembers()); - exit(intrface); - } - - public void visitCtInvocation(final spoon.reflect.code.CtInvocation invocation) { - spoon.reflect.code.CtInvocation other = ((spoon.reflect.code.CtInvocation) (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()); - exit(invocation); - } - - public void visitCtLiteral(final spoon.reflect.code.CtLiteral literal) { - spoon.reflect.code.CtLiteral other = ((spoon.reflect.code.CtLiteral) (stack.peek())); - enter(literal); - biScan(literal.getAnnotations(), other.getAnnotations()); - biScan(literal.getType(), other.getType()); - biScan(literal.getTypeCasts(), other.getTypeCasts()); - exit(literal); - } - - public void visitCtLocalVariable(final spoon.reflect.code.CtLocalVariable localVariable) { - spoon.reflect.code.CtLocalVariable other = ((spoon.reflect.code.CtLocalVariable) (stack.peek())); - enter(localVariable); - biScan(localVariable.getAnnotations(), other.getAnnotations()); - biScan(localVariable.getType(), other.getType()); - biScan(localVariable.getDefaultExpression(), other.getDefaultExpression()); - exit(localVariable); - } - - public void visitCtLocalVariableReference(final spoon.reflect.reference.CtLocalVariableReference reference) { - spoon.reflect.reference.CtLocalVariableReference other = ((spoon.reflect.reference.CtLocalVariableReference) (stack.peek())); - enter(reference); - biScan(reference.getType(), other.getType()); - biScan(reference.getAnnotations(), other.getAnnotations()); - exit(reference); - } - - public void visitCtCatchVariable(final spoon.reflect.code.CtCatchVariable catchVariable) { - spoon.reflect.code.CtCatchVariable other = ((spoon.reflect.code.CtCatchVariable) (stack.peek())); - enter(catchVariable); - biScan(catchVariable.getAnnotations(), other.getAnnotations()); - biScan(catchVariable.getType(), other.getType()); - exit(catchVariable); - } - public void visitCtCatchVariableReference(final spoon.reflect.reference.CtCatchVariableReference reference) { - spoon.reflect.reference.CtCatchVariableReference other = ((spoon.reflect.reference.CtCatchVariableReference) (stack.peek())); - enter(reference); - biScan(reference.getType(), other.getType()); - biScan(reference.getAnnotations(), other.getAnnotations()); - exit(reference); - } - - public void visitCtMethod(final spoon.reflect.declaration.CtMethod m) { - spoon.reflect.declaration.CtMethod other = ((spoon.reflect.declaration.CtMethod) (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()); - exit(m); - } - - @java.lang.Override - public void visitCtAnnotationMethod(spoon.reflect.declaration.CtAnnotationMethod annotationMethod) { - spoon.reflect.declaration.CtAnnotationMethod other = ((spoon.reflect.declaration.CtAnnotationMethod) (stack.peek())); - enter(annotationMethod); - biScan(annotationMethod.getAnnotations(), other.getAnnotations()); - biScan(annotationMethod.getType(), other.getType()); - biScan(annotationMethod.getDefaultExpression(), other.getDefaultExpression()); - exit(annotationMethod); - } - - public void visitCtNewArray(final spoon.reflect.code.CtNewArray newArray) { - spoon.reflect.code.CtNewArray other = ((spoon.reflect.code.CtNewArray) (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()); - exit(newArray); - } - - @java.lang.Override - public void visitCtConstructorCall(final spoon.reflect.code.CtConstructorCall ctConstructorCall) { - spoon.reflect.code.CtConstructorCall other = ((spoon.reflect.code.CtConstructorCall) (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()); - exit(ctConstructorCall); - } - - public void visitCtNewClass(final spoon.reflect.code.CtNewClass newClass) { - spoon.reflect.code.CtNewClass other = ((spoon.reflect.code.CtNewClass) (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()); - exit(newClass); - } - - @java.lang.Override - public void visitCtLambda(final spoon.reflect.code.CtLambda lambda) { - spoon.reflect.code.CtLambda other = ((spoon.reflect.code.CtLambda) (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.getBody(), other.getBody()); - biScan(lambda.getExpression(), other.getExpression()); - exit(lambda); - } - - @java.lang.Override - public > void visitCtExecutableReferenceExpression(final spoon.reflect.code.CtExecutableReferenceExpression expression) { - spoon.reflect.code.CtExecutableReferenceExpression other = ((spoon.reflect.code.CtExecutableReferenceExpression) (stack.peek())); - enter(expression); - biScan(expression.getType(), other.getType()); - biScan(expression.getTypeCasts(), other.getTypeCasts()); - biScan(expression.getExecutable(), other.getExecutable()); - biScan(expression.getTarget(), other.getTarget()); - exit(expression); - } - - public void visitCtOperatorAssignment(final spoon.reflect.code.CtOperatorAssignment assignment) { - spoon.reflect.code.CtOperatorAssignment other = ((spoon.reflect.code.CtOperatorAssignment) (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()); - exit(assignment); - } - - public void visitCtPackage(final spoon.reflect.declaration.CtPackage ctPackage) { - spoon.reflect.declaration.CtPackage other = ((spoon.reflect.declaration.CtPackage) (stack.peek())); - enter(ctPackage); - biScan(ctPackage.getAnnotations(), other.getAnnotations()); - biScan(ctPackage.getPackages(), other.getPackages()); - biScan(ctPackage.getTypes(), other.getTypes()); - exit(ctPackage); - } - - public void visitCtPackageReference(final spoon.reflect.reference.CtPackageReference reference) { - spoon.reflect.reference.CtPackageReference other = ((spoon.reflect.reference.CtPackageReference) (stack.peek())); - enter(reference); - exit(reference); - } - - public void visitCtParameter(final spoon.reflect.declaration.CtParameter parameter) { - spoon.reflect.declaration.CtParameter other = ((spoon.reflect.declaration.CtParameter) (stack.peek())); - enter(parameter); - biScan(parameter.getAnnotations(), other.getAnnotations()); - biScan(parameter.getType(), other.getType()); - exit(parameter); - } - - public void visitCtParameterReference(final spoon.reflect.reference.CtParameterReference reference) { - spoon.reflect.reference.CtParameterReference other = ((spoon.reflect.reference.CtParameterReference) (stack.peek())); - enter(reference); - biScan(reference.getType(), other.getType()); - biScan(reference.getAnnotations(), other.getAnnotations()); - biScan(reference.getDeclaringExecutable(), other.getDeclaringExecutable()); - exit(reference); - } - - public void visitCtReturn(final spoon.reflect.code.CtReturn returnStatement) { - spoon.reflect.code.CtReturn other = ((spoon.reflect.code.CtReturn) (stack.peek())); - enter(returnStatement); - biScan(returnStatement.getAnnotations(), other.getAnnotations()); - biScan(returnStatement.getReturnedExpression(), other.getReturnedExpression()); - exit(returnStatement); - } - - public void visitCtStatementList(final spoon.reflect.code.CtStatementList statements) { - spoon.reflect.code.CtStatementList other = ((spoon.reflect.code.CtStatementList) (stack.peek())); - enter(statements); - biScan(statements.getAnnotations(), other.getAnnotations()); - biScan(statements.getStatements(), other.getStatements()); - exit(statements); - } - - public void visitCtSwitch(final spoon.reflect.code.CtSwitch switchStatement) { - spoon.reflect.code.CtSwitch other = ((spoon.reflect.code.CtSwitch) (stack.peek())); - enter(switchStatement); - biScan(switchStatement.getAnnotations(), other.getAnnotations()); - biScan(switchStatement.getSelector(), other.getSelector()); - biScan(switchStatement.getCases(), other.getCases()); - exit(switchStatement); - } - - public void visitCtSynchronized(final spoon.reflect.code.CtSynchronized synchro) { - spoon.reflect.code.CtSynchronized other = ((spoon.reflect.code.CtSynchronized) (stack.peek())); - enter(synchro); - biScan(synchro.getAnnotations(), other.getAnnotations()); - biScan(synchro.getExpression(), other.getExpression()); - biScan(synchro.getBlock(), other.getBlock()); - exit(synchro); - } - - public void visitCtThrow(final spoon.reflect.code.CtThrow throwStatement) { - spoon.reflect.code.CtThrow other = ((spoon.reflect.code.CtThrow) (stack.peek())); - enter(throwStatement); - biScan(throwStatement.getAnnotations(), other.getAnnotations()); - biScan(throwStatement.getThrownExpression(), other.getThrownExpression()); - exit(throwStatement); - } - - public void visitCtTry(final spoon.reflect.code.CtTry tryBlock) { - spoon.reflect.code.CtTry other = ((spoon.reflect.code.CtTry) (stack.peek())); - enter(tryBlock); - biScan(tryBlock.getAnnotations(), other.getAnnotations()); - biScan(tryBlock.getBody(), other.getBody()); - biScan(tryBlock.getCatchers(), other.getCatchers()); - biScan(tryBlock.getFinalizer(), other.getFinalizer()); - exit(tryBlock); - } + //biScan(reference.getActualTypeArguments(), other.getActualTypeArguments()); // required to be commented - @java.lang.Override - public void visitCtTryWithResource(final spoon.reflect.code.CtTryWithResource tryWithResource) { - spoon.reflect.code.CtTryWithResource other = ((spoon.reflect.code.CtTryWithResource) (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()); - exit(tryWithResource); - } - - public void visitCtTypeParameterReference(final spoon.reflect.reference.CtTypeParameterReference ref) { - spoon.reflect.reference.CtTypeParameterReference other = ((spoon.reflect.reference.CtTypeParameterReference) (stack.peek())); - enter(ref); - biScan(ref.getPackage(), other.getPackage()); - biScan(ref.getDeclaringType(), other.getDeclaringType()); - biScan(ref.getAnnotations(), other.getAnnotations()); - biScan(ref.getBoundingType(), other.getBoundingType()); - exit(ref); - } - - @java.lang.Override - public void visitCtWildcardReference(spoon.reflect.reference.CtWildcardReference wildcardReference) { - spoon.reflect.reference.CtWildcardReference other = ((spoon.reflect.reference.CtWildcardReference) (stack.peek())); - enter(wildcardReference); - biScan(wildcardReference.getAnnotations(), other.getAnnotations()); - biScan(wildcardReference.getBoundingType(), other.getBoundingType()); - exit(wildcardReference); - } - - @java.lang.Override - public void visitCtIntersectionTypeReference(final spoon.reflect.reference.CtIntersectionTypeReference reference) { - spoon.reflect.reference.CtIntersectionTypeReference other = ((spoon.reflect.reference.CtIntersectionTypeReference) (stack.peek())); - enter(reference); - biScan(reference.getBounds(), other.getBounds()); - exit(reference); - } - - public void visitCtTypeReference(final spoon.reflect.reference.CtTypeReference reference) { - spoon.reflect.reference.CtTypeReference other = ((spoon.reflect.reference.CtTypeReference) (stack.peek())); - enter(reference); - biScan(reference.getPackage(), other.getPackage()); - biScan(reference.getDeclaringType(), other.getDeclaringType()); biScan(reference.getAnnotations(), other.getAnnotations()); + biScan(reference.getComments(), other.getComments()); exit(reference); } - @java.lang.Override - public void visitCtTypeAccess(final spoon.reflect.code.CtTypeAccess typeAccess) { - spoon.reflect.code.CtTypeAccess other = ((spoon.reflect.code.CtTypeAccess) (stack.peek())); - enter(typeAccess); - biScan(typeAccess.getAnnotations(), other.getAnnotations()); - biScan(typeAccess.getTypeCasts(), other.getTypeCasts()); - biScan(typeAccess.getAccessedType(), other.getAccessedType()); - exit(typeAccess); - } - - public void visitCtUnaryOperator(final spoon.reflect.code.CtUnaryOperator operator) { - spoon.reflect.code.CtUnaryOperator other = ((spoon.reflect.code.CtUnaryOperator) (stack.peek())); - enter(operator); - biScan(operator.getAnnotations(), other.getAnnotations()); - biScan(operator.getType(), other.getType()); - biScan(operator.getTypeCasts(), other.getTypeCasts()); - biScan(operator.getOperand(), other.getOperand()); - exit(operator); - } - - @java.lang.Override - public void visitCtVariableRead(final spoon.reflect.code.CtVariableRead variableRead) { - spoon.reflect.code.CtVariableRead other = ((spoon.reflect.code.CtVariableRead) (stack.peek())); - enter(variableRead); - biScan(variableRead.getAnnotations(), other.getAnnotations()); - biScan(variableRead.getTypeCasts(), other.getTypeCasts()); - biScan(variableRead.getVariable(), other.getVariable()); - exit(variableRead); - } - - @java.lang.Override - public void visitCtVariableWrite(final spoon.reflect.code.CtVariableWrite variableWrite) { - spoon.reflect.code.CtVariableWrite other = ((spoon.reflect.code.CtVariableWrite) (stack.peek())); - enter(variableWrite); - biScan(variableWrite.getAnnotations(), other.getAnnotations()); - biScan(variableWrite.getTypeCasts(), other.getTypeCasts()); - biScan(variableWrite.getVariable(), other.getVariable()); - exit(variableWrite); - } - - public void visitCtWhile(final spoon.reflect.code.CtWhile whileLoop) { - spoon.reflect.code.CtWhile other = ((spoon.reflect.code.CtWhile) (stack.peek())); - enter(whileLoop); - biScan(whileLoop.getAnnotations(), other.getAnnotations()); - biScan(whileLoop.getLoopingExpression(), other.getLoopingExpression()); - biScan(whileLoop.getBody(), other.getBody()); - exit(whileLoop); - } - - public void visitCtCodeSnippetExpression(final spoon.reflect.code.CtCodeSnippetExpression expression) { - spoon.reflect.code.CtCodeSnippetExpression other = ((spoon.reflect.code.CtCodeSnippetExpression) (stack.peek())); - enter(expression); - exit(expression); - } - - public void visitCtCodeSnippetStatement(final spoon.reflect.code.CtCodeSnippetStatement statement) { - spoon.reflect.code.CtCodeSnippetStatement other = ((spoon.reflect.code.CtCodeSnippetStatement) (stack.peek())); - enter(statement); - exit(statement); - } - - public void visitCtUnboundVariableReference(final spoon.reflect.reference.CtUnboundVariableReference reference) { - spoon.reflect.reference.CtUnboundVariableReference other = ((spoon.reflect.reference.CtUnboundVariableReference) (stack.peek())); - enter(reference); - exit(reference); - } - - @java.lang.Override - public void visitCtFieldRead(final spoon.reflect.code.CtFieldRead fieldRead) { - spoon.reflect.code.CtFieldRead other = ((spoon.reflect.code.CtFieldRead) (stack.peek())); - enter(fieldRead); - biScan(fieldRead.getAnnotations(), other.getAnnotations()); - biScan(fieldRead.getTypeCasts(), other.getTypeCasts()); - biScan(fieldRead.getTarget(), other.getTarget()); - biScan(fieldRead.getVariable(), other.getVariable()); - exit(fieldRead); - } - - @java.lang.Override - public void visitCtFieldWrite(final spoon.reflect.code.CtFieldWrite fieldWrite) { - spoon.reflect.code.CtFieldWrite other = ((spoon.reflect.code.CtFieldWrite) (stack.peek())); - enter(fieldWrite); - biScan(fieldWrite.getAnnotations(), other.getAnnotations()); - biScan(fieldWrite.getTypeCasts(), other.getTypeCasts()); - biScan(fieldWrite.getTarget(), other.getTarget()); - biScan(fieldWrite.getVariable(), other.getVariable()); - exit(fieldWrite); - } - @java.lang.Override - public void visitCtSuperAccess(final spoon.reflect.code.CtSuperAccess f) { - spoon.reflect.code.CtSuperAccess other = ((spoon.reflect.code.CtSuperAccess) (stack.peek())); - enter(f); - biScan(f.getAnnotations(), other.getAnnotations()); - biScan(f.getType(), other.getType()); - biScan(f.getTypeCasts(), other.getTypeCasts()); - biScan(f.getTarget(), other.getTarget()); - exit(f); - } - - @java.lang.Override - public void visitCtComment(final spoon.reflect.code.CtComment comment) { - spoon.reflect.code.CtComment other = ((spoon.reflect.code.CtComment) (stack.peek())); - enter(comment); - exit(comment); - } } diff --git a/src/main/java/spoon/support/visitor/equals/IgnoredByEquals.java b/src/main/java/spoon/support/visitor/equals/IgnoredByEquals.java deleted file mode 100644 index bfbe7d38203..00000000000 --- a/src/main/java/spoon/support/visitor/equals/IgnoredByEquals.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (C) 2006-2016 INRIA and contributors - * Spoon - http://spoon.gforge.inria.fr/ - * - * This software is governed by the CeCILL-C License under French law and - * abiding by the rules of distribution of free software. You can use, modify - * and/or redistribute the software under the terms of the CeCILL-C license as - * circulated by CEA, CNRS and INRIA at http://www.cecill.info. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL-C license and that you accept its terms. - */ -package spoon.support.visitor.equals; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.METHOD }) -public @interface IgnoredByEquals { -} diff --git a/src/main/java/spoon/support/visitor/replace/ReplacementVisitor.java b/src/main/java/spoon/support/visitor/replace/ReplacementVisitor.java index 76df3bcc956..9a0453d26e0 100644 --- a/src/main/java/spoon/support/visitor/replace/ReplacementVisitor.java +++ b/src/main/java/spoon/support/visitor/replace/ReplacementVisitor.java @@ -938,6 +938,7 @@ public void visitCtAnnotationFieldAccess(final spoon.reflect.code.CtAnnotati replaceInListIfExist(annotationFieldAccess.getComments(), new spoon.support.visitor.replace.ReplacementVisitor.CtElementCommentsReplaceListener(annotationFieldAccess)); replaceInListIfExist(annotationFieldAccess.getAnnotations(), new spoon.support.visitor.replace.ReplacementVisitor.CtElementAnnotationsReplaceListener(annotationFieldAccess)); replaceInListIfExist(annotationFieldAccess.getTypeCasts(), new spoon.support.visitor.replace.ReplacementVisitor.CtExpressionTypeCastsReplaceListener(annotationFieldAccess)); + replaceElementIfExist(annotationFieldAccess.getTarget(), new spoon.support.visitor.replace.ReplacementVisitor.CtTargetedExpressionTargetReplaceListener(annotationFieldAccess)); replaceElementIfExist(annotationFieldAccess.getType(), new spoon.support.visitor.replace.ReplacementVisitor.CtVariableAccessTypeReplaceListener(annotationFieldAccess)); replaceElementIfExist(annotationFieldAccess.getVariable(), new spoon.support.visitor.replace.ReplacementVisitor.CtAnnotationFieldAccessVariableReplaceListener(annotationFieldAccess)); } diff --git a/src/main/java/spoon/testing/utils/ModelUtils.java b/src/main/java/spoon/testing/utils/ModelUtils.java index 6d6a0509340..4da923b2340 100644 --- a/src/main/java/spoon/testing/utils/ModelUtils.java +++ b/src/main/java/spoon/testing/utils/ModelUtils.java @@ -85,7 +85,7 @@ public static Factory build(File... filesToBuild) { try { comp.addInputSource(SpoonResourceHelper.createResource(fileToBuild)); } catch (FileNotFoundException e) { - throw new RuntimeException("File not found"); + throw new RuntimeException("File not found", e); } } comp.build(); diff --git a/src/test/java/spoon/processing/CtGenerationTest.java b/src/test/java/spoon/processing/CtGenerationTest.java index e31dc240328..2e1c0dc0297 100644 --- a/src/test/java/spoon/processing/CtGenerationTest.java +++ b/src/test/java/spoon/processing/CtGenerationTest.java @@ -2,17 +2,14 @@ import org.junit.ComparisonFailure; import org.junit.Test; - import spoon.Launcher; import spoon.generating.CloneVisitorGenerator; import spoon.generating.CtBiScannerGenerator; -import spoon.generating.EqualsVisitorGenerator; import spoon.generating.ReplacementVisitorGenerator; import spoon.reflect.declaration.CtClass; import spoon.reflect.declaration.CtElement; import spoon.reflect.declaration.CtType; import spoon.reflect.visitor.Filter; -import spoon.support.visitor.equals.EqualsVisitor; import java.io.File; import java.util.regex.Matcher; @@ -30,6 +27,7 @@ public void testGenerateReplacementVisitor() throws Exception { launcher.getEnvironment().setNoClasspath(true); launcher.getEnvironment().setCommentEnabled(true); launcher.getEnvironment().useTabulations(true); + //launcher.getEnvironment().setAutoImports(true); launcher.setSourceOutputDirectory("./target/generated/"); // interfaces. launcher.addInputResource("./src/main/java/spoon/reflect/code"); @@ -44,8 +42,8 @@ public void testGenerateReplacementVisitor() throws Exception { launcher.run(); // cp ./target/generated/spoon/support/visitor/replace/ReplacementVisitor.java ./src/main/java/spoon/support/visitor/replace/ReplacementVisitor.java - CtClass actual = build(new File("./src/main/java/spoon/support/visitor/replace/ReplacementVisitor.java")).Class().get("spoon.support.visitor.replace.ReplacementVisitor"); - CtClass expected = build(new File("./target/generated/spoon/support/visitor/replace/ReplacementVisitor.java")).Class().get("spoon.support.visitor.replace.ReplacementVisitor"); + CtClass actual = build(new File(launcher.getModelBuilder().getSourceOutputDirectory()+"/spoon/support/visitor/replace/ReplacementVisitor.java")).Class().get("spoon.support.visitor.replace.ReplacementVisitor"); + CtClass expected = build(new File("./src/main/java/spoon/support/visitor/replace/ReplacementVisitor.java")).Class().get("spoon.support.visitor.replace.ReplacementVisitor"); try { assertThat(actual) .isEqualTo(expected); @@ -56,6 +54,7 @@ public void testGenerateReplacementVisitor() throws Exception { @Test public void testGenerateCtBiScanner() throws Exception { + // contract: generates the biscanner that is used for equality checking //use always LINUX line separator, because generated files are committed to Spoon repository which expects that. System.setProperty("line.separator", "\n"); final Launcher launcher = new Launcher(); @@ -75,6 +74,7 @@ public void testGenerateCtBiScanner() throws Exception { launcher.setOutputFilter(new RegexFilter("spoon.reflect.visitor.CtBiScannerDefault")); launcher.run(); + // cp ./target/generated/spoon/reflect/visitor/CtBiScannerDefault.java ./src/main/java/spoon/reflect/visitor/CtBiScannerDefault.java // we don't necessarily want to hard-wired the relation bewteen CtScanner and CtBiScannerDefault.java // this can be done on an informed basis when important changes are made in the metamodel/scanner // and then we can have smaller clean tested pull requests to see the impact of the change @@ -83,38 +83,6 @@ public void testGenerateCtBiScanner() throws Exception { // .isEqualTo(build(new File("./target/generated/spoon/reflect/visitor/CtBiScannerDefault.java")).Class().get(CtBiScannerDefault.class)); } - @Test - public void testGenerateEqualsVisitor() throws Exception { - //use always LINUX line separator, because generated files are committed to Spoon repository which expects that. - System.setProperty("line.separator", "\n"); - final Launcher launcher = new Launcher(); - launcher.getEnvironment().setNoClasspath(true); - launcher.getEnvironment().setCommentEnabled(true); - launcher.getEnvironment().useTabulations(true); - launcher.setSourceOutputDirectory("./target/generated/"); - // interfaces. - launcher.addInputResource("./src/main/java/spoon/reflect/code"); - launcher.addInputResource("./src/main/java/spoon/reflect/declaration"); - launcher.addInputResource("./src/main/java/spoon/reflect/reference"); - launcher.addInputResource("./src/main/java/spoon/reflect/internal"); - // Utils. - launcher.addInputResource("./src/main/java/spoon/reflect/visitor/CtAbstractBiScanner.java"); - launcher.addInputResource("./src/main/java/spoon/reflect/visitor/CtBiScannerDefault.java"); - launcher.addInputResource("./src/main/java/spoon/generating/equals/"); - launcher.addProcessor(new EqualsVisitorGenerator()); - launcher.setOutputFilter(new RegexFilter("spoon.support.visitor.equals.EqualsVisitor")); - launcher.run(); - - CtClass actual = build(new File("./src/main/java/spoon/support/visitor/equals/EqualsVisitor.java")).Class().get(EqualsVisitor.class); - CtClass expected = build(new File("./target/generated/spoon/support/visitor/equals/EqualsVisitor.java")).Class().get(EqualsVisitor.class); - try { - assertThat(actual) - .isEqualTo(expected); - } catch (AssertionError e) { - throw new ComparisonFailure("EqualsVisitor different", expected.toString(), actual.toString()); - } - } - @Test public void testGenerateCloneVisitor() throws Exception { //use always LINUX line separator, because generated files are committed to Spoon repository which expects that. @@ -124,6 +92,7 @@ public void testGenerateCloneVisitor() throws Exception { launcher.getEnvironment().setNoClasspath(true); launcher.getEnvironment().setCommentEnabled(true); launcher.getEnvironment().useTabulations(true); + //launcher.getEnvironment().setAutoImports(true); launcher.setSourceOutputDirectory("./target/generated/"); // interfaces. launcher.addInputResource("./src/main/java/spoon/reflect/code"); @@ -145,7 +114,7 @@ public void testGenerateCloneVisitor() throws Exception { // cp ./target/generated/spoon/support/visitor/clone/CloneBuilder.java ./src/main/java/spoon/support/visitor/clone/CloneBuilder.java // cp ./target/generated/spoon/support/visitor/clone/CloneVisitor.java ./src/main/java/spoon/support/visitor/clone/CloneVisitor.java - CtElement expected = build(new File("./target/generated/spoon/support/visitor/clone/")).Package().get("spoon.support.visitor.clone"); + CtElement expected = build(new File(launcher.getModelBuilder().getSourceOutputDirectory()+"/spoon/support/visitor/clone/")).Package().get("spoon.support.visitor.clone"); CtElement actual = build(new File("./src/main/java/spoon/support/visitor/clone/")).Package().get("spoon.support.visitor.clone"); try { assertThat(actual) diff --git a/src/test/java/spoon/test/architecture/SpoonArchitectureEnforcer.java b/src/test/java/spoon/test/architecture/SpoonArchitectureEnforcer.java index 60b547b04a5..e27d06e4a70 100644 --- a/src/test/java/spoon/test/architecture/SpoonArchitectureEnforcer.java +++ b/src/test/java/spoon/test/architecture/SpoonArchitectureEnforcer.java @@ -76,10 +76,11 @@ public void metamodelPackageRule() throws Exception { interfaces.addInputResource("src/main/java/spoon/support/DefaultCoreFactory.java"); interfaces.buildModel(); - for (CtType t : implementations.getModel().getAllTypes()) { - String impl = t.getQualifiedName().replace(".support", "").replace("Impl", ""); - CtType itf = interfaces.getFactory().Type().get(impl); - assertTrue(itf.isSubtypeOf(t.getReference())); + for (CtType implType : implementations.getModel().getAllTypes()) { + String impl = implType.getQualifiedName().replace(".support", "").replace("Impl", ""); + CtType interfaceType = interfaces.getFactory().Type().get(impl); + // the implementation is a subtype of the superinterface + assertTrue(implType.getReference().isSubtypeOf(interfaceType.getReference())); } } } diff --git a/src/test/java/spoon/test/comparison/EqualTest.java b/src/test/java/spoon/test/comparison/EqualTest.java index e5510c35007..49a8a5a293e 100644 --- a/src/test/java/spoon/test/comparison/EqualTest.java +++ b/src/test/java/spoon/test/comparison/EqualTest.java @@ -3,15 +3,20 @@ import org.junit.Test; import spoon.Launcher; import spoon.compiler.SpoonCompiler; +import spoon.reflect.code.CtComment; import spoon.reflect.code.CtInvocation; import spoon.reflect.code.CtLiteral; +import spoon.reflect.code.CtLocalVariable; import spoon.reflect.code.CtReturn; +import spoon.reflect.code.CtTry; import spoon.reflect.declaration.CtClass; import spoon.reflect.declaration.CtMethod; import spoon.reflect.factory.Factory; import spoon.support.compiler.jdt.JDTSnippetCompiler; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; public class EqualTest { @@ -61,5 +66,25 @@ public void testEqualsEmptyException() throws Exception { } + @Test + public void testEqualsComment() throws Exception { + Factory factory = new Launcher().createFactory(); + CtLocalVariable var = factory.Code().createCodeSnippetStatement("int i=0").compile(); + CtLocalVariable var2 = var.clone(); + var2.addComment(factory.Code().createComment("foo", CtComment.CommentType.INLINE)); + assertNotEquals(1, var.getComments().size()); + assertNotEquals(var2, var); + } + @Test + public void testEqualsMultitype() throws Exception { + Factory factory = new Launcher().createFactory(); + CtTry var = factory.Code().createCodeSnippetStatement("try{}catch(RuntimeException | AssertionError e){}").compile(); + CtTry var2 = var.clone(); + assertEquals(2, var2.getCatchers().get(0).getParameter().getMultiTypes().size()); + // removing a multitype + var2.getCatchers().get(0).getParameter().getMultiTypes().remove(0); + assertEquals(1, var2.getCatchers().get(0).getParameter().getMultiTypes().size()); + assertNotEquals(var2, var); + } } diff --git a/src/test/java/spoon/test/reference/VariableAccessTest.java b/src/test/java/spoon/test/reference/VariableAccessTest.java index 8ce19ed8b1a..aa43b4658a5 100644 --- a/src/test/java/spoon/test/reference/VariableAccessTest.java +++ b/src/test/java/spoon/test/reference/VariableAccessTest.java @@ -105,7 +105,7 @@ public boolean matches(CtExecutable exec) { exec.getBody().getElements(new TypeFilter>(CtParameterReference.class) { @Override public boolean matches(CtParameterReference p) { - assertEquals(p, param); + assertEquals(p.getSimpleName(), param.getSimpleName()); return super.matches(p); } });