Search in sources :

Example 6 with DeepRepresentationComparator

use of spoon.support.comparator.DeepRepresentationComparator in project spoon by INRIA.

the class ConstructorCallTest method setUp.

@Before
public void setUp() throws Exception {
    final Launcher launcher = new Launcher();
    launcher.addInputResource("./src/test/java/" + Foo.class.getCanonicalName().replace(".", "/") + ".java");
    launcher.addInputResource("./src/test/java/" + Panini.class.getCanonicalName().replace(".", "/") + ".java");
    launcher.setSourceOutputDirectory("./target/spooned");
    launcher.run();
    final Factory factory = launcher.getFactory();
    final CtClass<?> foo = (CtClass<?>) factory.Type().get(Foo.class);
    TreeSet ts = new TreeSet(new DeepRepresentationComparator());
    ts.addAll(foo.getElements(new AbstractFilter<CtConstructorCall<?>>(CtConstructorCall.class) {

        @Override
        public boolean matches(CtConstructorCall<?> element) {
            return true;
        }
    }));
    constructorCalls = new ArrayList(ts);
    final CtType<Panini> panini = factory.Type().get(Panini.class);
    constructorCallsPanini = panini.getElements(new TypeFilter<CtConstructorCall<?>>(CtConstructorCall.class));
}
Also used : AbstractFilter(spoon.reflect.visitor.filter.AbstractFilter) Foo(spoon.test.constructorcallnewclass.testclasses.Foo) ArrayList(java.util.ArrayList) Factory(spoon.reflect.factory.Factory) Panini(spoon.test.constructorcallnewclass.testclasses.Panini) TypeFilter(spoon.reflect.visitor.filter.TypeFilter) CtClass(spoon.reflect.declaration.CtClass) DeepRepresentationComparator(spoon.support.comparator.DeepRepresentationComparator) CtConstructorCall(spoon.reflect.code.CtConstructorCall) TreeSet(java.util.TreeSet) Launcher(spoon.Launcher) Before(org.junit.Before)

Aggregations

TreeSet (java.util.TreeSet)6 DeepRepresentationComparator (spoon.support.comparator.DeepRepresentationComparator)6 Test (org.junit.Test)5 Launcher (spoon.Launcher)5 CtMethod (spoon.reflect.declaration.CtMethod)4 OverridingMethodFilter (spoon.reflect.visitor.filter.OverridingMethodFilter)3 CtClass (spoon.reflect.declaration.CtClass)2 Factory (spoon.reflect.factory.Factory)2 TypeFilter (spoon.reflect.visitor.filter.TypeFilter)2 AbstractTostada (spoon.test.filters.testclasses.AbstractTostada)2 ITostada (spoon.test.filters.testclasses.ITostada)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 SpoonModelBuilder (spoon.SpoonModelBuilder)1 CtConstructorCall (spoon.reflect.code.CtConstructorCall)1 CtInvocation (spoon.reflect.code.CtInvocation)1 CtLiteral (spoon.reflect.code.CtLiteral)1 CtType (spoon.reflect.declaration.CtType)1 FactoryImpl (spoon.reflect.factory.FactoryImpl)1 AbstractFilter (spoon.reflect.visitor.filter.AbstractFilter)1