internal SqlProcedureDefinitionFormatter(FormatterVisitor visitor, SqlProcedureDefinition codeObject) : base(visitor, codeObject) { NewLineSeparatedListFormatter = new NewLineSeparatedListFormatter(visitor, codeObject, true); CommaSeparatedListFormatter = new CommaSeparatedListFormatter(visitor, codeObject, true); foundTokenWith = false; }
public override ASTNodeFormatter Create(FormatterVisitor visitor, SqlCodeObject codeObject) { Validate.IsNotNull(nameof(visitor), visitor); Validate.IsNotNull(nameof(codeObject), codeObject); return(DoCreate(visitor, codeObject as T)); }
public ASTNodeFormatterT(FormatterVisitor visitor, T codeObject) { Validate.IsNotNull(nameof(visitor), visitor); Validate.IsNotNull(nameof(codeObject), codeObject); Visitor = visitor; CodeObject = codeObject; }
private void DoFormat(string input, FormatOptions options, bool verifyOutput, Action <FormatterVisitor> postFormatAction) { Validate.IsNotNull(nameof(input), input); Validate.IsNotNull(nameof(options), options); ParseResult result = Parser.Parse(input); FormatContext context = new FormatContext(result.Script, options); FormatterVisitor visitor = new FormatterVisitor(context, ServiceProvider); result.Script.Accept(visitor); if (verifyOutput) { visitor.VerifyFormat(); } postFormatAction?.Invoke(visitor); }
public SqlTableDefinitionFormatter(FormatterVisitor visitor, SqlTableDefinition codeObject) : base(visitor, codeObject) { CommaSeparatedListFormatter = new CommaSeparatedListFormatter(visitor, codeObject, true); // figure out the size of paddings required to align column definitions in a "columnar" form if (FormatOptions.AlignColumnDefinitionsInColumns) { int range1MaxLength = 0; int range2MaxLength = 0; foreach (SqlCodeObject child in CodeObject.Children) { if (child is SqlColumnDefinition && !(child is SqlComputedColumnDefinition)) { SqlIdentifier identifierChild = child.Children.ElementAtOrDefault(0) as SqlIdentifier; if (identifierChild == null) { throw new FormatFailedException("unexpected token at index start Token Index"); } string s1 = child.TokenManager.GetText(identifierChild.Position.startTokenNumber, identifierChild.Position.endTokenNumber); range1MaxLength = Math.Max(range1MaxLength, s1.Length); SqlDataTypeSpecification dataTypeChildchild = child.Children.ElementAtOrDefault(1) as SqlDataTypeSpecification; // token "timestamp" should be ignorred if (dataTypeChildchild != null) { string s2 = child.TokenManager.GetText(dataTypeChildchild.Position.startTokenNumber, dataTypeChildchild.Position.endTokenNumber); range2MaxLength = Math.Max(range2MaxLength, s2.Length); } } } PaddedSpaceSeparatedListFormatter.ColumnSpacingFormatDefinition d1 = new PaddedSpaceSeparatedListFormatter.ColumnSpacingFormatDefinition(typeof(SqlIdentifier), typeof(SqlDataTypeSpecification), range1MaxLength + 1); PaddedSpaceSeparatedListFormatter.ColumnSpacingFormatDefinition d2 = new PaddedSpaceSeparatedListFormatter.ColumnSpacingFormatDefinition(typeof(SqlDataTypeSpecification), null, range2MaxLength + 1); List <PaddedSpaceSeparatedListFormatter.ColumnSpacingFormatDefinition> columnSpacingFormatDefinitions = new List <PaddedSpaceSeparatedListFormatter.ColumnSpacingFormatDefinition>(2); columnSpacingFormatDefinitions.Add(d1); columnSpacingFormatDefinitions.Add(d2); Visitor.Context.CurrentColumnSpacingFormatDefinitions = columnSpacingFormatDefinitions; } }
internal SqlBinaryBooleanExpressionFormatter(FormatterVisitor visitor, SqlBinaryBooleanExpression codeObject) : base(visitor, codeObject) { SpaceSeparatedListFormatter = new SpaceSeparatedListFormatter(visitor, codeObject, true); }
protected override ASTNodeFormatter DoCreate(FormatterVisitor visitor, SqlBinaryBooleanExpression codeObject) { return(new SqlBinaryBooleanExpressionFormatter(visitor, codeObject)); }
internal SqlQuerySpecificationFormatter(FormatterVisitor visitor, SqlQuerySpecification codeObject) : base(visitor, codeObject) { WhiteSpaceSeparatedListFormatter = new NewLineSeparatedListFormatter(visitor, codeObject, false); }
protected override ASTNodeFormatter DoCreate(FormatterVisitor visitor, SqlInsertSpecification codeObject) { return(new SqlInsertSpecificationFormatter(visitor, codeObject)); }
public abstract ASTNodeFormatter Create(FormatterVisitor visitor, SqlCodeObject codeObject);
protected override ASTNodeFormatter DoCreate(FormatterVisitor visitor, SqlCommonTableExpression codeObject) { return(new SqlCommonTableExpressionFormatter(visitor, codeObject)); }
protected override ASTNodeFormatter DoCreate(FormatterVisitor visitor, SqlCompoundStatement codeObject) { return(new SqlCompoundStatementFormatter(visitor, codeObject)); }
public NewLineSeparatedListFormatter(FormatterVisitor visitor, SqlCodeObject codeObject, bool incrementIndentLevelOnPrefixRegion) : base(visitor, codeObject, incrementIndentLevelOnPrefixRegion) { }
internal PaddedSpaceSeparatedListFormatter(FormatterVisitor visitor, SqlCodeObject codeObject, List <ColumnSpacingFormatDefinition> spacingDefinitions, bool incrementIndentLevelOnPrefixRegion) : base(visitor, codeObject, incrementIndentLevelOnPrefixRegion) { ColumnSpacingDefinitions = spacingDefinitions; }
internal SqlDataTypeFormatter(FormatterVisitor visitor, SqlDataType codeObject) : base(visitor, codeObject) { }
protected override ASTNodeFormatter DoCreate(FormatterVisitor visitor, SqlDataType codeObject) { return(new SqlDataTypeFormatter(visitor, codeObject)); }
public SqlQueryWithClauseFormatter(FormatterVisitor visitor, SqlQueryWithClause codeObject) : base(visitor, codeObject, true) { }
protected override ASTNodeFormatter DoCreate(FormatterVisitor visitor, SqlSelectClause codeObject) { return(new SqlSelectClauseFormatter(visitor, codeObject)); }
internal SqlSelectClauseFormatter(FormatterVisitor visitor, SqlSelectClause codeObject) : base(visitor, codeObject, visitor.Context.FormatOptions.PlaceEachReferenceOnNewLineInQueryStatements) { NewLineSeparatedListFormatter = new NewLineSeparatedListFormatter(visitor, codeObject, true); }
internal SqlQualifiedJoinTableExpressionFormatter(FormatterVisitor visitor, SqlQualifiedJoinTableExpression codeObject) : base(visitor, codeObject) { SpaceSeparatedListFormatter = new SpaceSeparatedListFormatter(visitor, codeObject, false); }
internal SqlCompoundStatementFormatter(FormatterVisitor visitor, SqlCompoundStatement codeObject) : base(visitor, codeObject, true) { }
protected override ASTNodeFormatter DoCreate(FormatterVisitor visitor, SqlColumnDefinition codeObject) { return(new SqlColumnDefinitionFormatter(visitor, codeObject)); }
public SqlCommonTableExpressionFormatter(FormatterVisitor visitor, SqlCommonTableExpression codeObject) : base(visitor, codeObject) { }
protected abstract ASTNodeFormatter DoCreate(FormatterVisitor visitor, T codeObject);
internal SqlColumnDefinitionFormatter(FormatterVisitor visitor, SqlColumnDefinition codeObject) : base(visitor, codeObject) { SpaceSeparatedListFormatter = new PaddedSpaceSeparatedListFormatter(visitor, codeObject, Visitor.Context.CurrentColumnSpacingFormatDefinitions, true); }
internal SqlInsertSpecificationFormatter(FormatterVisitor visitor, SqlInsertSpecification codeObject) : base(visitor, codeObject) { }
internal CommaSeparatedListFormatter(FormatterVisitor visitor, SqlCodeObject codeObject, bool placeEachElementOnNewLine) : base(visitor, codeObject) { PlaceEachElementOnNewLine = placeEachElementOnNewLine; }
internal SqlBinaryQueryExpressionFormatter(FormatterVisitor visitor, SqlBinaryQueryExpression codeObject) : base(visitor, codeObject) { }
public SqlTableConstructorExpressionFormatter(FormatterVisitor visitor, SqlTableConstructorExpression codeObject) : base(visitor, codeObject, true) { }
internal SqlCreateProcedureStatementFormatter(FormatterVisitor visitor, SqlCreateProcedureStatement codeObject) : base(visitor, codeObject, false) { }