use of spoon.reflect.visitor.filter.LineFilter in project spoon by INRIA.
the class FilterTest method testLineFilter.
@Test
public void testLineFilter() throws Exception {
CtType<FooLine> foo = ModelUtils.buildClass(FooLine.class);
CtMethod method = foo.getMethod("simple");
List<CtStatement> expressions = method.getElements(new LineFilter());
assertEquals(3, expressions.size());
assertNull(expressions.get(0).getParent(new LineFilter()));
method = foo.getMethod("loopBlock");
expressions = method.getElements(new LineFilter());
assertEquals(2, expressions.size());
assertNull(expressions.get(0).getParent(new LineFilter()));
assertTrue(expressions.get(1).getParent(new LineFilter()) instanceof CtLoop);
method = foo.getMethod("loopNoBlock");
expressions = method.getElements(new LineFilter());
assertEquals(2, expressions.size());
assertNull(expressions.get(0).getParent(new LineFilter()));
assertTrue(expressions.get(1).getParent(new LineFilter()) instanceof CtLoop);
method = foo.getMethod("ifBlock");
expressions = method.getElements(new LineFilter());
assertEquals(2, expressions.size());
assertNull(expressions.get(0).getParent(new LineFilter()));
assertTrue(expressions.get(1).getParent(new LineFilter()) instanceof CtIf);
method = foo.getMethod("ifNoBlock");
expressions = method.getElements(new LineFilter());
assertEquals(2, expressions.size());
assertNull(expressions.get(0).getParent(new LineFilter()));
assertTrue(expressions.get(1).getParent(new LineFilter()) instanceof CtIf);
method = foo.getMethod("switchBlock");
expressions = method.getElements(new LineFilter());
assertEquals(3, expressions.size());
assertNull(expressions.get(0).getParent(new LineFilter()));
assertTrue(expressions.get(1).getParent(new LineFilter()) instanceof CtSwitch);
assertTrue(expressions.get(2).getParent(new LineFilter()) instanceof CtSwitch);
}
Aggregations