improved odps sql formatter

This commit is contained in:
shaojin.wensj
2015-07-20 06:02:49 +08:00
parent a5811a4f3e
commit eb24ee61fc
16 changed files with 181 additions and 44 deletions
@@ -112,7 +112,6 @@ public class OdpsLexer extends Lexer {
} else {
stringVal = subString(mark, bufPos + 1);
token = Token.MULTI_LINE_COMMENT;
hasComment = true;
if (keepComments) {
addComment(stringVal);
}
@@ -160,9 +159,8 @@ public class OdpsLexer extends Lexer {
bufPos++;
}
stringVal = subString(mark, bufPos);
stringVal = subString(mark, ch != EOI ? bufPos : bufPos + 1);
token = Token.LINE_COMMENT;
hasComment = true;
if (keepComments) {
addComment(stringVal);
}
@@ -450,6 +450,10 @@ public class OdpsOutputVisitor extends SQLASTOutputVisitor implements OdpsASTVis
if (x.getWhere() != null) {
println();
print("WHERE ");
if (x.getWhere().hasBeforeComment() && isPrettyFormat()) {
printlnComments(x.getWhere().getBeforeCommentsDirect());
}
x.getWhere().setParent(x);
x.getWhere().accept(this);
if (x.getWhere().hasAfterComment() && isPrettyFormat()) {