-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathSqlScriptGeneratorVisitor.IfStatement.cs
More file actions
35 lines (31 loc) · 1.28 KB
/
SqlScriptGeneratorVisitor.IfStatement.cs
File metadata and controls
35 lines (31 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//------------------------------------------------------------------------------
// <copyright file="SqlScriptGeneratorVisitor.IfStatement.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace Microsoft.SqlServer.TransactSql.ScriptDom.ScriptGenerator
{
partial class SqlScriptGeneratorVisitor
{
public override void ExplicitVisit(IfStatement node)
{
AlignmentPoint branchStatements = new AlignmentPoint();
GenerateKeyword(TSqlTokenType.If);
GenerateSpaceAndFragmentIfNotNull(node.Predicate);
NewLineAndIndent();
MarkAndPushAlignmentPoint(branchStatements);
GenerateStatementWithSemiColon(node.ThenStatement);
PopAlignmentPoint();
if (node.ElseStatement != null)
{
NewLine();
GenerateKeyword(TSqlTokenType.Else);
NewLineAndIndent();
MarkAndPushAlignmentPoint(branchStatements);
GenerateStatementWithSemiColon(node.ElseStatement);
PopAlignmentPoint();
}
}
}
}