use of com.abubusoft.kripton.processor.sqlite.grammars.jsql.JqlParser.Sql_stmtContext in project kripton by xcesco.
the class SQLiteSchemaVerifierHelper method extractCommands.
static List<String> extractCommands(SQLiteDatabase database, InputStream inputStream) {
final List<String> result = new ArrayList<>();
final String input = IOUtils.readText(inputStream);
JqlLexer lexer = new JqlLexer(CharStreams.fromString(input));
CommonTokenStream tokens = new CommonTokenStream(lexer);
JqlParser parser = new JqlParser(tokens);
ParserRuleContext parseContext = parser.parse();
ParseTreeWalker walk = new ParseTreeWalker();
walk.walk(new JqlBaseListener() {
@Override
public void enterSql_stmt(Sql_stmtContext ctx) {
int start = ctx.getStart().getStartIndex();
int stop = ctx.getStop().getStopIndex() + 1;
if (start == stop)
return;
result.add(input.substring(start, stop));
}
}, parseContext);
return result;
}
use of com.abubusoft.kripton.processor.sqlite.grammars.jsql.JqlParser.Sql_stmtContext in project kripton by xcesco.
the class SQLiteUpdateTestHelper method readSQLFromFile.
public static List<String> readSQLFromFile(String sqlDefinitionFile) {
try {
final List<String> executionList = new ArrayList<>();
File f = new File(sqlDefinitionFile);
final String ddl = IOUtils.toString(new FileInputStream(f), Charset.forName("utf-8"));
MigrationSQLChecker.getInstance().analyze(ddl, new JqlBaseListener() {
public void enterSelect_stmt(Select_stmtContext ctx) {
}
public void enterSql_stmt(Sql_stmtContext ctx) {
;
int start = ctx.getStart().getStartIndex();
int stop = ctx.getStop().getStopIndex() + 1;
if (start == stop)
return;
String statement = ddl.substring(start, stop).trim();
executionList.add(statement);
}
});
return executionList;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
Aggregations