use of net.sourceforge.pmd.lang.java.ast.ASTPrimaryExpression in project pmd by pmd.
the class ClassTypeResolverTest method testThisExpression.
@Test
public void testThisExpression() throws JaxenException {
ASTCompilationUnit acu = parseAndTypeResolveForClass15(ThisExpression.class);
List<ASTPrimaryExpression> expressions = convertList(acu.findChildNodesWithXPath("//PrimaryExpression"), ASTPrimaryExpression.class);
List<ASTPrimaryPrefix> prefixes = convertList(acu.findChildNodesWithXPath("//PrimaryPrefix"), ASTPrimaryPrefix.class);
int index = 0;
assertEquals(ThisExpression.class, expressions.get(index).getType());
assertEquals(ThisExpression.class, prefixes.get(index++).getType());
assertEquals(ThisExpression.class, expressions.get(index).getType());
assertEquals(ThisExpression.class, prefixes.get(index++).getType());
assertEquals(ThisExpression.class, expressions.get(index).getType());
assertEquals(ThisExpression.class, prefixes.get(index++).getType());
assertEquals(ThisExpression.class, expressions.get(index).getType());
assertEquals(ThisExpression.class, prefixes.get(index++).getType());
assertEquals(ThisExpression.ThisExprNested.class, expressions.get(index).getType());
assertEquals(ThisExpression.ThisExprNested.class, prefixes.get(index++).getType());
// Qualified this
assertEquals(ThisExpression.class, expressions.get(index).getType());
assertEquals(ThisExpression.class, prefixes.get(index).getType());
assertEquals(ThisExpression.class, ((TypeNode) expressions.get(index++).jjtGetChild(1)).getType());
assertEquals(ThisExpression.ThisExprStaticNested.class, expressions.get(index).getType());
assertEquals(ThisExpression.ThisExprStaticNested.class, prefixes.get(index++).getType());
// Make sure we got them all
assertEquals("All expressions not tested", index, expressions.size());
assertEquals("All expressions not tested", index, prefixes.size());
}
Aggregations