Search in sources :

Example 1 with CtArrayRead

use of spoon.reflect.code.CtArrayRead in project spoon by INRIA.

the class AccessTest method testCanVisitArrayAccessAndSubClasses.

@Test
public void testCanVisitArrayAccessAndSubClasses() throws Exception {
    final Factory factory = build(ArrayAccessSample.class);
    final List<CtArrayRead<?>> arraysRead = Query.getElements(factory, new AbstractFilter<CtArrayRead<?>>(CtArrayRead.class) {

        @Override
        public boolean matches(CtArrayRead<?> element) {
            return super.matches(element);
        }
    });
    assertEquals(2, arraysRead.size());
    final List<CtArrayWrite<?>> arraysWrite = Query.getElements(factory, new AbstractFilter<CtArrayWrite<?>>(CtArrayWrite.class) {

        @Override
        public boolean matches(CtArrayWrite<?> element) {
            return super.matches(element);
        }
    });
    assertEquals(1, arraysWrite.size());
    final List<CtArrayAccess<?, CtExpression<?>>> arraysAccess = Query.getElements(factory, new AbstractFilter<CtArrayAccess<?, CtExpression<?>>>(CtArrayAccess.class) {

        @Override
        public boolean matches(CtArrayAccess<?, CtExpression<?>> element) {
            return super.matches(element);
        }
    });
    assertEquals(3, arraysAccess.size());
}
Also used : CtExpression(spoon.reflect.code.CtExpression) ModelUtils.createFactory(spoon.testing.utils.ModelUtils.createFactory) Factory(spoon.reflect.factory.Factory) CtArrayWrite(spoon.reflect.code.CtArrayWrite) CtArrayAccess(spoon.reflect.code.CtArrayAccess) CtArrayRead(spoon.reflect.code.CtArrayRead) MainTest(spoon.test.main.MainTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 CtArrayAccess (spoon.reflect.code.CtArrayAccess)1 CtArrayRead (spoon.reflect.code.CtArrayRead)1 CtArrayWrite (spoon.reflect.code.CtArrayWrite)1 CtExpression (spoon.reflect.code.CtExpression)1 Factory (spoon.reflect.factory.Factory)1 MainTest (spoon.test.main.MainTest)1 ModelUtils.createFactory (spoon.testing.utils.ModelUtils.createFactory)1