From 7214ab5070e4bf12c5e50e1dcccd97f067bb37c2 Mon Sep 17 00:00:00 2001 From: niu niu Date: Mon, 18 Sep 2023 12:09:12 +0800 Subject: [PATCH] Format OracleStatementParser import class --- .../statement/OracleStatementVisitor.java | 19 ++++++++++------ .../type/OracleDDLStatementVisitor.java | 22 ++++++++++++------- .../type/OracleDMLStatementVisitor.java | 10 +++++---- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementVisitor.java b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementVisitor.java index c9629fe1213ca..4854c9107f0c5 100644 --- a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementVisitor.java +++ b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/OracleStatementVisitor.java @@ -25,7 +25,6 @@ import org.apache.shardingsphere.infra.database.core.metadata.database.enums.NullsOrderType; import org.apache.shardingsphere.sql.parser.api.ASTNode; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementBaseVisitor; -import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AggregationFunctionContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AnalyticFunctionContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.BitExprContext; @@ -33,6 +32,8 @@ import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.BooleanLiteralsContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.BooleanPrimaryContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CastFunctionContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CaseExpressionContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CaseWhenContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CharFunctionContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ColumnNameContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ColumnNamesContext; @@ -45,6 +46,7 @@ import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DatetimeExprContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ExprContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ExtractFunctionContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ExprListContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.FeatureFunctionContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.FirstOrLastValueFunctionContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.FormatFunctionContext; @@ -69,13 +71,16 @@ import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.PrivateExprOfDbContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.RegularFunctionContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.SchemaNameContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.SetFunctionContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.SimpleExprContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.SpecialFunctionContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.StringLiteralsContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.SynonymNameContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.TableNameContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.TableNamesContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ToDateFunctionContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.TrimFunctionContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.TranslateFunctionContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.TypeNameContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.UnreservedWordContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ViewNameContext; @@ -604,11 +609,11 @@ private ASTNode visitRemainSimpleExpr(final SimpleExprContext ctx, final int sta } @Override - public ASTNode visitCaseExpression(final OracleStatementParser.CaseExpressionContext ctx) { + public ASTNode visitCaseExpression(final CaseExpressionContext ctx) { ExpressionSegment caseExpr = null == ctx.simpleExpr() ? null : (ExpressionSegment) visit(ctx.simpleExpr()); Collection whenExprs = new ArrayList<>(ctx.caseWhen().size()); Collection thenExprs = new ArrayList<>(ctx.caseWhen().size()); - for (OracleStatementParser.CaseWhenContext each : ctx.caseWhen()) { + for (CaseWhenContext each : ctx.caseWhen()) { whenExprs.add((ExpressionSegment) visit(each.expr(0))); thenExprs.add((ExpressionSegment) visit(each.expr(1))); } @@ -906,7 +911,7 @@ public ASTNode visitXmlIsSchemaValidFunction(final XmlIsSchemaValidFunctionConte return result; } - private Collection getExpressions(final OracleStatementParser.ExprListContext exprList) { + private Collection getExpressions(final ExprListContext exprList) { if (null == exprList) { return Collections.emptyList(); } @@ -980,12 +985,12 @@ public ASTNode visitCursorFunction(final CursorFunctionContext ctx) { } @Override - public ASTNode visitToDateFunction(final OracleStatementParser.ToDateFunctionContext ctx) { + public ASTNode visitToDateFunction(final ToDateFunctionContext ctx) { return new FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.TO_DATE().getText(), getOriginalText(ctx)); } @Override - public final ASTNode visitTranslateFunction(final OracleStatementParser.TranslateFunctionContext ctx) { + public final ASTNode visitTranslateFunction(final TranslateFunctionContext ctx) { FunctionSegment result = new FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.TRANSLATE().getText(), getOriginalText(ctx)); result.getParameters().add((ExpressionSegment) visit(ctx.expr())); TerminalNode charSet = null == ctx.NCHAR_CS() ? ctx.CHAR_CS() : ctx.NCHAR_CS(); @@ -994,7 +999,7 @@ public final ASTNode visitTranslateFunction(final OracleStatementParser.Translat } @Override - public final ASTNode visitSetFunction(final OracleStatementParser.SetFunctionContext ctx) { + public final ASTNode visitSetFunction(final SetFunctionContext ctx) { FunctionSegment result = new FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.SET().getText(), getOriginalText(ctx)); result.getParameters().add((ExpressionSegment) visit(ctx.expr())); return result; diff --git a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDDLStatementVisitor.java b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDDLStatementVisitor.java index 84357ff0e2a73..926dba4f3d2b7 100644 --- a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDDLStatementVisitor.java +++ b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDDLStatementVisitor.java @@ -19,7 +19,6 @@ import org.apache.shardingsphere.sql.parser.api.ASTNode; import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.DDLStatementVisitor; -import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AddColumnSpecificationContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AddConstraintSpecificationContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AlterAnalyticViewContext; @@ -95,7 +94,9 @@ import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CreateSynonymContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CreateTableContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CreateTablespaceContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CreateTypeContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.CreateViewContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DataTypeDefinitionContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DisassociateStatisticsContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DropClusterContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.DropColumnClauseContext; @@ -145,7 +146,11 @@ import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ModifyColPropertiesContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ModifyColumnSpecificationContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ModifyConstraintClauseContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.NestedTableTypeSpecContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.NoAuditContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ObjectBaseTypeDefContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ObjectSubTypeDefContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ObjectTypeDefContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.OperateColumnClauseContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.OutOfLineConstraintContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.OutOfLineRefConstraintContext; @@ -157,6 +162,7 @@ import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.TableNameContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.TruncateTableContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.TypeNameContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.VarrayTypeSpecContext; import org.apache.shardingsphere.sql.parser.oracle.visitor.statement.OracleStatementVisitor; import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.AlterDefinitionSegment; import org.apache.shardingsphere.sql.parser.sql.common.segment.ddl.CreateDefinitionSegment; @@ -335,12 +341,12 @@ public ASTNode visitCreateTable(final CreateTableContext ctx) { } @Override - public ASTNode visitCreateType(final OracleStatementParser.CreateTypeContext ctx) { + public ASTNode visitCreateType(final CreateTypeContext ctx) { boolean isReplace = null != ctx.REPLACE(); boolean isEditionable = null == ctx.NONEDITIONABLE(); TypeSegment typeSegment = (TypeSegment) visit(ctx.plsqlTypeSource().typeName()); if (null != ctx.plsqlTypeSource().objectSubTypeDef()) { - OracleStatementParser.ObjectSubTypeDefContext objectSubTypeDefContext = ctx.plsqlTypeSource().objectSubTypeDef(); + ObjectSubTypeDefContext objectSubTypeDefContext = ctx.plsqlTypeSource().objectSubTypeDef(); return new OracleCreateSubTypeStatement(isReplace, isEditionable, null == objectSubTypeDefContext.finalClause() || null == objectSubTypeDefContext.finalClause().NOT(), null == objectSubTypeDefContext.instantiableClause() || null == objectSubTypeDefContext.instantiableClause().NOT(), @@ -351,15 +357,15 @@ public ASTNode visitCreateType(final OracleStatementParser.CreateTypeContext ctx } } - private ASTNode visitCreateTypeObjectBaseTypeDef(final OracleStatementParser.ObjectBaseTypeDefContext ctx, final boolean isReplace, final boolean isEditionable, final TypeSegment typeSegment) { + private ASTNode visitCreateTypeObjectBaseTypeDef(final ObjectBaseTypeDefContext ctx, final boolean isReplace, final boolean isEditionable, final TypeSegment typeSegment) { if (null != ctx.objectTypeDef()) { - OracleStatementParser.ObjectTypeDefContext objectTypeDefContext = ctx.objectTypeDef(); + ObjectTypeDefContext objectTypeDefContext = ctx.objectTypeDef(); return new OracleCreateObjectTypeStatement(isReplace, isEditionable, null == objectTypeDefContext.finalClause() || null == objectTypeDefContext.finalClause().NOT(), null == objectTypeDefContext.instantiableClause() || null == objectTypeDefContext.instantiableClause().NOT(), null == objectTypeDefContext.persistableClause() || null == objectTypeDefContext.persistableClause().NOT(), typeSegment, objectTypeDefContext.dataTypeDefinition().stream().map(definition -> (TypeDefinitionSegment) visit(definition)).collect(Collectors.toList())); } else if (null != ctx.varrayTypeSpec()) { - OracleStatementParser.VarrayTypeSpecContext varrayTypeSpecContext = ctx.varrayTypeSpec(); + VarrayTypeSpecContext varrayTypeSpecContext = ctx.varrayTypeSpec(); return new OracleCreateVarrayTypeStatement(isReplace, isEditionable, null == varrayTypeSpecContext.INTEGER_() ? -1 : Integer.parseInt(varrayTypeSpecContext.INTEGER_().getText()), null != varrayTypeSpecContext.typeSpec().NULL(), @@ -367,7 +373,7 @@ private ASTNode visitCreateTypeObjectBaseTypeDef(final OracleStatementParser.Obj typeSegment, (DataTypeSegment) visit(varrayTypeSpecContext.typeSpec().dataType())); } else { - OracleStatementParser.NestedTableTypeSpecContext nestedTableTypeSpecContext = ctx.nestedTableTypeSpec(); + NestedTableTypeSpecContext nestedTableTypeSpecContext = ctx.nestedTableTypeSpec(); return new OracleCreateNestedTableTypeStatement(isReplace, isEditionable, null != nestedTableTypeSpecContext.typeSpec().NULL(), null == nestedTableTypeSpecContext.typeSpec().persistableClause() || null == nestedTableTypeSpecContext.typeSpec().persistableClause().NOT(), @@ -377,7 +383,7 @@ private ASTNode visitCreateTypeObjectBaseTypeDef(final OracleStatementParser.Obj } @Override - public ASTNode visitDataTypeDefinition(final OracleStatementParser.DataTypeDefinitionContext ctx) { + public ASTNode visitDataTypeDefinition(final DataTypeDefinitionContext ctx) { return new TypeDefinitionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.name().getText(), (DataTypeSegment) visit(ctx.dataType())); } diff --git a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java index b11f3d12d413d..b35aa4e345c81 100644 --- a/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java +++ b/parser/sql/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/type/OracleDMLStatementVisitor.java @@ -20,7 +20,6 @@ import org.antlr.v4.runtime.misc.Interval; import org.apache.shardingsphere.sql.parser.api.ASTNode; import org.apache.shardingsphere.sql.parser.api.visitor.statement.type.DMLStatementVisitor; -import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AliasContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AssignmentValueContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.AssignmentValuesContext; @@ -64,6 +63,9 @@ import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.MergeAssignmentContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.MergeAssignmentValueContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.MergeContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.MergeColumnValueContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.MergeInsertClauseContext; +import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.MergeInsertColumnContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.MergeSetAssignmentsClauseContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.MergeUpdateClauseContext; import org.apache.shardingsphere.sql.parser.autogen.OracleStatementParser.ModelClauseContext; @@ -1225,7 +1227,7 @@ public ASTNode visitMerge(final MergeContext ctx) { @SuppressWarnings("unchecked") @Override - public ASTNode visitMergeInsertClause(final OracleStatementParser.MergeInsertClauseContext ctx) { + public ASTNode visitMergeInsertClause(final MergeInsertClauseContext ctx) { OracleInsertStatement result = new OracleInsertStatement(); if (null != ctx.mergeInsertColumn()) { result.setInsertColumns((InsertColumnsSegment) visit(ctx.mergeInsertColumn())); @@ -1240,7 +1242,7 @@ public ASTNode visitMergeInsertClause(final OracleStatementParser.MergeInsertCla } @Override - public ASTNode visitMergeInsertColumn(final OracleStatementParser.MergeInsertColumnContext ctx) { + public ASTNode visitMergeInsertColumn(final MergeInsertColumnContext ctx) { Collection columnSegments = new ArrayList<>(ctx.columnName().size()); for (ColumnNameContext each : ctx.columnName()) { if (null != each.name()) { @@ -1251,7 +1253,7 @@ public ASTNode visitMergeInsertColumn(final OracleStatementParser.MergeInsertCol } @Override - public ASTNode visitMergeColumnValue(final OracleStatementParser.MergeColumnValueContext ctx) { + public ASTNode visitMergeColumnValue(final MergeColumnValueContext ctx) { CollectionValue result = new CollectionValue<>(); List segments = new LinkedList<>(); for (ExprContext each : ctx.expr()) {