in fastmodel-transform/fastmodel-transform-postgresql/src/main/java/com/aliyun/fastmodel/transform/postgresql/parser/PostgreSQLParserBase.java [33:78]
public void ParseRoutineBody(PostgreSQLParser.Createfunc_opt_listContext _localctx) {
String lang = null;
for (PostgreSQLParser.Createfunc_opt_itemContext coi : _localctx.createfunc_opt_item()) {
if (coi.LANGUAGE() != null) {
if (coi.nonreservedword_or_sconst() != null) {
if (coi.nonreservedword_or_sconst().nonreservedword() != null) {
if (coi.nonreservedword_or_sconst().nonreservedword().identifier() != null) {
if (coi.nonreservedword_or_sconst().nonreservedword().identifier()
.Identifier() != null) {
lang = coi.nonreservedword_or_sconst().nonreservedword().identifier()
.Identifier().getText();
break;
}
}
}
}
}
}
if (null == lang) {return;}
PostgreSQLParser.Createfunc_opt_itemContext func_as = null;
for (PostgreSQLParser.Createfunc_opt_itemContext a : _localctx.createfunc_opt_item()) {
if (a.func_as() != null) {
func_as = a;
break;
}
}
if (func_as != null) {
String txt = GetRoutineBodyString(func_as.func_as().sconst(0));
int line = func_as.func_as().sconst(0).start.getLine();
PostgreSQLParser ph = getPostgreSQLParser(txt);
switch (lang) {
case "plpgsql":
func_as.func_as().Definition = ph.plsqlroot();
break;
case "sql":
func_as.func_as().Definition = ph.root();
break;
}
for (PostgreSQLParseError err : ph.ParseErrors) {
ParseErrors.add(new PostgreSQLParseError(err.getNumber(), err.getOffset(), err.getLine() + line, err.getColumn(), err.getMessage()));
}
}
}