diff --git a/src/main/java/spoon/SpoonModelBuilder.java b/src/main/java/spoon/SpoonModelBuilder.java
index 42c635883cb..4d4808c1367 100644
--- a/src/main/java/spoon/SpoonModelBuilder.java
+++ b/src/main/java/spoon/SpoonModelBuilder.java
@@ -285,22 +285,6 @@ interface InputType {
*/
void forceBuild(SpoonResource source);
- /**
- * Sets the encoding to use when different from the system encoding.
- * @deprecated encoding is directly used from Environment
- */
- @Deprecated
- void setEncoding(String encoding);
-
- /**
- * Gets the encoding used by this compiler. Null means that it uses the
- * system encoding.
- *
- * @deprecated encoding is directly used from Environment
- */
- @Deprecated
- String getEncoding();
-
/**
* Returns the working factory
*/
diff --git a/src/main/java/spoon/reflect/visitor/filter/NameFilter.java b/src/main/java/spoon/legacy/NameFilter.java
similarity index 95%
rename from src/main/java/spoon/reflect/visitor/filter/NameFilter.java
rename to src/main/java/spoon/legacy/NameFilter.java
index 6ec1b4a479d..a27d89ebe0a 100644
--- a/src/main/java/spoon/reflect/visitor/filter/NameFilter.java
+++ b/src/main/java/spoon/legacy/NameFilter.java
@@ -14,10 +14,11 @@
* 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.reflect.visitor.filter;
+package spoon.legacy;
import spoon.reflect.declaration.CtNamedElement;
import spoon.reflect.visitor.Filter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
/**
diff --git a/src/main/java/spoon/legacy/package.html b/src/main/java/spoon/legacy/package.html
new file mode 100644
index 00000000000..f0da6f6a085
--- /dev/null
+++ b/src/main/java/spoon/legacy/package.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+ This package contains legacy code of Spoon. This code is kept for sake of maximum compatibility but no support is provided anymore.
+
+Related Documentation
+
+
+
+
+
+
+
diff --git a/src/main/java/spoon/reflect/visitor/DefaultJavaPrettyPrinter.java b/src/main/java/spoon/reflect/visitor/DefaultJavaPrettyPrinter.java
index 5eff88bd297..6265fc90c31 100644
--- a/src/main/java/spoon/reflect/visitor/DefaultJavaPrettyPrinter.java
+++ b/src/main/java/spoon/reflect/visitor/DefaultJavaPrettyPrinter.java
@@ -1820,12 +1820,6 @@ public void visitCtUnboundVariableReference(CtUnboundVariableReference re
printer.write(reference.getSimpleName());
}
- @Override
- @Deprecated
- public String getPackageDeclaration() {
- return printPackageInfo(context.currentTopLevel.getPackage());
- }
-
@Override
public String printPackageInfo(CtPackage pack) {
reset();
@@ -1843,8 +1837,7 @@ public String getResult() {
return printer.toString();
}
- @Override
- public void reset() {
+ private void reset() {
printer.reset();
context = new PrintingContext();
if (env.isAutoImports()) {
diff --git a/src/main/java/spoon/reflect/visitor/PrettyPrinter.java b/src/main/java/spoon/reflect/visitor/PrettyPrinter.java
index d8d9b822927..59fe0736bf4 100644
--- a/src/main/java/spoon/reflect/visitor/PrettyPrinter.java
+++ b/src/main/java/spoon/reflect/visitor/PrettyPrinter.java
@@ -28,12 +28,6 @@
*/
public interface PrettyPrinter {
- /**
- * Gets the package declaration contents.
- */
- @Deprecated
- String getPackageDeclaration();
-
/**
* Prints the package info.
* It always resets the printing context at the beginning of this process.
@@ -45,14 +39,6 @@ public interface PrettyPrinter {
*/
String getResult();
- /**
- * It does not have to be called by clients now.
- * The printing buffer is reset automatically at the beginning of #printPackageInfo or #calculate call
- * So this method can be removed from the API, but should be kept in internal implementation and inherited PrettyPrinters
- */
- @Deprecated
- void reset();
-
/**
* Calculates the resulting source file for a list of types. The source
* compilation unit is required for calculating the line numbers mapping.
diff --git a/src/main/java/spoon/reflect/visitor/filter/PotentialVariableDeclarationFunction.java b/src/main/java/spoon/reflect/visitor/filter/PotentialVariableDeclarationFunction.java
index c59786ce587..f227218b760 100644
--- a/src/main/java/spoon/reflect/visitor/filter/PotentialVariableDeclarationFunction.java
+++ b/src/main/java/spoon/reflect/visitor/filter/PotentialVariableDeclarationFunction.java
@@ -26,6 +26,7 @@
import spoon.reflect.declaration.CtElement;
import spoon.reflect.declaration.CtExecutable;
import spoon.reflect.declaration.CtField;
+import spoon.reflect.declaration.CtNamedElement;
import spoon.reflect.declaration.CtPackage;
import spoon.reflect.declaration.CtParameter;
import spoon.reflect.declaration.CtType;
@@ -93,7 +94,7 @@ public void apply(CtElement input, CtConsumer outputConsumer) {
.select(new TypeFilter<>(CtVariable.class));
if (variableName != null) {
//variable name is defined so we have to search only for variables with that name
- siblingsQuery = siblingsQuery.select(new NameFilter<>(variableName));
+ siblingsQuery = siblingsQuery.select(new NamedElementFilter<>(CtNamedElement.class, variableName));
}
CtElement scopeElement = input;
diff --git a/src/main/java/spoon/support/compiler/jdt/FileCompilerConfig.java b/src/main/java/spoon/support/compiler/jdt/FileCompilerConfig.java
index b55977328e1..36a07969b06 100644
--- a/src/main/java/spoon/support/compiler/jdt/FileCompilerConfig.java
+++ b/src/main/java/spoon/support/compiler/jdt/FileCompilerConfig.java
@@ -23,7 +23,6 @@
import spoon.SpoonException;
import spoon.SpoonModelBuilder;
import spoon.compiler.SpoonFile;
-import spoon.compiler.SpoonFolder;
import org.apache.commons.io.IOUtils;
import org.eclipse.jdt.internal.compiler.batch.CompilationUnit;
@@ -50,14 +49,6 @@ public FileCompilerConfig(List files) {
this.files = files;
}
- /*
- * This method is not used now, so let's get rid of it.
- */
- @Deprecated
- public FileCompilerConfig(SpoonFolder folder) {
- this(folder.getAllJavaFiles());
- }
-
@Override
public void initializeCompiler(JDTBatchCompiler compiler) {
JDTBasedSpoonCompiler jdtCompiler = compiler.getJdtCompiler();
@@ -73,7 +64,7 @@ public void initializeCompiler(JDTBatchCompiler compiler) {
String fName = f.isActualFile() ? f.getPath() : f.getName();
inputStream = f.getContent();
- char[] content = IOUtils.toCharArray(inputStream, jdtCompiler.getEncoding());
+ char[] content = IOUtils.toCharArray(inputStream, jdtCompiler.getEnvironment().getEncoding());
cuList.add(new CompilationUnit(content, fName, null));
IOUtils.closeQuietly(inputStream);
}
diff --git a/src/main/java/spoon/support/compiler/jdt/JDTBasedSpoonCompiler.java b/src/main/java/spoon/support/compiler/jdt/JDTBasedSpoonCompiler.java
index 1402f3f0b32..ee4667d5772 100644
--- a/src/main/java/spoon/support/compiler/jdt/JDTBasedSpoonCompiler.java
+++ b/src/main/java/spoon/support/compiler/jdt/JDTBasedSpoonCompiler.java
@@ -88,18 +88,11 @@ public class JDTBasedSpoonCompiler implements spoon.SpoonModelBuilder {
protected List forceBuildList = new ArrayList<>();
protected List compilationUnitFilters = new ArrayList<>();
- /**
- * @deprecated The encoding of Environment should be used instead
- */
- @Deprecated
- protected String encoding;
-
/**
* Default constructor
*/
public JDTBasedSpoonCompiler(Factory factory) {
this.factory = factory;
- this.encoding = factory.getEnvironment().getEncoding().displayName();
}
@Override
@@ -150,7 +143,7 @@ public boolean compile(InputType... types) {
final String[] args = new JDTBuilderImpl() //
- .classpathOptions(new ClasspathOptions().encoding(this.getEncoding()).classpath(getSourceClasspath()).binaries(getBinaryOutputDirectory())) //
+ .classpathOptions(new ClasspathOptions().encoding(this.getEnvironment().getEncoding().displayName()).classpath(getSourceClasspath()).binaries(getBinaryOutputDirectory())) //
.complianceOptions(new ComplianceOptions().compliance(javaCompliance)) //
.annotationProcessingOptions(new AnnotationProcessingOptions().compileProcessors()) //
.advancedOptions(new AdvancedOptions().preserveUnusedVars().continueExecution().enableJavadoc()) //
@@ -334,16 +327,6 @@ public void forceBuild(SpoonResource source) {
forceBuildList.add(source);
}
- @Override
- public String getEncoding() {
- return this.encoding;
- }
-
- @Override
- public void setEncoding(String encoding) {
- this.encoding = encoding;
- }
-
@Override
public Factory getFactory() {
return factory;
@@ -395,7 +378,7 @@ protected CompilationUnitDeclaration[] buildUnits(JDTBuilder jdtBuilder, SpoonFo
String[] args;
if (jdtBuilder == null) {
args = new JDTBuilderImpl() //
- .classpathOptions(new ClasspathOptions().encoding(this.getEncoding()).classpath(classpath)) //
+ .classpathOptions(new ClasspathOptions().encoding(this.getEnvironment().getEncoding().displayName()).classpath(classpath)) //
.complianceOptions(new ComplianceOptions().compliance(javaCompliance)) //
.advancedOptions(new AdvancedOptions().preserveUnusedVars().continueExecution().enableJavadoc()) //
.sources(new SourceOptions().sources(sourceFiles)) // no sources, handled by the JDTBatchCompiler
diff --git a/src/main/java/spoon/support/compiler/jdt/JDTImportBuilder.java b/src/main/java/spoon/support/compiler/jdt/JDTImportBuilder.java
index 609009b6cff..e75789db47a 100644
--- a/src/main/java/spoon/support/compiler/jdt/JDTImportBuilder.java
+++ b/src/main/java/spoon/support/compiler/jdt/JDTImportBuilder.java
@@ -29,7 +29,7 @@
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtFieldReference;
import spoon.reflect.reference.CtReference;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import java.util.Collection;
import java.util.HashSet;
@@ -115,7 +115,7 @@ public void build() {
}
}
} else {
- List methodOrFields = klass.getElements(new NameFilter<>(methodOrFieldName));
+ List methodOrFields = klass.getElements(new NamedElementFilter<>(CtNamedElement.class, methodOrFieldName));
if (methodOrFields.size() > 0) {
this.imports.add(methodOrFields.get(0).getReference());
diff --git a/src/main/java/spoon/support/reflect/declaration/CtTypeImpl.java b/src/main/java/spoon/support/reflect/declaration/CtTypeImpl.java
index 0725be185b7..994f0003a7c 100644
--- a/src/main/java/spoon/support/reflect/declaration/CtTypeImpl.java
+++ b/src/main/java/spoon/support/reflect/declaration/CtTypeImpl.java
@@ -46,7 +46,7 @@
import spoon.reflect.visitor.Query;
import spoon.reflect.visitor.chain.CtConsumer;
import spoon.reflect.visitor.filter.AllTypeMembersFunction;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.ReferenceTypeFilter;
import spoon.support.UnsettableProperty;
import spoon.support.comparator.CtLineElementComparator;
@@ -235,7 +235,7 @@ public CtFieldReference> getDeclaredField(String name) {
@Override
public CtFieldReference> getDeclaredOrInheritedField(String fieldName) {
- CtField> field = map(new AllTypeMembersFunction(CtField.class)).select(new NameFilter<>(fieldName)).first();
+ CtField> field = map(new AllTypeMembersFunction(CtField.class)).select(new NamedElementFilter<>(CtField.class, fieldName)).first();
return field == null ? null : field.getReference();
}
diff --git a/src/main/java/spoon/support/reflect/reference/CtExecutableReferenceImpl.java b/src/main/java/spoon/support/reflect/reference/CtExecutableReferenceImpl.java
index 12ad83e5104..6425a8f31b9 100644
--- a/src/main/java/spoon/support/reflect/reference/CtExecutableReferenceImpl.java
+++ b/src/main/java/spoon/support/reflect/reference/CtExecutableReferenceImpl.java
@@ -29,7 +29,7 @@
import spoon.reflect.reference.CtExecutableReference;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.visitor.CtVisitor;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.support.reflect.declaration.CtElementImpl;
import spoon.support.util.RtHelper;
import spoon.support.visitor.ClassTypingContext;
@@ -173,7 +173,7 @@ private CtExecutable getCtExecutable(CtType> typeDecl) {
Launcher.LOGGER.error(e.getMessage(), e);
}
} else if (method == null && getSimpleName().startsWith(CtExecutableReference.LAMBDA_NAME_PREFIX)) {
- final List> elements = (List>) typeDecl.getElements(new NameFilter>(getSimpleName()));
+ final List elements = (List) typeDecl.getElements(new NamedElementFilter<>(CtLambda.class, getSimpleName()));
if (elements.size() == 0) {
return null;
}
diff --git a/src/test/java/spoon/LauncherTest.java b/src/test/java/spoon/LauncherTest.java
index 3c387929b45..bf0d3156b2c 100644
--- a/src/test/java/spoon/LauncherTest.java
+++ b/src/test/java/spoon/LauncherTest.java
@@ -40,7 +40,7 @@ public void testInitEnvironmentDefault() throws Exception {
final SpoonModelBuilder builder = launcher.getModelBuilder();
assertEquals(new File("spooned"), builder.getSourceOutputDirectory());
assertEquals(0, builder.getInputSources().size());
- assertEquals("UTF-8", builder.getEncoding());
+ assertEquals("UTF-8", environment.getEncoding().displayName());
}
@Test
@@ -67,7 +67,7 @@ public void testInitEnvironment() throws Exception {
// the input directories
List inputSources = new ArrayList<>(builder.getInputSources());
assertTrue(inputSources.get(0).getPath().replace('\\', '/').contains("src/main/java"));
- assertEquals("UTF-16", builder.getEncoding());
+ assertEquals("UTF-16", environment.getEncoding().displayName());
}
diff --git a/src/test/java/spoon/test/annotation/AnnotationTest.java b/src/test/java/spoon/test/annotation/AnnotationTest.java
index 08fcbf00c92..2920f91893c 100644
--- a/src/test/java/spoon/test/annotation/AnnotationTest.java
+++ b/src/test/java/spoon/test/annotation/AnnotationTest.java
@@ -36,9 +36,8 @@
import spoon.reflect.declaration.CtTypeParameter;
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtTypeReference;
-import spoon.reflect.visitor.DefaultJavaPrettyPrinter;
import spoon.reflect.visitor.filter.AbstractFilter;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.QueueProcessingManager;
import spoon.test.annotation.testclasses.AnnotArray;
@@ -158,7 +157,7 @@ public void testPersistenceProperty() throws Exception {
public void testAnnotationParameterTypes() throws Exception {
CtType> type = this.factory.Type().get("spoon.test.annotation.testclasses.Main");
- CtMethod> m1 = type.getElements(new NameFilter>("m1")).get(0);
+ CtMethod> m1 = type.getElements(new NamedElementFilter<>(CtMethod.class, "m1")).get(0);
List> annotations = m1.getAnnotations();
assertEquals(1, annotations.size());
@@ -186,7 +185,7 @@ public void testAnnotationParameterTypes() throws Exception {
assertEquals(AnnotParamTypeEnum.G, annot.e());
assertEquals("dd", annot.ia().value());
- CtMethod> m2 = type.getElements(new NameFilter>("m2")).get(0);
+ CtMethod> m2 = type.getElements(new NamedElementFilter<>(CtMethod.class, "m2")).get(0);
annotations = m2.getAnnotations();
assertEquals(1, annotations.size());
@@ -210,7 +209,7 @@ public void testAnnotationParameterTypes() throws Exception {
assertEquals("dd", annot.ia().value());
// tests binary expressions
- CtMethod> m3 = type.getElements(new NameFilter>("m3")).get(0);
+ CtMethod> m3 = type.getElements(new NamedElementFilter<>(CtMethod.class,"m3")).get(0);
annotations = m3.getAnnotations();
assertEquals(1, annotations.size());
@@ -512,7 +511,7 @@ public boolean matches(CtLocalVariable> element) {
public void testUsageOfTypeAnnotationInExtendsImplementsOfAClass() throws Exception {
final CtClass> ctClass = (CtClass>) this.factory.Type().get("spoon.test.annotation.testclasses.AnnotationsAppliedOnAnyTypeInAClass");
- final CtClass> innerClass = ctClass.getElements(new NameFilter>("DummyClass")).get(0);
+ final CtClass> innerClass = ctClass.getElements(new NamedElementFilter<>(CtClass.class,"DummyClass")).get(0);
final CtTypeReference> extendsActual = innerClass.getSuperclass();
final List> extendsTypeAnnotations = extendsActual.getAnnotations();
final String superClassExpected = "spoon.test.annotation.testclasses.@spoon.test.annotation.testclasses.TypeAnnotation" + System.lineSeparator() + "AnnotArrayInnerClass";
@@ -530,7 +529,7 @@ public void testUsageOfTypeAnnotationInExtendsImplementsOfAClass() throws Except
assertEquals(CtAnnotatedElementType.TYPE_USE, implementsTypeAnnotations.get(0).getAnnotatedElementType());
assertEquals("Extends with an type annotation must be well printed", superInterfaceExpected, firstSuperInterface.toString());
- final CtEnum> enumActual = ctClass.getElements(new NameFilter>("DummyEnum")).get(0);
+ final CtEnum> enumActual = ctClass.getElements(new NamedElementFilter<>(CtEnum.class,"DummyEnum")).get(0);
final Set> superInterfacesOfEnum = enumActual.getSuperInterfaces();
final CtTypeReference> firstSuperInterfaceOfEnum = superInterfacesOfEnum.toArray(new CtTypeReference>[0])[0];
final List> enumTypeAnnotations = firstSuperInterfaceOfEnum.getAnnotations();
@@ -540,7 +539,7 @@ public void testUsageOfTypeAnnotationInExtendsImplementsOfAClass() throws Except
assertEquals(CtAnnotatedElementType.TYPE_USE, enumTypeAnnotations.get(0).getAnnotatedElementType());
assertEquals("Implements in a enum with an type annotation must be well printed", enumExpected, enumActual.toString());
- final CtInterface> interfaceActual = ctClass.getElements(new NameFilter>("DummyInterface")).get(0);
+ final CtInterface> interfaceActual = ctClass.getElements(new NamedElementFilter<>(CtInterface.class,"DummyInterface")).get(0);
final Set> superInterfacesOfInterface = interfaceActual.getSuperInterfaces();
final CtTypeReference> firstSuperInterfaceOfInterface = superInterfacesOfInterface.toArray(new CtTypeReference>[0])[0];
final List> interfaceTypeAnnotations = firstSuperInterfaceOfInterface.getAnnotations();
@@ -555,7 +554,7 @@ public void testUsageOfTypeAnnotationInExtendsImplementsOfAClass() throws Except
public void testUsageOfTypeAnnotationWithGenericTypesInClassDeclaration() throws Exception {
final CtClass> ctClass = (CtClass>) this.factory.Type().get("spoon.test.annotation.testclasses.AnnotationsAppliedOnAnyTypeInAClass");
- final CtClass> genericClass = ctClass.getElements(new NameFilter>("DummyGenericClass")).get(0);
+ final CtClass> genericClass = ctClass.getElements(new NamedElementFilter<>(CtClass.class,"DummyGenericClass")).get(0);
// New type parameter declaration.
final List typeParameters = genericClass.getFormalCtTypeParameters();
@@ -931,7 +930,7 @@ public void testSpoonSpoonResult() throws Exception {
//spoon2.addInputResource("./src/test/java/spoon/test/annotation/testclasses/PortRange.java");
spoon2.buildModel();
- List> methods = spoon2.getModel().getElements(new NameFilter>("getPort"));
+ List> methods = spoon2.getModel().getElements(new NamedElementFilter(CtMethod.class, "getPort"));
assertEquals("Number of method getPort should be 1", 1, methods.size());
@@ -958,7 +957,7 @@ public void testGetAnnotationFromParameter() {
factory = spoon.getFactory();
spoon.buildModel();
- List methods = factory.getModel().getElements(new NameFilter("setField"));
+ List methods = factory.getModel().getElements(new NamedElementFilter<>(CtMethod.class, "setField"));
assertThat(methods.size(), is(1));
CtMethod methodSet = methods.get(0);
@@ -994,7 +993,7 @@ public void annotationAddValue() {
factory = spoon.getFactory();
- List methods = factory.getModel().getElements(new NameFilter("bidule"));
+ List methods = factory.getModel().getElements(new NamedElementFilter(CtMethod.class, "bidule"));
assertThat(methods.size(), is(1));
@@ -1036,7 +1035,7 @@ public void testCreateAnnotation() throws Exception {
public void testReplaceAnnotationValue() throws Exception {
CtType> type = this.factory.Type().get("spoon.test.annotation.testclasses.Main");
- CtMethod> m1 = type.getElements(new NameFilter>("m1")).get(0);
+ CtMethod> m1 = type.getElements(new NamedElementFilter<>(CtMethod.class,"m1")).get(0);
List> annotations = m1.getAnnotations();
assertEquals(1, annotations.size());
diff --git a/src/test/java/spoon/test/casts/CastTest.java b/src/test/java/spoon/test/casts/CastTest.java
index 047c7d74d9b..515f8b4a59d 100644
--- a/src/test/java/spoon/test/casts/CastTest.java
+++ b/src/test/java/spoon/test/casts/CastTest.java
@@ -10,7 +10,7 @@
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.visitor.Query;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.testing.utils.ModelUtils;
@@ -62,7 +62,7 @@ public void testCast3() {
+ "public void foo() {" + " Class> x = null;"
+ " addConsumedAnnotationType((Class) x);"
+ "}" + "};").compile();
- CtMethod> foo = clazz.getElements(new NameFilter>("foo"))
+ CtMethod> foo = clazz.getElements(new NamedElementFilter<>(CtMethod.class,"foo"))
.get(0);
CtVariableRead> a = (CtVariableRead>) clazz.getElements(
new TypeFilter<>(CtVariableRead.class)).get(0);
diff --git a/src/test/java/spoon/test/control/ControlTest.java b/src/test/java/spoon/test/control/ControlTest.java
index 84f6598ecb6..9cfb10251d8 100644
--- a/src/test/java/spoon/test/control/ControlTest.java
+++ b/src/test/java/spoon/test/control/ControlTest.java
@@ -7,7 +7,7 @@
import spoon.reflect.code.CtStatement;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.declaration.CtType;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import java.util.List;
@@ -29,14 +29,14 @@ public void testModelBuildingFor() throws Exception {
assertEquals(4, fors.size());
CtMethod> normalFor = type.getElements(
- new NameFilter>("normalFor")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"normalFor")).get(0);
CtFor firstFor = (CtFor) normalFor.getBody().getStatements().get(0);
assertEquals("int i = 0", firstFor.getForInit().get(0).toString());
assertEquals("i < 2", firstFor.getExpression().toString());
assertEquals("i++", firstFor.getForUpdate().get(0).toString());
CtMethod> empty1 = type.getElements(
- new NameFilter>("empty1")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"empty1")).get(0);
CtFor empty1For = (CtFor) empty1.getBody().getStatements().get(1);
assertEquals("i = 0", empty1For.getForInit().get(0).toString());
// TODO: is it good to return null??
@@ -53,7 +53,7 @@ public void testModelBuildingDoWhile() throws Exception {
CtType> type = build("spoon.test.control", "DoWhile");
assertEquals("DoWhile", type.getSimpleName());
CtMethod> meth = type.getElements(
- new NameFilter>("methode")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"methode")).get(0);
List stmts = meth.getBody().getStatements();
assertEquals(2, stmts.size());
assertTrue(stmts.get(1) instanceof CtDo);
diff --git a/src/test/java/spoon/test/ctBlock/TestCtBlock.java b/src/test/java/spoon/test/ctBlock/TestCtBlock.java
index c6fe2b582ef..a3c37ea13a2 100644
--- a/src/test/java/spoon/test/ctBlock/TestCtBlock.java
+++ b/src/test/java/spoon/test/ctBlock/TestCtBlock.java
@@ -9,7 +9,7 @@
import spoon.reflect.code.CtSwitch;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtMethod;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.test.ctBlock.testclasses.Toto;
import java.util.List;
@@ -28,7 +28,7 @@ public void testRemoveStatement() {
spoon.addInputResource("./src/test/java/spoon/test/ctBlock/testclasses/Toto.java");
spoon.buildModel();
- List methods = spoon.getModel().getElements(new NameFilter("foo"));
+ List methods = spoon.getModel().getElements(new NamedElementFilter<>(CtMethod.class,"foo"));
assertEquals(1, methods.size());
diff --git a/src/test/java/spoon/test/ctType/CtTypeParameterTest.java b/src/test/java/spoon/test/ctType/CtTypeParameterTest.java
index b6fed2a7086..9df70d84bdb 100644
--- a/src/test/java/spoon/test/ctType/CtTypeParameterTest.java
+++ b/src/test/java/spoon/test/ctType/CtTypeParameterTest.java
@@ -17,7 +17,7 @@
import spoon.reflect.declaration.CtTypeMember;
import spoon.reflect.declaration.CtTypeParameter;
import spoon.reflect.reference.CtTypeReference;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.test.ctType.testclasses.ErasureModelA;
import spoon.testing.utils.ModelUtils;
@@ -69,7 +69,7 @@ private void checkTypeParamErasureOfType(CtTypeParameter typeParam, Class> cla
private void checkTypeParamErasureOfExecutable(CtTypeParameter typeParam) throws NoSuchFieldException, SecurityException {
CtExecutable> exec = (CtExecutable>) typeParam.getParent();
- CtParameter> param = exec.filterChildren(new NameFilter<>("param"+typeParam.getSimpleName())).first();
+ CtParameter> param = exec.filterChildren(new NamedElementFilter<>(CtParameter.class,"param"+typeParam.getSimpleName())).first();
assertNotNull("Missing param"+typeParam.getSimpleName() + " in "+ exec.getSignature(), param);
int paramIdx = exec.getParameters().indexOf(param);
Class declClass = exec.getParent(CtType.class).getActualClass();
@@ -140,7 +140,7 @@ public void testTypeSame() throws Exception {
CtMethod> ctModelMethod = ctModel.getMethodsByName("method").get(0);
CtMethod> ctModelMethod2 = ctModel.getMethodsByName("method2").get(0);
- CtClass> ctModelB = ctModel.filterChildren(new NameFilter<>("ModelB")).first();
+ CtClass> ctModelB = ctModel.filterChildren(new NamedElementFilter<>(CtClass.class,"ModelB")).first();
CtTypeParameter tpA2 = ctModelB.getFormalCtTypeParameters().get(0);
CtTypeParameter tpB2 = ctModelB.getFormalCtTypeParameters().get(1);
CtTypeParameter tpC2 = ctModelB.getFormalCtTypeParameters().get(2);
@@ -164,7 +164,7 @@ public void testTypeSame() throws Exception {
//https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.4.4
checkIsSame(ctModelMethod.getFormalCtTypeParameters(), ctModelMethod2.getFormalCtTypeParameters(), true);
- CtClass> ctModelC = ctModel.filterChildren(new NameFilter<>("ModelC")).first();
+ CtClass> ctModelC = ctModel.filterChildren(new NamedElementFilter<>(CtClass.class,"ModelC")).first();
}
/**
diff --git a/src/test/java/spoon/test/ctType/CtTypeTest.java b/src/test/java/spoon/test/ctType/CtTypeTest.java
index ef17d320fd6..0e5054a5d14 100644
--- a/src/test/java/spoon/test/ctType/CtTypeTest.java
+++ b/src/test/java/spoon/test/ctType/CtTypeTest.java
@@ -15,7 +15,7 @@
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtReference;
import spoon.reflect.reference.CtTypeReference;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.test.ctType.testclasses.X;
@@ -115,8 +115,8 @@ public void testIsSubTypeOfonTypeParameters() throws Exception {
CtType> P_D_CtType = pTypeParameters.get(0);
CtType> P_F_CtType = pTypeParameters.get(1);
- CtMethod> O_FooMethod = oCtType.filterChildren(new NameFilter<>("foo")).first();
- CtMethod> P_FooMethod = pCtType.filterChildren(new NameFilter<>("foo")).first();
+ CtMethod> O_FooMethod = oCtType.filterChildren(new NamedElementFilter<>(CtMethod.class,"foo")).first();
+ CtMethod> P_FooMethod = pCtType.filterChildren(new NamedElementFilter<>(CtMethod.class,"foo")).first();
CtType> O_B_CtType = O_FooMethod.getType().getDeclaration();
CtType> P_E_CtType = P_FooMethod.getType().getDeclaration();
@@ -144,7 +144,7 @@ public void testIsSubTypeOfonTypeReferences() throws Exception {
Factory factory = launcher.getFactory();
CtType> oCtType = factory.Class().get("spoon.test.ctType.testclasses.SubtypeModel");
- CtMethod> O_FooMethod = oCtType.filterChildren(new NameFilter<>("foo")).first();
+ CtMethod> O_FooMethod = oCtType.filterChildren(new NamedElementFilter<>(CtMethod.class,"foo")).first();
Map> nameToTypeRef = new HashMap<>();
O_FooMethod.filterChildren(new TypeFilter<>(CtLocalVariable.class)).forEach((CtLocalVariable var)->{
diff --git a/src/test/java/spoon/test/factory/FactoryTest.java b/src/test/java/spoon/test/factory/FactoryTest.java
index 92b2cfb8975..f5754fa40a0 100644
--- a/src/test/java/spoon/test/factory/FactoryTest.java
+++ b/src/test/java/spoon/test/factory/FactoryTest.java
@@ -12,13 +12,13 @@
import spoon.reflect.declaration.CtField;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.declaration.CtPackage;
+import spoon.reflect.declaration.CtParameter;
import spoon.reflect.declaration.CtType;
-import spoon.reflect.declaration.ModifierKind;
import spoon.reflect.factory.CoreFactory;
import spoon.reflect.factory.Factory;
import spoon.reflect.factory.FactoryImpl;
import spoon.reflect.visitor.filter.AbstractFilter;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.support.DefaultCoreFactory;
import spoon.support.StandardEnvironment;
import spoon.support.reflect.declaration.CtMethodImpl;
@@ -129,12 +129,12 @@ public void testCtModel() throws Exception {
assertEquals(5, model.getAllPackages().size());
- CtPackage p = model.getRootPackage().getElements(new NameFilter("spoon")).get(0).clone();
+ CtPackage p = model.getRootPackage().getElements(new NamedElementFilter<>(CtPackage.class,"spoon")).get(0).clone();
// if we change the implem, merge is impossible
CtField f = spoon.getFactory().Core().createField();
f.setSimpleName("foo");
f.setType(spoon.getFactory().Type().BYTE);
- p.getElements(new NameFilter("testclasses")).get(0).getType("Foo").addField(f);
+ p.getElements(new NamedElementFilter<>(CtPackage.class,"testclasses")).get(0).getType("Foo").addField(f);
try {
model.getRootPackage().addPackage(p);
fail("no exception thrown");
diff --git a/src/test/java/spoon/test/fieldaccesses/FieldAccessTest.java b/src/test/java/spoon/test/fieldaccesses/FieldAccessTest.java
index 48b46c30b03..fbe86527222 100644
--- a/src/test/java/spoon/test/fieldaccesses/FieldAccessTest.java
+++ b/src/test/java/spoon/test/fieldaccesses/FieldAccessTest.java
@@ -26,7 +26,7 @@
import spoon.reflect.visitor.CtScanner;
import spoon.reflect.visitor.DefaultJavaPrettyPrinter;
import spoon.reflect.visitor.Query;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.test.fieldaccesses.testclasses.B;
import spoon.test.fieldaccesses.testclasses.Kuu;
@@ -54,9 +54,9 @@ public void testModelBuildingFieldAccesses() throws Exception {
assertEquals("Mouse", type.getSimpleName());
CtMethod> meth1 = type.getElements(
- new NameFilter>("meth1")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"meth1")).get(0);
CtMethod> meth1b = type.getElements(
- new NameFilter>("meth1b")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"meth1b")).get(0);
assertEquals(
3,
@@ -71,7 +71,7 @@ public void testModelBuildingFieldAccesses() throws Exception {
.size());
CtMethod> meth2 = type.getElements(
- new NameFilter>("meth2")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"meth2")).get(0);
assertEquals(
2,
meth2.getElements(
@@ -79,7 +79,7 @@ public void testModelBuildingFieldAccesses() throws Exception {
.size());
CtMethod> meth3 = type.getElements(
- new NameFilter>("meth3")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"meth3")).get(0);
assertEquals(
3,
meth3.getElements(
@@ -87,7 +87,7 @@ public void testModelBuildingFieldAccesses() throws Exception {
.size());
CtMethod> meth4 = type.getElements(
- new NameFilter>("meth4")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"meth4")).get(0);
assertEquals(
1,
meth4.getElements(
diff --git a/src/test/java/spoon/test/filters/FilterTest.java b/src/test/java/spoon/test/filters/FilterTest.java
index 309cd113cc8..624c5cf9570 100644
--- a/src/test/java/spoon/test/filters/FilterTest.java
+++ b/src/test/java/spoon/test/filters/FilterTest.java
@@ -62,7 +62,6 @@
import spoon.reflect.visitor.filter.FilteringOperator;
import spoon.reflect.visitor.filter.InvocationFilter;
import spoon.reflect.visitor.filter.LineFilter;
-import spoon.reflect.visitor.filter.NameFilter;
import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.OverriddenMethodFilter;
import spoon.reflect.visitor.filter.OverriddenMethodQuery;
@@ -156,7 +155,7 @@ public void testFieldAccessFilter() throws Exception {
CtClass> foo = factory.Package().get("spoon.test.filters").getType("Foo");
assertEquals("Foo", foo.getSimpleName());
- List elements = foo.getElements(new NameFilter<>("i"));
+ List elements = foo.getElements(new NamedElementFilter<>(CtNamedElement.class,"i"));
assertEquals(1, elements.size());
CtFieldReference> ref = (CtFieldReference>)(elements.get(0)).getReference();
@@ -244,8 +243,8 @@ public void unionOfTwoFilters() throws Exception {
@Test
public void classCastExceptionIsNotThrown() throws Exception {
Factory factory = build("spoon.test", "SampleClass").getFactory();
- NameFilter> nameFilterA = new NameFilter>("j");
- NameFilter> nameFilterB = new NameFilter>("k");
+ NamedElementFilter nameFilterA = new NamedElementFilter<>(CtVariable.class,"j");
+ NamedElementFilter nameFilterB = new NamedElementFilter<>(CtVariable.class,"k");
CompositeFilter compositeFilter = new CompositeFilter(FilteringOperator.INTERSECTION, nameFilterA, nameFilterB);
List filteredWithCompositeFilter = Query.getElements(factory, compositeFilter);
assertTrue(filteredWithCompositeFilter.isEmpty());
@@ -961,7 +960,7 @@ public void testParentFunction() throws Exception {
launcher.run();
CtClass> cls = launcher.getFactory().Class().get(Tacos.class);
- CtLocalVariable> varStrings = cls.filterChildren(new NameFilter<>("strings")).first();
+ CtLocalVariable> varStrings = cls.filterChildren(new NamedElementFilter<>(CtLocalVariable.class,"strings")).first();
class Context {
CtElement expectedParent;
diff --git a/src/test/java/spoon/test/generics/GenericsTest.java b/src/test/java/spoon/test/generics/GenericsTest.java
index ada8fc6c7f8..1855aa27964 100644
--- a/src/test/java/spoon/test/generics/GenericsTest.java
+++ b/src/test/java/spoon/test/generics/GenericsTest.java
@@ -31,7 +31,7 @@
import spoon.reflect.reference.CtWildcardReference;
import spoon.reflect.visitor.DefaultJavaPrettyPrinter;
import spoon.reflect.visitor.filter.AbstractFilter;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.ReferenceTypeFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.StandardEnvironment;
@@ -63,7 +63,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
@@ -104,7 +103,7 @@ public void testModelBuildingTree() throws Exception {
assertEquals("[java.io.Serializable, java.lang.Comparable]", typeParameter.getSuperclass().asCtIntersectionTypeReference().getBounds().toString());
CtMethod> node5 = type.getElements(
- new NameFilter>("node5")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"node5")).get(0);
assertEquals(
"this.>foo()",
node5.getBody().getStatement(0).toString());
@@ -152,7 +151,7 @@ public void testDiamond1() {
@Test
public void testModelBuildingSimilarSignatureMethods() throws Exception {
CtClass> type = build("spoon.test.generics", "SimilarSignatureMethodes");
- List methods = type.getElements(new NameFilter("methode"));
+ List methods = type.getElements(new NamedElementFilter<>(CtNamedElement.class,"methode"));
assertEquals(2, methods.size());
CtTypeParameter typeParameter = ((CtMethod>) methods.get(0)).getFormalCtTypeParameters().get(0);
assertEquals("E", typeParameter.getSimpleName());
@@ -230,7 +229,7 @@ public void testBugCommonCollection() throws Exception {
CtClass> type = build("spoon.test.generics", "BugCollection");
CtField> INSTANCE = type.getElements(
- new NameFilter>("INSTANCE")).get(0);
+ new NamedElementFilter<>(CtField.class,"INSTANCE")).get(0);
// assertTrue(INSTANCE.getDefaultExpression().getType().getActualTypeArguments().get(0)
// instanceof CtAnnonTypeParameterReference);
assertEquals(
@@ -238,7 +237,7 @@ public void testBugCommonCollection() throws Exception {
INSTANCE.toString());
CtField> INSTANCE2 = type.getElements(
- new NameFilter>("INSTANCE2")).get(0);
+ new NamedElementFilter<>(CtField.class,"INSTANCE2")).get(0);
INSTANCE2.setAnnotations(new ArrayList>());
assertEquals(
"public static final spoon.test.generics.ACLass> INSTANCE2 = new spoon.test.generics.ACLass();",
@@ -247,14 +246,14 @@ public void testBugCommonCollection() throws Exception {
CtClass> ComparableComparator = type
.getPackage()
.getElements(
- new NameFilter>("ComparableComparator"))
+ new NamedElementFilter<>(CtClass.class,"ComparableComparator"))
.get(0);
assertTrue(ComparableComparator
.toString()
.startsWith(
"class ComparableComparator>"));
- CtField> x = type.getElements(new NameFilter>("x"))
+ CtField> x = type.getElements(new NamedElementFilter<>(CtField.class,"x"))
.get(0);
CtTypeReference> ref = x.getType();
DefaultJavaPrettyPrinter pp = new DefaultJavaPrettyPrinter(
@@ -273,11 +272,11 @@ public void testBugCommonCollection() throws Exception {
assertEquals("java.util.Map.Entry", pp.getResult().toString());
- CtField> y = type.getElements(new NameFilter>("y"))
+ CtField> y = type.getElements(new NamedElementFilter<>(CtField.class,"y"))
.get(0);
assertEquals("java.util.Map.Entry, ?> y;", y.toString());
- CtField> z = type.getElements(new NameFilter>("z"))
+ CtField> z = type.getElements(new NamedElementFilter<>(CtField.class,"z"))
.get(0);
assertEquals(
"java.util.Map.Entry z;",
@@ -285,21 +284,21 @@ public void testBugCommonCollection() throws Exception {
// now as local variables
CtLocalVariable> lx = type.getElements(
- new NameFilter>("lx")).get(0);
+ new NamedElementFilter<>(CtLocalVariable.class,"lx")).get(0);
assertEquals("java.util.Map.Entry lx", lx.toString());
CtLocalVariable> ly = type.getElements(
- new NameFilter>("ly")).get(0);
+ new NamedElementFilter<>(CtLocalVariable.class,"ly")).get(0);
assertEquals("java.util.Map.Entry, ?> ly", ly.toString());
CtLocalVariable> lz = type.getElements(
- new NameFilter>("lz")).get(0);
+ new NamedElementFilter<>(CtLocalVariable.class,"lz")).get(0);
assertEquals(
"java.util.Map.Entry lz",
lz.toString());
CtLocalVariable> it = type.getElements(
- new NameFilter>("it")).get(0);
+ new NamedElementFilter<>(CtLocalVariable.class,"it")).get(0);
assertEquals("java.util.Iterator> it",
it.toString());
@@ -659,7 +658,7 @@ public void testGenericTypeReference() throws Exception {
public void testCtTypeReference_getSuperclass() throws Exception {
Factory factory = build(new File("src/test/java/spoon/test/generics/testclasses"));
CtClass> ctClassCelebrationLunch = factory.Class().get(CelebrationLunch.class);
- CtTypeReference> trWeddingLunch_Mole = ctClassCelebrationLunch.filterChildren(new NameFilter<>("disgust")).map((CtTypedElement te)->{
+ CtTypeReference> trWeddingLunch_Mole = ctClassCelebrationLunch.filterChildren(new NamedElementFilter<>(CtNamedElement.class,"disgust")).map((CtTypedElement te)->{
return te.getType();
}).first();
@@ -700,7 +699,7 @@ public void testTypeAdapted() throws Exception {
CtTypeParameter tpC = ctModel.getFormalCtTypeParameters().get(2);
CtTypeParameter tpD = ctModel.getFormalCtTypeParameters().get(3);
- CtClass> ctModelB = ctModel.filterChildren(new NameFilter<>("ModelB")).first();
+ CtClass> ctModelB = ctModel.filterChildren(new NamedElementFilter<>(CtClass.class,"ModelB")).first();
ClassTypingContext sth = new ClassTypingContext(ctModelB);
// in ModelB, "A" is "A2"
assertEquals("A2", sth.adaptType(tpA).getQualifiedName());
@@ -710,7 +709,7 @@ public void testTypeAdapted() throws Exception {
assertEquals("C2", sth.adaptType(tpC).getQualifiedName());
assertEquals("D2", sth.adaptType(tpD).getQualifiedName());
- CtClass> ctModelC = ctModel.filterChildren(new NameFilter<>("ModelC")).first();
+ CtClass> ctModelC = ctModel.filterChildren(new NamedElementFilter<>(CtClass.class,"ModelC")).first();
ClassTypingContext sthC = new ClassTypingContext(ctModelC);
assertEquals("java.lang.Integer", sthC.adaptType(tpA).getQualifiedName());
assertEquals("java.lang.RuntimeException", sthC.adaptType(tpB).getQualifiedName());
@@ -724,7 +723,7 @@ public void testClassTypingContext() throws Exception {
// contract: a ClassTypingContext enables one to perform type resolution of generic types
Factory factory = build(new File("src/test/java/spoon/test/generics/testclasses"));
CtClass> ctClassCelebrationLunch = factory.Class().get(CelebrationLunch.class);
- CtTypeReference> typeReferenceOfDisgust = ctClassCelebrationLunch.filterChildren(new NameFilter<>("disgust")).map((CtTypedElement te)->{
+ CtTypeReference> typeReferenceOfDisgust = ctClassCelebrationLunch.filterChildren(new NamedElementFilter<>(CtNamedElement.class,"disgust")).map((CtTypedElement te)->{
return te.getType();
}).first();
@@ -821,7 +820,7 @@ public void testRecursiveTypeAdapting() throws Exception {
public void testMethodTypingContext() throws Exception {
Factory factory = build(new File("src/test/java/spoon/test/generics/testclasses"));
CtClass> ctClassWeddingLunch = factory.Class().get(WeddingLunch.class);
- CtMethod> trWeddingLunch_eatMe = ctClassWeddingLunch.filterChildren(new NameFilter<>("eatMe")).first();
+ CtMethod> trWeddingLunch_eatMe = ctClassWeddingLunch.filterChildren(new NamedElementFilter<>(CtMethod.class,"eatMe")).first();
MethodTypingContext methodSTH = new MethodTypingContext().setMethod(trWeddingLunch_eatMe);
@@ -829,7 +828,7 @@ public void testMethodTypingContext() throws Exception {
assertSame(trWeddingLunch_eatMe, methodSTH.getAdaptationScope());
CtClass> ctClassLunch = factory.Class().get(Lunch.class);
- CtMethod> trLunch_eatMe = ctClassLunch.filterChildren(new NameFilter<>("eatMe")).first();
+ CtMethod> trLunch_eatMe = ctClassLunch.filterChildren(new NamedElementFilter<>(CtMethod.class,"eatMe")).first();
CtInvocation> invokeReserve = factory.Class().get(CelebrationLunch.class)
.filterChildren(new TypeFilter<>(CtInvocation.class))
@@ -889,7 +888,7 @@ public void testMethodTypingContextAdaptMethod() throws Exception {
CtClass> ctClassLunch = factory.Class().get(Lunch.class);
// represents void eatMe(A paramA, B paramB, C paramC){}
- CtMethod> trLunch_eatMe = ctClassLunch.filterChildren(new NameFilter<>("eatMe")).first();
+ CtMethod> trLunch_eatMe = ctClassLunch.filterChildren(new NamedElementFilter<>(CtMethod.class,"eatMe")).first();
CtClass> ctClassWeddingLunch = factory.Class().get(WeddingLunch.class);
ClassTypingContext ctcWeddingLunch = new ClassTypingContext(ctClassWeddingLunch);
@@ -941,10 +940,10 @@ public void testClassTypingContextMethodSignature() throws Exception {
CtClass> ctClassWeddingLunch = factory.Class().get(WeddingLunch.class);
// represents void eatMe(A paramA, B paramB, C paramC){}
- CtMethod> trLunch_eatMe = ctClassLunch.filterChildren(new NameFilter<>("eatMe")).first();
+ CtMethod> trLunch_eatMe = ctClassLunch.filterChildren(new NamedElementFilter<>(CtMethod.class,"eatMe")).first();
// represents void eatMe(M paramA, K paramB, C paramC)
- CtMethod> trWeddingLunch_eatMe = ctClassWeddingLunch.filterChildren(new NameFilter<>("eatMe")).first();
+ CtMethod> trWeddingLunch_eatMe = ctClassWeddingLunch.filterChildren(new NamedElementFilter<>(CtMethod.class,"eatMe")).first();
ClassTypingContext ctcWeddingLunch = new ClassTypingContext(ctClassWeddingLunch);
@@ -1053,12 +1052,12 @@ public void testGetDeclarationOfTypeParameterReference() {
Factory factory = launcher.getFactory();
- CtClass extendedPaella = factory.getModel().getElements(new NameFilter("ExtendedPaella")).get(0);
+ CtClass extendedPaella = factory.getModel().getElements(new NamedElementFilter<>(CtClass.class,"ExtendedPaella")).get(0);
List typeParameterList = extendedPaella.getFormalCtTypeParameters();
assertEquals(1, typeParameterList.size());
- CtMethod totoMethod = factory.getModel().getElements(new NameFilter("toto")).get(0);
+ CtMethod totoMethod = factory.getModel().getElements(new NamedElementFilter<>(CtMethod.class,"toto")).get(0);
CtTypeReference returnTypeToto = totoMethod.getType();
CtTypeReference paramToto = ((CtParameter)totoMethod.getParameters().get(0)).getType();
@@ -1067,7 +1066,7 @@ public void testGetDeclarationOfTypeParameterReference() {
assertSame(typeParameterList.get(0), declaration);
assertSame(typeParameterList.get(0), paramToto.getDeclaration());
- CtMethod machinMethod = factory.getModel().getElements(new NameFilter("machin")).get(0);
+ CtMethod machinMethod = factory.getModel().getElements(new NamedElementFilter<>(CtMethod.class,"machin")).get(0);
CtTypeReference returnTypeMachin = machinMethod.getType();
List formalCtTypeParameters = machinMethod.getFormalCtTypeParameters();
@@ -1078,12 +1077,12 @@ public void testGetDeclarationOfTypeParameterReference() {
assertNotSame(typeParameterList.get(0), declarationMachin);
assertSame(formalCtTypeParameters.get(0), declarationMachin);
- CtClass innerPaella = factory.getModel().getElements(new NameFilter("InnerPaella")).get(0);
+ CtClass innerPaella = factory.getModel().getElements(new NamedElementFilter<>(CtClass.class,"InnerPaella")).get(0);
List innerTypeParametersList = innerPaella.getFormalCtTypeParameters();
assertEquals(typeParameterList.get(0), innerTypeParametersList.get(0).getSuperclass().getDeclaration());
- CtMethod innerMachinMethod = factory.getModel().getElements(new NameFilter("innerMachin")).get(0);
+ CtMethod innerMachinMethod = factory.getModel().getElements(new NamedElementFilter<>(CtMethod.class,"innerMachin")).get(0);
CtTypeReference returnTypeInnerMachin = innerMachinMethod.getType();
CtTypeReference paramInnerMachinType = ((CtParameter)innerMachinMethod.getParameters().get(0)).getType();
List innerMachinFormalCtType = innerMachinMethod.getFormalCtTypeParameters();
@@ -1091,7 +1090,7 @@ public void testGetDeclarationOfTypeParameterReference() {
assertSame(typeParameterList.get(0), returnTypeInnerMachin.getDeclaration());
assertSame(innerMachinFormalCtType.get(0), paramInnerMachinType.getDeclaration());
- CtMethod innerTotoMethod = factory.getModel().getElements(new NameFilter("innerToto")).get(0);
+ CtMethod innerTotoMethod = factory.getModel().getElements(new NamedElementFilter<>(CtMethod.class,"innerToto")).get(0);
CtTypeReference returnInnerToto = innerTotoMethod.getType();
CtTypeReference paramInnerToto = ((CtParameter)innerTotoMethod.getParameters().get(0)).getType();
List innerTotoFormatCtType = innerTotoMethod.getFormalCtTypeParameters();
diff --git a/src/test/java/spoon/test/imports/ImportScannerTest.java b/src/test/java/spoon/test/imports/ImportScannerTest.java
index d3a56c0b39e..f5540a58aaf 100644
--- a/src/test/java/spoon/test/imports/ImportScannerTest.java
+++ b/src/test/java/spoon/test/imports/ImportScannerTest.java
@@ -4,6 +4,7 @@
import spoon.Launcher;
import spoon.SpoonModelBuilder;
import spoon.compiler.SpoonResourceHelper;
+import spoon.reflect.code.CtLocalVariable;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtType;
import spoon.reflect.factory.Factory;
@@ -13,7 +14,7 @@
import spoon.reflect.visitor.ImportScannerImpl;
import spoon.reflect.visitor.MinimalImportScanner;
import spoon.reflect.visitor.Query;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import java.security.AccessControlException;
import java.util.Collection;
@@ -90,7 +91,7 @@ public void testMultiCatchImport() throws Exception {
compiler.build();
- final List> classes = Query.getElements(factory, new NameFilter>("MultiCatch"));
+ final List classes = Query.getElements(factory, new NamedElementFilter<>(CtClass.class,"MultiCatch"));
ImportScanner importScanner = new ImportScannerImpl();
importScanner.computeImports(classes.get(0));
diff --git a/src/test/java/spoon/test/imports/ImportTest.java b/src/test/java/spoon/test/imports/ImportTest.java
index aa614f62327..ade8fe84e15 100644
--- a/src/test/java/spoon/test/imports/ImportTest.java
+++ b/src/test/java/spoon/test/imports/ImportTest.java
@@ -17,6 +17,7 @@
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtElement;
import spoon.reflect.declaration.CtMethod;
+import spoon.reflect.declaration.CtParameter;
import spoon.reflect.declaration.CtType;
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtExecutableReference;
@@ -29,7 +30,7 @@
import spoon.reflect.visitor.Query;
import spoon.reflect.visitor.chain.CtScannerListener;
import spoon.reflect.visitor.chain.ScanningMode;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.SuperInheritanceHierarchyFunction;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.comparator.CtLineElementComparator;
@@ -85,9 +86,9 @@ public void testImportOfAnInnerClassInASuperClassPackageAutoImport() throws Exce
spoon.setSourceOutputDirectory("./target/spoon/super_imports/src");
spoon.run();
- final List> classes = Query.getElements(spoon.getFactory(), new NameFilter>("ClientClass"));
+ final List classes = Query.getElements(spoon.getFactory(), new NamedElementFilter<>(CtClass.class,"ClientClass"));
- final CtClass> innerClass = classes.get(0).getNestedType("InnerClass");
+ final CtType> innerClass = classes.get(0).getNestedType("InnerClass");
String expected = "spoon.test.imports.testclasses.ClientClass.InnerClass";
assertEquals(expected, innerClass.getReference().toString());
@@ -115,9 +116,9 @@ public void testImportOfAnInnerClassInASuperClassPackageFullQualified() throws E
spoon.setSourceOutputDirectory("./target/spoon/super_imports/src");
spoon.run();
- final List> classes = Query.getElements(spoon.getFactory(), new NameFilter>("ClientClass"));
+ final List classes = Query.getElements(spoon.getFactory(), new NamedElementFilter<>(CtClass.class,"ClientClass"));
- final CtClass> innerClass = classes.get(0).getNestedType("InnerClass");
+ final CtType> innerClass = classes.get(0).getNestedType("InnerClass");
assertEquals("spoon.test.imports.testclasses.ClientClass$InnerClass", innerClass.getQualifiedName());
@@ -220,9 +221,10 @@ public void testAnotherMissingImport() throws Exception {
SpoonModelBuilder compiler = spoon.createCompiler(factory, SpoonResourceHelper.resources("./src/test/resources/import-resources/fr/inria/AnotherMissingImport.java"));
compiler.build();
- List> methods = factory.getModel().getElements(new NameFilter>("doSomething"));
+ List methods = factory.getModel().getElements(new NamedElementFilter<>(CtMethod.class,"doSomething"));
- CtTypeReference> type = methods.get(0).getParameters().get(0).getType();
+ List parameters = methods.get(0).getParameters();
+ CtTypeReference> type = parameters.get(0).getType();
assertEquals("SomeType", type.getSimpleName());
assertEquals("externallib", type.getPackage().getSimpleName());
diff --git a/src/test/java/spoon/test/initializers/InitializerTest.java b/src/test/java/spoon/test/initializers/InitializerTest.java
index 60b8c62d96b..3a29cb194dd 100644
--- a/src/test/java/spoon/test/initializers/InitializerTest.java
+++ b/src/test/java/spoon/test/initializers/InitializerTest.java
@@ -3,11 +3,12 @@
import org.junit.Test;
import spoon.reflect.code.CtConstructorCall;
import spoon.reflect.code.CtLiteral;
+import spoon.reflect.code.CtLocalVariable;
import spoon.reflect.declaration.CtAnonymousExecutable;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtField;
import spoon.reflect.declaration.ModifierKind;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import static org.junit.Assert.assertEquals;
@@ -41,19 +42,19 @@ public void testModelBuildingInitializer() throws Exception {
"InstanceInitializers");
assertEquals("InstanceInitializers", type.getSimpleName());
- CtField> k = type.getElements(new NameFilter>("k")).get(0);
+ CtField> k = type.getElements(new NamedElementFilter<>(CtField.class,"k")).get(0);
assertTrue(k.getDefaultExpression() instanceof CtConstructorCall);
- CtField> l = type.getElements(new NameFilter>("l")).get(0);
+ CtField> l = type.getElements(new NamedElementFilter<>(CtField.class,"l")).get(0);
assertTrue(l.getDefaultExpression() instanceof CtConstructorCall);
- CtField> x = type.getElements(new NameFilter>("x")).get(0);
+ CtField> x = type.getElements(new NamedElementFilter<>(CtField.class,"x")).get(0);
assertTrue(x.getDefaultExpression() == null);
- CtField> y = type.getElements(new NameFilter>("y")).get(0);
+ CtField> y = type.getElements(new NamedElementFilter<>(CtField.class,"y")).get(0);
assertTrue(y.getDefaultExpression() instanceof CtLiteral);
- CtField> z = type.getElements(new NameFilter>("z")).get(0);
+ CtField> z = type.getElements(new NamedElementFilter<>(CtField.class,"z")).get(0);
assertTrue(z.getDefaultExpression().toString().equals("5"));
// static initializer
diff --git a/src/test/java/spoon/test/intercession/insertBefore/InsertMethodsTest.java b/src/test/java/spoon/test/intercession/insertBefore/InsertMethodsTest.java
index 38341b01f95..20c0d91b80e 100644
--- a/src/test/java/spoon/test/intercession/insertBefore/InsertMethodsTest.java
+++ b/src/test/java/spoon/test/intercession/insertBefore/InsertMethodsTest.java
@@ -14,10 +14,11 @@
import spoon.reflect.code.CtWhile;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtElement;
+import spoon.reflect.declaration.CtField;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.factory.Factory;
import spoon.reflect.visitor.Query;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import java.util.List;
@@ -90,7 +91,7 @@ public void testInsertAfter() throws Exception {
@Test
public void testInsertBeforeWithoutBrace() throws Exception {
- CtMethod> ifWithoutBraces_m = insertExampleClass.getElements(new NameFilter>("ifWithoutBraces")).get(0);
+ CtMethod> ifWithoutBraces_m = insertExampleClass.getElements(new NamedElementFilter<>(CtMethod.class,"ifWithoutBraces")).get(0);
// replace the return
CtCodeSnippetStatement s = factory.Code().createCodeSnippetStatement("return 2");
@@ -107,7 +108,7 @@ public void testInsertBeforeWithoutBrace() throws Exception {
@Test
public void testInsertBeforeWithBrace() throws Exception {
- CtMethod> ifWithBraces_m = insertExampleClass.getElements(new NameFilter>("ifWithBraces")).get(0);
+ CtMethod> ifWithBraces_m = insertExampleClass.getElements(new NamedElementFilter<>(CtMethod.class,"ifWithBraces")).get(0);
// replace the return
CtCodeSnippetStatement s = factory.Code().createCodeSnippetStatement("return 2");
@@ -123,7 +124,7 @@ public void testInsertBeforeWithBrace() throws Exception {
@Test
public void testInsertAfterWithoutBrace() throws Exception {
- CtMethod> ifWithoutBraces_m = insertExampleClass.getElements(new NameFilter>("ifWithoutBraces")).get(0);
+ CtMethod> ifWithoutBraces_m = insertExampleClass.getElements(new NamedElementFilter<>(CtMethod.class,"ifWithoutBraces")).get(0);
// replace the return
CtCodeSnippetStatement s = factory.Code().createCodeSnippetStatement("return 2");
@@ -140,7 +141,7 @@ public void testInsertAfterWithoutBrace() throws Exception {
@Test
public void testInsertAfterWithBrace() throws Exception {
- CtMethod> ifWithBraces_m = insertExampleClass.getElements(new NameFilter>("ifWithBraces")).get(0);
+ CtMethod> ifWithBraces_m = insertExampleClass.getElements(new NamedElementFilter<>(CtMethod.class,"ifWithBraces")).get(0);
// replace the return
CtCodeSnippetStatement s = factory.Code().createCodeSnippetStatement("return 2");
@@ -156,7 +157,7 @@ public void testInsertAfterWithBrace() throws Exception {
@Test
public void testInsertBeforeSwitchCase() throws Exception {
- CtMethod> sm = insertExampleClass.getElements(new NameFilter>("switchMethod")).get(0);
+ CtMethod> sm = insertExampleClass.getElements(new NamedElementFilter<>(CtMethod.class,"switchMethod")).get(0);
// Adds a new snippet in a case.
CtSwitch> sw = sm.getElements(new TypeFilter>(CtSwitch.class)).get(0);
@@ -192,7 +193,7 @@ public void testInsertBeforeSwitchCase() throws Exception {
@Test
public void testInsertAfterSwitchCase() throws Exception {
- CtMethod> sm = insertExampleClass.getElements(new NameFilter>("switchMethod")).get(0);
+ CtMethod> sm = insertExampleClass.getElements(new NamedElementFilter<>(CtMethod.class,"switchMethod")).get(0);
// Adds a new snippet in a case.
CtSwitch> sw = sm.getElements(new TypeFilter>(CtSwitch.class)).get(0);
diff --git a/src/test/java/spoon/test/labels/TestLabels.java b/src/test/java/spoon/test/labels/TestLabels.java
index a7388fbc01b..a19d3ea22b9 100644
--- a/src/test/java/spoon/test/labels/TestLabels.java
+++ b/src/test/java/spoon/test/labels/TestLabels.java
@@ -12,8 +12,9 @@
import spoon.reflect.code.CtStatement;
import spoon.reflect.code.CtSwitch;
import spoon.reflect.code.CtWhile;
+import spoon.reflect.declaration.CtField;
import spoon.reflect.declaration.CtMethod;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import java.util.List;
@@ -32,7 +33,7 @@ public void testLabelsAreDetected() {
launcher.addInputResource("./src/test/java/spoon/test/labels/testclasses/ManyLabels.java");
launcher.buildModel();
- CtMethod mainMethod = launcher.getFactory().getModel().getElements(new NameFilter("main")).get(0);
+ CtMethod mainMethod = launcher.getFactory().getModel().getElements(new NamedElementFilter<>(CtMethod.class,"main")).get(0);
CtBlock body = mainMethod.getBody();
assertEquals(2, body.getStatements().size());
diff --git a/src/test/java/spoon/test/lambda/LambdaTest.java b/src/test/java/spoon/test/lambda/LambdaTest.java
index cf010eb7ab5..cef93dcc3fb 100644
--- a/src/test/java/spoon/test/lambda/LambdaTest.java
+++ b/src/test/java/spoon/test/lambda/LambdaTest.java
@@ -10,11 +10,11 @@
import spoon.reflect.code.CtLambda;
import spoon.reflect.code.CtTypeAccess;
import spoon.reflect.declaration.CtClass;
+import spoon.reflect.declaration.CtField;
import spoon.reflect.declaration.CtInterface;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.declaration.CtParameter;
import spoon.reflect.declaration.CtType;
-import spoon.reflect.declaration.CtTypeParameter;
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtArrayTypeReference;
import spoon.reflect.reference.CtParameterReference;
@@ -24,7 +24,7 @@
import spoon.reflect.visitor.Filter;
import spoon.reflect.visitor.filter.AbstractFilter;
import spoon.reflect.visitor.filter.LambdaFilter;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.test.lambda.testclasses.Bar;
import spoon.test.lambda.testclasses.Foo;
@@ -257,7 +257,7 @@ public void testLambdaExpressionInIfConditional() throws Exception {
assertParameterIsNamedBy("p", parameter);
assertHasExpressionBody(lambda);
- final CtMethod> method = foo.getElements(new NameFilter>("m8")).get(0);
+ final CtMethod> method = foo.getElements(new NamedElementFilter<>(CtMethod.class,"m8")).get(0);
final CtIf condition = method.getElements(new AbstractFilter(CtIf.class) {
@Override
public boolean matches(CtIf element) {
diff --git a/src/test/java/spoon/test/limits/utils/InternalTest.java b/src/test/java/spoon/test/limits/utils/InternalTest.java
index 8a6d84f1434..c49e5a25343 100644
--- a/src/test/java/spoon/test/limits/utils/InternalTest.java
+++ b/src/test/java/spoon/test/limits/utils/InternalTest.java
@@ -2,8 +2,9 @@
import org.junit.Test;
import spoon.reflect.declaration.CtClass;
+import spoon.reflect.declaration.CtField;
import spoon.reflect.declaration.CtNamedElement;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import java.util.List;
@@ -51,7 +52,7 @@ public void testStaticFinalFieldInAnonymousClass() throws Exception {
CtClass.class));
CtClass> c3 = classes.get(3);
List fields = c3
- .getElements(new NameFilter("serialVersionUID"));
+ .getElements(new NamedElementFilter<>(CtNamedElement.class,"serialVersionUID"));
assertEquals(1, fields.size());
}
diff --git a/src/test/java/spoon/test/methodreference/MethodReferenceTest.java b/src/test/java/spoon/test/methodreference/MethodReferenceTest.java
index 6ef1f029fd0..45b4f566a1c 100644
--- a/src/test/java/spoon/test/methodreference/MethodReferenceTest.java
+++ b/src/test/java/spoon/test/methodreference/MethodReferenceTest.java
@@ -13,16 +13,16 @@
import spoon.reflect.code.CtTypeAccess;
import spoon.reflect.code.CtVariableRead;
import spoon.reflect.declaration.CtClass;
+import spoon.reflect.declaration.CtField;
import spoon.reflect.declaration.CtMethod;
import spoon.reflect.declaration.CtParameter;
import spoon.reflect.declaration.CtType;
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtExecutableReference;
-import spoon.reflect.reference.CtTypeParameterReference;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.visitor.Query;
import spoon.reflect.visitor.filter.AbstractFilter;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.test.methodreference.testclasses.AssertJ;
import spoon.test.methodreference.testclasses.Cloud;
@@ -191,21 +191,21 @@ public void testNoClasspathSuperExecutable() {
// some consistency checks...
assertEquals(1, model.getElements(
- new NameFilter("a")).size());
+ new NamedElementFilter<>(CtMethod.class,"a")).size());
assertEquals(1, model.getElements(
- new NameFilter("b")).size());
+ new NamedElementFilter<>(CtMethod.class,"b")).size());
assertEquals(1, model.getElements(
- new NameFilter("toString")).size());
+ new NamedElementFilter<>(CtMethod.class,"toString")).size());
// get super method of a class not available in classpath
final CtMethod bMethod = model.getElements(
- new NameFilter("b")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"b")).get(0);
assertNotNull(bMethod.getAnnotation(overrideRef));
assertNull(bMethod.getReference().getOverridingExecutable());
// get super method of a class available in classpath (Object)
final CtMethod toStringMethod = model.getElements(
- new NameFilter("toString")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"toString")).get(0);
assertNotNull(toStringMethod.getAnnotation(overrideRef));
assertNotNull(toStringMethod.getReference().getOverridingExecutable());
}
diff --git a/src/test/java/spoon/test/parameters/ParameterTest.java b/src/test/java/spoon/test/parameters/ParameterTest.java
index 6e66c55b910..4cfa824c096 100644
--- a/src/test/java/spoon/test/parameters/ParameterTest.java
+++ b/src/test/java/spoon/test/parameters/ParameterTest.java
@@ -7,7 +7,7 @@
import spoon.reflect.declaration.CtParameter;
import spoon.reflect.reference.CtParameterReference;
import spoon.reflect.reference.CtTypeReference;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import java.util.List;
@@ -25,7 +25,7 @@ public void testParameterInNoClasspath() throws Exception {
launcher.run();
final CtClass aClass = launcher.getFactory().Class().get("org.eclipse.draw2d.text.FlowUtilities");
- final CtParameter> parameter = aClass.getElements(new NameFilter>("font")).get(0);
+ final CtParameter> parameter = aClass.getElements(new NamedElementFilter<>(CtParameter.class,"font")).get(0);
assertEquals("font", parameter.getSimpleName());
assertNotNull(parameter.getType());
@@ -74,7 +74,7 @@ public void testMultiParameterLambdaTypeReference() {
// test string parameters
parameters = launcher.getModel()
- .getElements(new NameFilter("stringLambda"))
+ .getElements(new NamedElementFilter<>(CtMethod.class,"stringLambda"))
.get(0)
.getElements(new TypeFilter<>(CtParameter.class));
assertEquals(2, parameters.size());
@@ -89,7 +89,7 @@ public void testMultiParameterLambdaTypeReference() {
// test integer parameters
parameters = launcher.getModel()
- .getElements(new NameFilter("integerLambda"))
+ .getElements(new NamedElementFilter<>(CtMethod.class,"integerLambda"))
.get(0)
.getElements(new TypeFilter<>(CtParameter.class));
assertEquals(2, parameters.size());
@@ -104,7 +104,7 @@ public void testMultiParameterLambdaTypeReference() {
// test unknown parameters
parameters = launcher.getModel()
- .getElements(new NameFilter("unknownLambda"))
+ .getElements(new NamedElementFilter<>(CtMethod.class,"unknownLambda"))
.get(0)
.getElements(new TypeFilter<>(CtParameter.class));
assertEquals(2, parameters.size());
diff --git a/src/test/java/spoon/test/query_function/VariableReferencesTest.java b/src/test/java/spoon/test/query_function/VariableReferencesTest.java
index 6815754a871..cdda9bdf9f5 100644
--- a/src/test/java/spoon/test/query_function/VariableReferencesTest.java
+++ b/src/test/java/spoon/test/query_function/VariableReferencesTest.java
@@ -30,7 +30,7 @@
import spoon.reflect.visitor.filter.CatchVariableScopeFunction;
import spoon.reflect.visitor.filter.LocalVariableReferenceFunction;
import spoon.reflect.visitor.filter.LocalVariableScopeFunction;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.ParameterReferenceFunction;
import spoon.reflect.visitor.filter.ParameterScopeFunction;
import spoon.reflect.visitor.filter.TypeFilter;
@@ -93,7 +93,7 @@ void checkKey(int key, CtElement ele) {
// System.out.println("Next available key is: "+(context.maxKey+1));
assertTrue(context.unique.size()>0);
assertEquals("Only these keys were found: "+context.unique.keySet(), context.maxKey, context.unique.size());
- assertEquals("AllLocalVars#maxValue must be equal to maximum value number ", (int)getLiteralValue((CtVariable)modelClass.filterChildren(new NameFilter("maxValue")).first()), context.maxKey);
+ assertEquals("AllLocalVars#maxValue must be equal to maximum value number ", (int)getLiteralValue((CtVariable)modelClass.filterChildren(new NamedElementFilter<>(CtVariable.class,"maxValue")).first()), context.maxKey);
}
@Test
diff --git a/src/test/java/spoon/test/reference/ExecutableReferenceGenericTest.java b/src/test/java/spoon/test/reference/ExecutableReferenceGenericTest.java
index a3aa8ddc516..cffb9858fc8 100644
--- a/src/test/java/spoon/test/reference/ExecutableReferenceGenericTest.java
+++ b/src/test/java/spoon/test/reference/ExecutableReferenceGenericTest.java
@@ -10,23 +10,20 @@
import spoon.reflect.declaration.CtConstructor;
import spoon.reflect.declaration.CtExecutable;
import spoon.reflect.declaration.CtMethod;
-import spoon.reflect.declaration.CtParameter;
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtExecutableReference;
import spoon.reflect.visitor.Filter;
import spoon.reflect.visitor.Query;
import spoon.reflect.visitor.filter.AbstractReferenceFilter;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.ReferenceTypeFilter;
import java.util.ArrayList;
import java.util.List;
-import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
/**
* Created by gerard on 21/11/2014.
@@ -229,7 +226,7 @@ public void testReferencesBetweenMethods() throws Exception {
public void testExecutableReferences() throws Exception {
// factory has loaded MyClass, MyClass2 and MyClass3
- CtClass> classMyClass = Query.getElements(factory, new NameFilter("MyClass")).get(0);
+ CtClass> classMyClass = Query.getElements(factory, new NamedElementFilter<>(CtClass.class,"MyClass")).get(0);
assertEquals("MyClass", classMyClass.getSimpleName());
List> refsExecutableClass1 = Query.getElements(classMyClass,
new AbstractReferenceFilter>(CtExecutableReference.class) {
@@ -238,7 +235,7 @@ public boolean matches(CtExecutableReference> reference) {
}
});
- CtClass> classMyClass2 = Query.getElements(factory, new NameFilter("MyClass2")).get(0);
+ CtClass> classMyClass2 = Query.getElements(factory, new NamedElementFilter<>(CtClass.class,"MyClass2")).get(0);
assertEquals("MyClass2", classMyClass2.getSimpleName());
List> refsExecutableClass2 = Query.getElements(classMyClass2,
new AbstractReferenceFilter>(CtExecutableReference.class) {
diff --git a/src/test/java/spoon/test/reference/TypeReferenceTest.java b/src/test/java/spoon/test/reference/TypeReferenceTest.java
index 1682aa95a8d..35b686b061f 100644
--- a/src/test/java/spoon/test/reference/TypeReferenceTest.java
+++ b/src/test/java/spoon/test/reference/TypeReferenceTest.java
@@ -29,7 +29,7 @@
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.reference.CtWildcardReference;
import spoon.reflect.visitor.Query;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.ReferenceTypeFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.test.reference.testclasses.EnumValue;
@@ -614,7 +614,7 @@ public void testTypeDeclarationWildcard() throws Exception {
@Test
public void testEqualityTypeReference() throws Exception {
CtClass aClass = (CtClass) buildClass(ParamRefs.class);
- CtParameter> parameter = aClass.getElements(new NameFilter>("param")).get(0);
+ CtParameter> parameter = aClass.getElements(new NamedElementFilter<>(CtParameter.class,"param")).get(0);
CtParameterReference> parameterRef1 = parameter.getReference();
CtParameterReference> parameterRef2 = aClass.getElements((CtParameterReference> ref)->ref.getSimpleName().equals("param")).get(0);
diff --git a/src/test/java/spoon/test/replace/ReplaceTest.java b/src/test/java/spoon/test/replace/ReplaceTest.java
index 659430414bf..a2dbdd1c4a2 100644
--- a/src/test/java/spoon/test/replace/ReplaceTest.java
+++ b/src/test/java/spoon/test/replace/ReplaceTest.java
@@ -27,7 +27,7 @@
import spoon.reflect.reference.CtParameterReference;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.visitor.Query;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.ReferenceTypeFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.visitor.replace.InvalidReplaceException;
@@ -93,7 +93,7 @@ public void testReplaceBlock() throws Exception {
CtClass> foo = factory.Package().get("spoon.test.replace.testclasses")
.getType("Foo");
CtMethod> m = foo.getElements(
- new NameFilter>("foo")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"foo")).get(0);
assertEquals("foo", m.getSimpleName());
final CtStatement parent = m.getBody().getStatements().get(2);
@@ -125,11 +125,11 @@ public void testReplaceReplace() throws Exception {
.getType("Foo");
CtMethod> fooMethod = foo.getElements(
- new NameFilter>("foo")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"foo")).get(0);
assertEquals("foo", fooMethod.getSimpleName());
CtMethod> barMethod = foo.getElements(
- new NameFilter>("bar")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"bar")).get(0);
assertEquals("bar", barMethod.getSimpleName());
CtLocalVariable> assignment = (CtLocalVariable>) fooMethod.getBody()
diff --git a/src/test/java/spoon/test/secondaryclasses/ClassesTest.java b/src/test/java/spoon/test/secondaryclasses/ClassesTest.java
index 8329107ac21..be8c2253537 100644
--- a/src/test/java/spoon/test/secondaryclasses/ClassesTest.java
+++ b/src/test/java/spoon/test/secondaryclasses/ClassesTest.java
@@ -20,13 +20,14 @@
import spoon.reflect.code.CtVariableRead;
import spoon.reflect.declaration.CtClass;
import spoon.reflect.declaration.CtField;
+import spoon.reflect.declaration.CtMethod;
import spoon.reflect.declaration.CtNamedElement;
import spoon.reflect.declaration.CtType;
import spoon.reflect.declaration.CtVariable;
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtTypeReference;
import spoon.reflect.visitor.filter.AbstractFilter;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.comparator.CtLineElementComparator;
import spoon.test.secondaryclasses.AnonymousClass.I;
@@ -52,7 +53,7 @@ public void testClassWithInternalPublicClassOrInterf() throws Exception {
assertEquals(
1,
type.getElements(
- new NameFilter("InternalInterf"))
+ new NamedElementFilter<>(CtNamedElement.class,"InternalInterf"))
.size());
}
@@ -127,7 +128,7 @@ public void testTopLevel() throws Exception {
assertEquals("TopLevel", type.getSimpleName());
CtClass> x = type.getElements(
- new NameFilter>("InnerClass")).get(0);
+ new NamedElementFilter<>(CtClass.class,"InnerClass")).get(0);
List> fields = x.getFields();
assertEquals(1, fields.size());
assertEquals(1, fields.get(0).getType().getActualTypeArguments().size());
diff --git a/src/test/java/spoon/test/signature/SignatureTest.java b/src/test/java/spoon/test/signature/SignatureTest.java
index df2bf0486ff..0211d389ef6 100644
--- a/src/test/java/spoon/test/signature/SignatureTest.java
+++ b/src/test/java/spoon/test/signature/SignatureTest.java
@@ -32,7 +32,7 @@
import spoon.reflect.factory.FactoryImpl;
import spoon.reflect.reference.CtExecutableReference;
import spoon.reflect.visitor.Query;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.ReferenceTypeFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.DefaultCoreFactory;
@@ -319,7 +319,7 @@ public void testBugSignature() throws Exception {
comp.addInputSources(SpoonResourceHelper.resources("./src/main/java/spoon/SpoonModelBuilder.java"));
comp.build();
CtType> ctClass = (CtType>) comp.getFactory().Type().get(SpoonModelBuilder.class);
- List> methods = ctClass.getElements(new NameFilter>("addInputSource"));
+ List methods = ctClass.getElements(new NamedElementFilter<>(CtMethod.class,"addInputSource"));
assertEquals(2, methods.size());
CtMethod> method = methods.get(0);
assertEquals(
diff --git a/src/test/java/spoon/test/targeted/TargetedExpressionTest.java b/src/test/java/spoon/test/targeted/TargetedExpressionTest.java
index 54f52e344e7..a5e7cdd4125 100644
--- a/src/test/java/spoon/test/targeted/TargetedExpressionTest.java
+++ b/src/test/java/spoon/test/targeted/TargetedExpressionTest.java
@@ -29,7 +29,7 @@
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtFieldReference;
import spoon.reflect.reference.CtTypeReference;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.reflect.visitor.filter.TypeFilter;
import spoon.support.comparator.CtLineElementComparator;
import spoon.support.reflect.code.CtConstructorCallImpl;
@@ -52,13 +52,13 @@ public void testCtSuperAccess() throws Exception {
final Factory factory = build(InternalSuperCall.class);
final CtClass> ctClass = factory.Class().get(InternalSuperCall.class);
- CtMethod> method = ctClass.getElements(new NameFilter>("methode")).get(0);
+ CtMethod> method = ctClass.getElements(new NamedElementFilter<>(CtMethod.class,"methode")).get(0);
assertEquals(
"spoon.test.targeted.testclasses.InternalSuperCall.super.toString()",
method.getBody().getStatements().get(0).toString());
assertNotNull(method.getElements(new TypeFilter<>(CtSuperAccess.class)).get(0).getTarget());
- CtMethod> toStringMethod = ctClass.getElements(new NameFilter>("toString")).get(0);
+ CtMethod> toStringMethod = ctClass.getElements(new NamedElementFilter<>(CtMethod.class,"toString")).get(0);
assertEquals(
"return super.toString()",
toStringMethod.getBody().getStatements().get(0).toString());
@@ -70,12 +70,12 @@ public void testCtThisAccess() throws Exception {
CtType> type = build("spoon.test.targeted.testclasses", "InnerClassThisAccess");
assertEquals("InnerClassThisAccess", type.getSimpleName());
- CtMethod> meth1 = type.getElements(new NameFilter>("method2")).get(0);
+ CtMethod> meth1 = type.getElements(new NamedElementFilter<>(CtMethod.class,"method2")).get(0);
assertEquals(
"this.method()",
meth1.getBody().getStatements().get(0).toString());
- CtClass> c = type.getElements(new NameFilter>("1InnerClass")).get(0);
+ CtClass> c = type.getElements(new NamedElementFilter<>(CtClass.class,"1InnerClass")).get(0);
assertEquals("1InnerClass", c.getSimpleName());
CtConstructor> ctr = c.getConstructor(type.getFactory().Type().createReference(boolean.class));
assertEquals("this.b = b", ctr.getBody().getLastStatement().toString());
diff --git a/src/test/java/spoon/test/template/TemplateTest.java b/src/test/java/spoon/test/template/TemplateTest.java
index fb4dc72b749..4352969f112 100644
--- a/src/test/java/spoon/test/template/TemplateTest.java
+++ b/src/test/java/spoon/test/template/TemplateTest.java
@@ -22,7 +22,7 @@
import spoon.reflect.factory.Factory;
import spoon.reflect.reference.CtFieldReference;
import spoon.reflect.visitor.ModelConsistencyChecker;
-import spoon.reflect.visitor.filter.NameFilter;
+import spoon.reflect.visitor.filter.NamedElementFilter;
import spoon.support.compiler.FileSystemFile;
import spoon.support.compiler.FileSystemFolder;
import spoon.support.template.Parameters;
@@ -112,7 +112,7 @@ public void testTemplateInheritance() throws Exception {
new SuperTemplate().addGeneratedBy(true).apply(superc);
CtMethod> addedMethod = superc.getElements(
- new NameFilter>("toBeOverriden")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"toBeOverriden")).get(0);
assertEquals("toBeOverriden", addedMethod.getSimpleName());
elementToGeneratedByMember.put(addedMethod, "#toBeOverriden");
@@ -137,7 +137,7 @@ public void testTemplateInheritance() throws Exception {
template.apply(subc);
CtMethod> addedMethod2 = subc.getElements(
- new NameFilter>("toBeOverriden")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"toBeOverriden")).get(0);
assertEquals("toBeOverriden", addedMethod2.getSimpleName());
assertEquals("super.toBeOverriden()", addedMethod2.getBody()
.getStatements().get(0).toString());
@@ -145,7 +145,7 @@ public void testTemplateInheritance() throws Exception {
// contract; method parameter templates are handled
CtMethod> methodWithTemplatedParameters = subc.getElements(
- new NameFilter>("methodWithTemplatedParameters")).get(0);
+ new NamedElementFilter<>(CtMethod.class,"methodWithTemplatedParameters")).get(0);
assertEquals("methodWithTemplatedParameters", methodWithTemplatedParameters.getSimpleName());
assertEquals("x", methodWithTemplatedParameters.getParameters().get(0).getSimpleName());
assertEquals("int x", methodWithTemplatedParameters.getParameters().get(0).toString());
@@ -202,7 +202,7 @@ public void testTemplateInheritance() throws Exception {
// contract; field access is handled same like local variable access
CtMethod> methodWithFieldAccess = subc.getElements(
- new NameFilter>("methodWithFieldAccess")).get(0);
+ new NamedElementFilter<>(CtMethod.class, "methodWithFieldAccess")).get(0);
elementToGeneratedByMember.put(methodWithFieldAccess, "#methodWithFieldAccess");
elementToGeneratedByMember.put(subc.getField("newVarName"), "#var");
@@ -314,7 +314,7 @@ public void testTemplateC1() throws Exception {
assertEquals(3, c1.getConstructors().size());
CtField> toBeInserted = c1.getElements(
- new NameFilter>("toBeInserted")).get(0);
+ new NamedElementFilter<>(CtField.class,"toBeInserted")).get(0);
assertEquals(Date.class, toBeInserted.getType()
.getActualTypeArguments().get(0).getActualClass());
assertEquals(
@@ -428,7 +428,7 @@ public void testTemplateMatcher() throws Exception {
{// testing matcher1
CtClass> templateKlass = factory.Class().get(CheckBoundMatcher.class);
CtClass> klass = factory.Class().get(CheckBound.class);
- CtIf templateRoot = (CtIf) ((CtMethod) templateKlass.getElements(new NameFilter("matcher1")).get(0)).getBody().getStatement(0);
+ CtIf templateRoot = (CtIf) ((CtMethod) templateKlass.getElements(new NamedElementFilter<>(CtMethod.class,"matcher1")).get(0)).getBody().getStatement(0);
TemplateMatcher matcher = new TemplateMatcher(templateRoot);
assertEquals(2, matcher.find(klass).size());
assertThat(asList("foo","fbar"), is(klass.filterChildren(matcher).map((CtElement e)->e.getParent(CtMethod.class).getSimpleName()).list())) ;
@@ -437,7 +437,7 @@ public void testTemplateMatcher() throws Exception {
{// testing matcher2
CtClass> templateKlass = factory.Class().get(CheckBoundMatcher.class);
CtClass> klass = factory.Class().get(CheckBound.class);
- CtIf templateRoot = (CtIf) ((CtMethod) templateKlass.getElements(new NameFilter("matcher2")).get(0)).getBody().getStatement(0);
+ CtIf templateRoot = (CtIf) ((CtMethod) templateKlass.getElements(new NamedElementFilter<>(CtMethod.class,"matcher2")).get(0)).getBody().getStatement(0);
TemplateMatcher matcher = new TemplateMatcher(templateRoot);
assertEquals(1, matcher.find(klass).size());
assertThat(asList("bov"), is(klass.filterChildren(matcher).map((CtElement e)->e.getParent(CtMethod.class).getSimpleName()).list())) ;
@@ -446,7 +446,7 @@ public void testTemplateMatcher() throws Exception {
{// testing matcher3
CtClass> templateKlass = factory.Class().get(CheckBoundMatcher.class);
CtClass> klass = factory.Class().get(CheckBound.class);
- CtIf templateRoot = (CtIf) ((CtMethod) templateKlass.getElements(new NameFilter("matcher3")).get(0)).getBody().getStatement(0);
+ CtIf templateRoot = (CtIf) ((CtMethod) templateKlass.getElements(new NamedElementFilter<>(CtMethod.class,"matcher3")).get(0)).getBody().getStatement(0);
TemplateMatcher matcher = new TemplateMatcher(templateRoot);
assertEquals(2, matcher.find(klass).size());
assertThat(asList("foo","fbar"), is(klass.filterChildren(matcher).map((CtElement e)->e.getParent(CtMethod.class).getSimpleName()).list())) ;
@@ -455,7 +455,7 @@ public void testTemplateMatcher() throws Exception {
{// testing matcher4
CtClass> templateKlass = factory.Class().get(CheckBoundMatcher.class);
CtClass> klass = factory.Class().get(CheckBound.class);
- CtIf templateRoot = (CtIf) ((CtMethod) templateKlass.getElements(new NameFilter("matcher4")).get(0)).getBody().getStatement(0);
+ CtIf templateRoot = (CtIf) ((CtMethod) templateKlass.getElements(new NamedElementFilter<>(CtMethod.class,"matcher4")).get(0)).getBody().getStatement(0);
TemplateMatcher matcher = new TemplateMatcher(templateRoot);
assertEquals(3, matcher.find(klass).size());
assertThat(asList("foo","foo2","fbar"), is(klass.filterChildren(matcher).map((CtElement e)->e.getParent(CtMethod.class).getSimpleName()).list())) ;
@@ -464,7 +464,7 @@ public void testTemplateMatcher() throws Exception {
{// testing matcher5
CtClass> templateKlass = factory.Class().get(CheckBoundMatcher.class);
CtClass> klass = factory.Class().get(CheckBound.class);
- CtIf templateRoot = (CtIf) ((CtMethod) templateKlass.getElements(new NameFilter("matcher5")).get(0)).getBody().getStatement(0);
+ CtIf templateRoot = (CtIf) ((CtMethod) templateKlass.getElements(new NamedElementFilter<>(CtMethod.class,"matcher5")).get(0)).getBody().getStatement(0);
TemplateMatcher matcher = new TemplateMatcher(templateRoot);
assertEquals(6, matcher.find(klass).size());
assertThat(asList("foo","foo2","fbar","baz","bou","bov"), is(klass.filterChildren(matcher).map((CtElement e)->e.getParent(CtMethod.class).getSimpleName()).list())) ;
@@ -473,7 +473,7 @@ public void testTemplateMatcher() throws Exception {
{// testing matcher6
CtClass> templateKlass = factory.Class().get(CheckBoundMatcher.class);
CtClass> klass = factory.Class().get(CheckBound.class);
- CtIf templateRoot = (CtIf) ((CtMethod) templateKlass.getElements(new NameFilter("matcher6")).get(0)).getBody().getStatement(0);
+ CtIf templateRoot = (CtIf) ((CtMethod) templateKlass.getElements(new NamedElementFilter<>(CtMethod.class,"matcher6")).get(0)).getBody().getStatement(0);
TemplateMatcher matcher = new TemplateMatcher(templateRoot);
assertEquals(2, matcher.find(klass).size());
assertThat(asList("baz","bou"), is(klass.filterChildren(matcher).map((CtElement e)->e.getParent(CtMethod.class).getSimpleName()).list())) ;
@@ -484,7 +484,7 @@ public void testTemplateMatcher() throws Exception {
{
CtClass> templateKlass = factory.Class().get(CheckBoundMatcher.class);
CtClass> klass = factory.Class().get(CheckBound.class);
- CtMethod meth = (CtMethod) templateKlass.getElements(new NameFilter("matcher3")).get(0);
+ CtMethod meth = (CtMethod) templateKlass.getElements(new NamedElementFilter<>(CtMethod.class,"matcher3")).get(0);
// exact match
meth.setSimpleName("foo");
@@ -498,7 +498,7 @@ public void testTemplateMatcher() throws Exception {
// contract: the name to be matched does not have to be an exact match
CtClass> templateKlass = factory.Class().get(CheckBoundMatcher.class);
CtClass> klass = factory.Class().get(CheckBound.class);
- CtMethod meth = (CtMethod) templateKlass.getElements(new NameFilter("matcher5")).get(0);
+ CtMethod meth = (CtMethod) templateKlass.getElements(new NamedElementFilter<>(CtMethod.class,"matcher5")).get(0);
// together with the appropriate @Parameter _w_, this means
// we match all methods with name f*, because parameter _w_ acts as a wildcard
@@ -606,7 +606,7 @@ public void testTemplateMatcherWithWholePackage() throws Exception {
Factory factory = spoon.getFactory();
CtClass> templateKlass = factory.Class().get(SecurityCheckerTemplate.class);
- CtMethod templateMethod = (CtMethod) templateKlass.getElements(new NameFilter("matcher1")).get(0);
+ CtMethod templateMethod = (CtMethod) templateKlass.getElements(new NamedElementFilter<>(CtMethod.class,"matcher1")).get(0);
CtIf templateRoot = (CtIf) templateMethod.getBody().getStatement(0);
TemplateMatcher matcher = new TemplateMatcher(templateRoot);
@@ -649,7 +649,7 @@ public void testTemplateMatcherMatchTwoSnippets() throws Exception {
Factory factory = spoon.getFactory();
CtClass> templateKlass = factory.Class().get(SecurityCheckerTemplate.class);
- CtMethod templateMethod = (CtMethod) templateKlass.getElements(new NameFilter("matcher1")).get(0);
+ CtMethod templateMethod = (CtMethod) templateKlass.getElements(new NamedElementFilter<>(CtMethod.class,"matcher1")).get(0);
CtIf templateRoot = (CtIf) templateMethod.getBody().getStatement(0);
TemplateMatcher matcher = new TemplateMatcher(templateRoot);
@@ -684,7 +684,7 @@ public void testTemplateInvocationSubstitution() throws Exception {
CtClass> resultKlass = factory.Class().create("Result");
new InvocationTemplate(factory.Type().OBJECT, "hashCode").apply(resultKlass);
- CtMethod> templateMethod = (CtMethod>) resultKlass.getElements(new NameFilter("invoke")).get(0);
+ CtMethod> templateMethod = (CtMethod>) resultKlass.getElements(new NamedElementFilter<>(CtMethod.class,"invoke")).get(0);
CtStatement templateRoot = (CtStatement) templateMethod.getBody().getStatement(0);
//iface.$method$() becomes iface.hashCode()
assertEquals("iface.hashCode()", templateRoot.toString());
diff --git a/src/test/java/spoon/test/variable/AccessFullyQualifiedFieldTest.java b/src/test/java/spoon/test/variable/AccessFullyQualifiedFieldTest.java
index 978f128bae4..b2d9d4960e8 100644
--- a/src/test/java/spoon/test/variable/AccessFullyQualifiedFieldTest.java
+++ b/src/test/java/spoon/test/variable/AccessFullyQualifiedFieldTest.java
@@ -2,22 +2,15 @@
import org.junit.Test;
import spoon.Launcher;
-import spoon.reflect.code.CtLocalVariable;
-import spoon.reflect.declaration.CtElement;
-import spoon.reflect.declaration.CtMethod;
import spoon.reflect.declaration.CtType;
-import spoon.reflect.declaration.CtVariable;
import spoon.reflect.factory.Factory;
import spoon.reflect.visitor.PrettyPrinter;
-import spoon.reflect.visitor.filter.NameFilter;
-import spoon.support.JavaOutputProcessor;
import spoon.test.main.MainTest;
import spoon.test.variable.testclasses.Tacos;
import java.util.ArrayList;
import java.util.List;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static spoon.testing.utils.ModelUtils.build;
import static spoon.testing.utils.ModelUtils.canBeBuilt;