HHH-18808 remove logging when keyword is used as identifier in HqlParser.g4

This commit is contained in:
nathan.xu 2024-11-04 01:44:13 -05:00 committed by Gavin King
parent f7c5ff28f0
commit 3153bce9b5
2 changed files with 8 additions and 32 deletions

View File

@ -14,12 +14,6 @@ options {
package org.hibernate.grammars.hql; package org.hibernate.grammars.hql;
} }
@members {
protected void logUseOfReservedWordAsIdentifier(Token token) {
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Statements // Statements
@ -1851,7 +1845,7 @@ xmltableDefaultClause
nakedIdentifier nakedIdentifier
: IDENTIFIER : IDENTIFIER
| QUOTED_IDENTIFIER | QUOTED_IDENTIFIER
| (ABSENT | ABSENT
| ALL | ALL
| AND | AND
| ANY | ANY
@ -2057,17 +2051,14 @@ xmltableDefaultClause
| XMLQUERY | XMLQUERY
| XMLTABLE | XMLTABLE
| YEAR | YEAR
| ZONED) { | ZONED
logUseOfReservedWordAsIdentifier( getCurrentToken() );
}
; ;
identifier identifier
: nakedIdentifier : nakedIdentifier
| (FULL | FULL
| INNER | INNER
| LEFT | LEFT
| OUTER | OUTER
| RIGHT) { | RIGHT
logUseOfReservedWordAsIdentifier( getCurrentToken() );
}
; ;

View File

@ -4,15 +4,10 @@
*/ */
package org.hibernate.query.hql.internal; package org.hibernate.query.hql.internal;
import org.hibernate.grammars.hql.HqlLexer;
import org.hibernate.grammars.hql.HqlParser;
import org.hibernate.query.hql.HqlLogging;
import org.jboss.logging.Logger;
import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.Token; import org.hibernate.grammars.hql.HqlLexer;
import org.hibernate.grammars.hql.HqlParser;
/** /**
* Leverages ANTLR to build a parse tree from an HQL query. * Leverages ANTLR to build a parse tree from an HQL query.
@ -20,9 +15,6 @@ import org.antlr.v4.runtime.Token;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class HqlParseTreeBuilder { public class HqlParseTreeBuilder {
private static final Logger LOGGER = HqlLogging.subLogger( "reservedWordAsIdentifier" );
private static final boolean DEBUG_ENABLED = LOGGER.isDebugEnabled();
/** /**
* Singleton access * Singleton access
*/ */
@ -34,13 +26,6 @@ public class HqlParseTreeBuilder {
public HqlParser buildHqlParser(String hql, HqlLexer hqlLexer) { public HqlParser buildHqlParser(String hql, HqlLexer hqlLexer) {
// Build the parser // Build the parser
return new HqlParser( new CommonTokenStream( hqlLexer ) ) { return new HqlParser( new CommonTokenStream( hqlLexer ) );
@Override
protected void logUseOfReservedWordAsIdentifier(Token token) {
if ( DEBUG_ENABLED ) {
LOGGER.debugf( "Encountered use of reserved word as identifier : %s", token.getText() );
}
}
};
} }
} }