HHH-14033 - SQL script parsing problem with multi-line comments

- Better handling of multi-line comments
- Restructured some internal classes to consolidate packages
- Added "system"-style SchemaToolingLogging

This commit:

- removed some temporary logging
- better comments in parsers
This commit is contained in:
Steve Ebersole 2020-05-20 07:13:41 -05:00
parent 7dfb0fdf24
commit 50a5da07c1
4 changed files with 25 additions and 5 deletions

View File

@ -55,6 +55,8 @@ public class GraphParser extends GeneratedGraphParser {
this.sessionFactory = sessionFactory;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Semantic actions
@Override
protected void startAttribute(Token attributeNameToken) {
@ -165,6 +167,10 @@ public class GraphParser extends GeneratedGraphParser {
}
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// trace logging hooks
@Override
public void traceIn(String s) throws TokenStreamException {
// nothing to do - this parser already does a good job with logging trace info

View File

@ -62,7 +62,8 @@ public final class HqlParser extends HqlBaseParser {
}
// handle trace logging ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// trace logging hooks
private int traceDepth;
@ -90,6 +91,9 @@ public final class HqlParser extends HqlBaseParser {
LOG.trace( prefix + ruleName );
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// error handling hooks
@Override
public void reportError(RecognitionException e) {
parseErrorHandler.reportError( e ); // Use the delegate.
@ -110,6 +114,9 @@ public final class HqlParser extends HqlBaseParser {
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Semantic actions
/**
* Overrides the base behavior to retry keywords as identifiers.
*

View File

@ -45,6 +45,9 @@ public class OrderByFragmentParser extends GeneratedOrderByFragmentParser {
return columnReferences;
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// semantic actions
@Override
protected AST quotedIdentifier(AST ident) {
/*
@ -286,7 +289,8 @@ public class OrderByFragmentParser extends GeneratedOrderByFragmentParser {
}
// trace logging ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// trace logging hooks
private int traceDepth = 0;

View File

@ -65,7 +65,6 @@ public class SqlScriptParser extends GeneratedSqlScriptParser {
*/
@Override
protected void out(String text) {
SchemaToolingLogging.AST_LOGGER.tracef( "Buffering text : %s", text );
currentStatementBuffer.append( text );
}
@ -74,7 +73,6 @@ public class SqlScriptParser extends GeneratedSqlScriptParser {
*/
@Override
protected void out(Token token) {
SchemaToolingLogging.AST_LOGGER.tracef( "out( %s(%s) )", TOKEN_NAMES[ token.getType() ], token.getText() );
currentStatementBuffer.append( token.getText() );
}
@ -117,6 +115,10 @@ public class SqlScriptParser extends GeneratedSqlScriptParser {
return buf.toString();
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// error handling hooks
@Override
public void reportError(RecognitionException e) {
final String textBase = "RecognitionException(@" + e.getLine() + ":" + e.getColumn() + ")";
@ -143,7 +145,8 @@ public class SqlScriptParser extends GeneratedSqlScriptParser {
SchemaToolingLogging.LOGGER.debugf( "SqlScriptParser recognition warning : " + message );
}
// handle trace logging ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// trace logging hooks
private final int depthIndent = 2;
private int traceDepth;