improved sql parser.

This commit is contained in:
wenshao
2017-09-01 21:58:09 +08:00
parent e0b0cca579
commit 29fbe65a77
34 changed files with 538 additions and 272 deletions
@@ -199,7 +199,11 @@ public abstract class SQLObjectImpl implements SQLObject {
}
public boolean hasAfterComment() {
List<String> comments = getAfterCommentsDirect();
if (attributes == null) {
return false;
}
List<String> comments = (List<String>) attributes.get("format.after_comment");
if (comments == null) {
return false;
}
@@ -112,7 +112,7 @@ public class SQLIdentifierExpr extends SQLExprImpl implements SQLName {
public SQLIdentifierExpr simplify() {
String normalized = SQLUtils.normalize(name);
if (normalized != name) {
return new SQLIdentifierExpr(name, hashCode64);
return new SQLIdentifierExpr(normalized, hashCode64);
}
return this;
}
@@ -284,4 +284,18 @@ public class SQLPropertyExpr extends SQLExprImpl implements SQLName {
public boolean nameEquals(String name) {
return SQLUtils.nameEquals(this.name, name);
}
public SQLPropertyExpr simplify() {
String normalizedName = SQLUtils.normalize(name);
SQLExpr normalizedOwner = this.owner;
if (normalizedOwner instanceof SQLIdentifierExpr) {
normalizedOwner = ((SQLIdentifierExpr) normalizedOwner).simplify();
}
if (normalizedName != name || normalizedOwner != owner) {
return new SQLPropertyExpr(normalizedOwner, normalizedName, hashCode64);
}
return this;
}
}