improved odps sql formatter

This commit is contained in:
shaojin.wensj
2015-07-20 04:41:57 +08:00
parent 8f51368245
commit a5811a4f3e
38 changed files with 415 additions and 103 deletions
@@ -26,6 +26,8 @@ import com.alibaba.druid.sql.dialect.sqlserver.visitor.SQLServerASTVisitor;
public class SQLServerBlockStatement extends SQLServerObjectImpl implements SQLServerStatement {
private List<SQLStatement> statementList = new ArrayList<SQLStatement>();
private String dbType;
public List<SQLStatement> getStatementList() {
return statementList;
@@ -43,4 +45,11 @@ public class SQLServerBlockStatement extends SQLServerObjectImpl implements SQL
visitor.endVisit(this);
}
public String getDbType() {
return dbType;
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
}
@@ -27,6 +27,8 @@ public class SQLServerCommitStatement extends SQLServerObjectImpl implements SQL
private SQLExpr transactionName;
private SQLExpr delayedDurability;
private String dbType;
public boolean isWork() {
return work;
@@ -59,4 +61,12 @@ public class SQLServerCommitStatement extends SQLServerObjectImpl implements SQL
public void setDelayedDurability(SQLExpr delayedDurability) {
this.delayedDurability = delayedDurability;
}
public String getDbType() {
return dbType;
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
}
@@ -26,6 +26,8 @@ import com.alibaba.druid.sql.dialect.sqlserver.visitor.SQLServerASTVisitor;
public class SQLServerDeclareStatement extends SQLServerObjectImpl implements SQLServerStatement {
protected List<SQLServerDeclareItem> items = new ArrayList<SQLServerDeclareItem>();
private String dbType;
@Override
public void accept0(SQLServerASTVisitor visitor) {
@@ -43,4 +45,11 @@ public class SQLServerDeclareStatement extends SQLServerObjectImpl implements SQ
this.items = items;
}
public String getDbType() {
return dbType;
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
}
@@ -29,6 +29,7 @@ public class SQLServerExecStatement extends SQLServerObjectImpl implements SQLSe
private SQLName returnStatus;
private SQLName moduleName;
private List<SQLExpr> parameters = new ArrayList<SQLExpr>();
private String dbType;
public SQLName getModuleName() {
return moduleName;
@@ -58,4 +59,12 @@ public class SQLServerExecStatement extends SQLServerObjectImpl implements SQLSe
public void setReturnStatus(SQLName returnStatus) {
this.returnStatus = returnStatus;
}
public String getDbType() {
return dbType;
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
}
@@ -29,6 +29,7 @@ public class SQLServerIfStatement extends SQLServerObjectImpl implements SQLServ
private SQLExpr condition;
private List<SQLStatement> statements = new ArrayList<SQLStatement>();
private Else elseItem;
private String dbType;
@Override
public void accept0(SQLServerASTVisitor visitor) {
@@ -86,4 +87,11 @@ public class SQLServerIfStatement extends SQLServerObjectImpl implements SQLServ
}
public String getDbType() {
return dbType;
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
}
@@ -24,7 +24,7 @@ import com.alibaba.druid.sql.dialect.sqlserver.visitor.SQLServerASTVisitor;
public class SQLServerSetStatement extends SQLServerObjectImpl implements SQLServerStatement {
private SQLAssignItem item = new SQLAssignItem();
private String dbType;
public SQLServerSetStatement(){
}
@@ -53,4 +53,12 @@ public class SQLServerSetStatement extends SQLServerObjectImpl implements SQLSer
}
visitor.endVisit(this);
}
public String getDbType() {
return dbType;
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
}
@@ -22,6 +22,7 @@ import com.alibaba.druid.sql.dialect.sqlserver.visitor.SQLServerASTVisitor;
public class SQLServerSetTransactionIsolationLevelStatement extends SQLServerObjectImpl implements SQLServerStatement {
private String level;
private String dbType;
@Override
public void accept0(SQLServerASTVisitor visitor) {
@@ -37,4 +38,11 @@ public class SQLServerSetTransactionIsolationLevelStatement extends SQLServerObj
this.level = level;
}
public String getDbType() {
return dbType;
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
}
@@ -30,6 +30,8 @@ public class SQLServerWaitForStatement extends SQLServerObjectImpl implements SQ
private SQLStatement statement;
private SQLExpr timeout;
private String dbType;
@Override
public void accept0(SQLServerASTVisitor visitor) {
@@ -74,4 +76,11 @@ public class SQLServerWaitForStatement extends SQLServerObjectImpl implements SQ
this.timeout = timeout;
}
public String getDbType() {
return dbType;
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
}
@@ -107,7 +107,7 @@ public class SQLServerLexer extends Lexer {
token = Token.MULTI_LINE_COMMENT;
hasComment = true;
if (keepComments) {
commentVal = stringVal;
addComment(stringVal);
}
}
@@ -149,7 +149,7 @@ public class SQLServerLexer extends Lexer {
token = Token.LINE_COMMENT;
hasComment = true;
if (keepComments) {
commentVal = stringVal;
addComment(stringVal);
}
endOfComment = isEOF();