private static ASTPrinter getASTPrinter() { return new ASTPrinter( org.hibernate.hql.internal.antlr.HqlTokenTypes.class ); }
private static ASTPrinter getASTPrinter() { return new ASTPrinter( org.hibernate.hql.internal.antlr.HqlTokenTypes.class ); }
private static void logAST(AST ast, String message) { if (LOGGER.isDebugEnabled()) { ASTPrinter printer = new ASTPrinter(HqlTokenTypes.class); String astText = printer.showAsString(ast, message); LOGGER.debug(astText); } }
/** * Returns an array of SelectExpressions gathered from the children of the given parent AST node. * * @return an array of SelectExpressions gathered from the children of the given parent AST node. */ public SelectExpression[] collectSelectExpressions() { // Get the first child to be considered. Sub-classes may do this differently in order to skip nodes that // are not select expressions (e.g. DISTINCT). AST firstChild = getFirstSelectExpression(); AST parent = this; ArrayList list = new ArrayList( parent.getNumberOfChildren() ); for ( AST n = firstChild; n != null; n = n.getNextSibling() ) { if ( n instanceof SelectExpression ) { list.add( n ); } else { throw new IllegalStateException( "Unexpected AST: " + n.getClass().getName() + " " + new ASTPrinter( SqlTokenTypes.class ).showAsString( n, "" ) ); } } return ( SelectExpression[] ) list.toArray( new SelectExpression[list.size()] ); }
/** * Returns an array of SelectExpressions gathered from the children of the given parent AST node. * * @return an array of SelectExpressions gathered from the children of the given parent AST node. */ public SelectExpression[] collectSelectExpressions() { // Get the first child to be considered. Sub-classes may do this differently in order to skip nodes that // are not select expressions (e.g. DISTINCT). AST firstChild = getFirstSelectExpression(); AST parent = this; ArrayList list = new ArrayList( parent.getNumberOfChildren() ); for ( AST n = firstChild; n != null; n = n.getNextSibling() ) { if ( n instanceof SelectExpression ) { list.add( n ); } else { throw new IllegalStateException( "Unexpected AST: " + n.getClass().getName() + " " + new ASTPrinter( SqlTokenTypes.class ).showAsString( n, "" ) ); } } return ( SelectExpression[] ) list.toArray( new SelectExpression[list.size()] ); }
void showHqlAst(AST hqlAst) { if ( LOG.isDebugEnabled() ) { ASTPrinter printer = new ASTPrinter( HqlTokenTypes.class ); LOG.debug( printer.showAsString( hqlAst, "--- HQL AST ---" ) ); } }
void showHqlAst(AST hqlAst) { if ( LOG.isDebugEnabled() ) { ASTPrinter printer = new ASTPrinter( HqlTokenTypes.class ); LOG.debug( printer.showAsString( hqlAst, "--- HQL AST ---" ) ); } }
/** * Create a new tree transformer. * * @param qti Back pointer to the query translator implementation that is using this tree transform. * @param sfi The session factory implementor where the Hibernate mappings can be found. * @param parser A reference to the phase-1 parser * @param tokenReplacements Registers the token replacement map with the walker. This map will * be used to substitute function names and constants. * @param collectionRole The collection role name of the collection used as the basis for the * filter, NULL if this is not a collection filter compilation. */ public HqlSqlWalker( QueryTranslatorImpl qti, SessionFactoryImplementor sfi, HqlParser parser, Map tokenReplacements, String collectionRole) { setASTFactory( new SqlASTFactory( this ) ); // Initialize the error handling delegate. this.parseErrorHandler = new ErrorCounter(); this.queryTranslatorImpl = qti; this.sessionFactoryHelper = new SessionFactoryHelper( sfi ); this.literalProcessor = new LiteralProcessor( this ); this.tokenReplacements = tokenReplacements; this.collectionFilterRole = collectionRole; this.hqlParser = parser; this.printer = new ASTPrinter( SqlTokenTypes.class ); }
/** * Create a new tree transformer. * * @param qti Back pointer to the query translator implementation that is using this tree transform. * @param sfi The session factory implementor where the Hibernate mappings can be found. * @param parser A reference to the phase-1 parser * @param tokenReplacements Registers the token replacement map with the walker. This map will * be used to substitute function names and constants. * @param collectionRole The collection role name of the collection used as the basis for the * filter, NULL if this is not a collection filter compilation. */ public HqlSqlWalker( QueryTranslatorImpl qti, SessionFactoryImplementor sfi, HqlParser parser, Map tokenReplacements, String collectionRole) { setASTFactory( new SqlASTFactory( this ) ); // Initialize the error handling delegate. this.parseErrorHandler = new ErrorCounter(); this.queryTranslatorImpl = qti; this.sessionFactoryHelper = new SessionFactoryHelper( sfi ); this.literalProcessor = new LiteralProcessor( this ); this.tokenReplacements = tokenReplacements; this.collectionFilterRole = collectionRole; this.hqlParser = parser; this.printer = new ASTPrinter( SqlTokenTypes.class ); }
private HqlSqlWalker analyze(HqlParser parser, String collectionRole) throws QueryException, RecognitionException { HqlSqlWalker w = new HqlSqlWalker( this, factory, parser, tokenReplacements, collectionRole ); AST hqlAst = parser.getAST(); // Transform the tree. w.statement( hqlAst ); if ( LOG.isDebugEnabled() ) { ASTPrinter printer = new ASTPrinter( SqlTokenTypes.class ); LOG.debug( printer.showAsString( w.getAST(), "--- SQL AST ---" ) ); } w.getParseErrorHandler().throwQueryException(); return w; }
private HqlSqlWalker analyze(HqlParser parser, String collectionRole) throws QueryException, RecognitionException { HqlSqlWalker w = new HqlSqlWalker( this, factory, parser, tokenReplacements, collectionRole ); AST hqlAst = parser.getAST(); // Transform the tree. w.statement( hqlAst ); if ( LOG.isDebugEnabled() ) { ASTPrinter printer = new ASTPrinter( SqlTokenTypes.class ); LOG.debug( printer.showAsString( w.getAST(), "--- SQL AST ---" ) ); } w.getParseErrorHandler().throwQueryException(); return w; }
if ( type == null ) { throw new IllegalStateException( "No data type for node: " + selectExpression.getClass().getName() + " " + new ASTPrinter( SqlTokenTypes.class ).showAsString( ( AST ) selectExpression, "" ) );
if ( type == null ) { throw new IllegalStateException( "No data type for node: " + selectExpression.getClass().getName() + " " + new ASTPrinter( SqlTokenTypes.class ).showAsString( ( AST ) selectExpression, "" ) );
ASTPrinter printer = new ASTPrinter( OrderByTemplateTokenTypes.class ); LOG.trace( printer.showAsString( parser.getAST(), "--- {order-by fragment} ---" ) );
ASTPrinter printer = new ASTPrinter( OrderByTemplateTokenTypes.class ); LOG.trace( printer.showAsString( parser.getAST(), "--- {order-by fragment} ---" ) );