use of org.hibernate.hql.internal.ast.tree.Node in project hibernate-orm by hibernate.
the class HqlParserTest method testLineAndColumnNumber.
@Test
public void testLineAndColumnNumber() throws Exception {
AST ast = doParse("from Foo f\nwhere f.name = 'fred'", false);
// Find some of the nodes and check line and column values.
ASTIterator iter = new ASTIterator(ast);
boolean foundFoo = false;
boolean foundName = false;
while (iter.hasNext()) {
AST n = iter.nextNode();
if ("Foo".equals(n.getText())) {
if (foundFoo)
fail("Already found 'Foo'!");
foundFoo = true;
Node node = (Node) n;
assertEquals(1, node.getLine());
assertEquals(6, node.getColumn());
} else if ("name".equals(n.getText())) {
if (foundName)
fail("Already found 'name'!");
foundName = true;
Node node = (Node) n;
assertEquals(2, node.getLine());
assertEquals(9, node.getColumn());
}
}
assertTrue(foundFoo);
assertTrue(foundName);
}
Aggregations