refactor parser

This commit is contained in:
高铁
2021-10-03 00:59:01 +08:00
parent 46513a02a8
commit 91e1592d9d
5 changed files with 23 additions and 38 deletions
@@ -19,7 +19,7 @@ import com.alibaba.druid.sql.ast.SQLObject;
public interface SQLSelectQuery extends SQLObject {
boolean isParenthesized();
void setParenthesized(boolean paren);
void setParenthesized(boolean parenthesized);
SQLSelectQuery clone();
}
@@ -0,0 +1,19 @@
package com.alibaba.druid.sql.ast.statement;
import com.alibaba.druid.sql.ast.SQLObjectImpl;
public abstract class SQLSelectQueryBase extends SQLObjectImpl implements SQLSelectQuery {
protected boolean parenthesized;
@Override
public boolean isParenthesized() {
return parenthesized;
}
@Override
public void setParenthesized(boolean parenthesized) {
this.parenthesized = parenthesized;
}
public abstract SQLSelectQueryBase clone();
}
@@ -29,7 +29,7 @@ import java.util.Collections;
import java.util.List;
import java.util.TreeSet;
public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery, SQLReplaceable, SQLDbTypedObject {
public class SQLSelectQueryBlock extends SQLSelectQueryBase implements SQLReplaceable, SQLDbTypedObject {
protected int distionOption;
protected final List<SQLSelectItem> selectList = new ArrayList<SQLSelectItem>();
@@ -47,7 +47,6 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
protected SQLSelectGroupByClause groupBy;
protected List<SQLWindow> windows;
protected SQLOrderBy orderBy;
protected boolean parenthesized = false;
protected boolean forUpdate = false;
protected boolean noWait = false;
protected boolean skipLocked = false;
@@ -1004,16 +1003,6 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
}
}
@Override
public boolean isParenthesized() {
return parenthesized;
}
@Override
public void setParenthesized(boolean paren) {
this.parenthesized = paren;
}
public SQLTableSource findTableSource(String alias) {
if (from == null) {
return null;
@@ -27,10 +27,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class SQLUnionQuery extends SQLObjectImpl implements SQLSelectQuery, SQLDbTypedObject {
private boolean parenthesized = false;
public class SQLUnionQuery extends SQLSelectQueryBase implements SQLDbTypedObject {
private List<SQLSelectQuery> relations = new ArrayList<SQLSelectQuery>();
private SQLUnionOperator operator = SQLUnionOperator.UNION;
private SQLOrderBy orderBy;
@@ -168,14 +165,6 @@ public class SQLUnionQuery extends SQLObjectImpl implements SQLSelectQuery, SQLD
this.limit = limit;
}
public boolean isParenthesized() {
return parenthesized;
}
public void setParenthesized(boolean paren) {
this.parenthesized = paren;
}
public SQLUnionQuery clone() {
SQLUnionQuery x = new SQLUnionQuery();
@@ -23,9 +23,7 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.ArrayList;
import java.util.List;
public class SQLValuesQuery extends SQLObjectImpl implements SQLSelectQuery {
private boolean parenthesized = false;
public class SQLValuesQuery extends SQLSelectQueryBase {
private List<SQLExpr> values = new ArrayList<SQLExpr>();
public List<SQLExpr> getValues() {
@@ -45,16 +43,6 @@ public class SQLValuesQuery extends SQLObjectImpl implements SQLSelectQuery {
visitor.endVisit(this);
}
@Override
public boolean isParenthesized() {
return parenthesized;
}
@Override
public void setParenthesized(boolean paren) {
this.parenthesized = paren;
}
public SQLValuesQuery clone() {
SQLValuesQuery x = new SQLValuesQuery();
x.parenthesized = parenthesized;