-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathSqlScriptGeneratorVisitor.ExternalFunctionStatement.cs
More file actions
62 lines (58 loc) · 2.63 KB
/
Copy pathSqlScriptGeneratorVisitor.ExternalFunctionStatement.cs
File metadata and controls
62 lines (58 loc) · 2.63 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//------------------------------------------------------------------------------
// <copyright file="SqlScriptGeneratorVisitor.CreateExternalFunctionStatement.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(CreateExternalFunctionStatement node)
{
GenerateKeyword(TSqlTokenType.Create);
GenerateExternalFunctionStatementBody(node);
}
public override void ExplicitVisit(AlterExternalFunctionStatement node)
{
GenerateKeyword(TSqlTokenType.Alter);
GenerateExternalFunctionStatementBody(node);
}
public override void ExplicitVisit(CreateOrAlterExternalFunctionStatement node)
{
GenerateKeyword(TSqlTokenType.Create);
GenerateSpaceAndKeyword(TSqlTokenType.Or);
GenerateSpaceAndKeyword(TSqlTokenType.Alter);
GenerateExternalFunctionStatementBody(node);
}
private void GenerateExternalFunctionStatementBody(ExternalFunctionStatement node)
{
GenerateSpaceAndKeyword(TSqlTokenType.Function);
GenerateSpaceAndFragmentIfNotNull(node.Name);
if (node.Parameters != null && node.Parameters.Count > 0)
{
if (_options.MultilineProcedureParametersList)
{
// Opt-in: one parameter per line, indented one level.
ListGenerationOption option = ListGenerationOption.CreateOptionFromFormattingConfig(_options);
GenerateFragmentList(node.Parameters, option);
}
else
{
// Default: unchanged single-line, parenthesized parameter list.
GenerateSpace();
GenerateParenthesisedCommaSeparatedList(node.Parameters);
}
}
if (node.ReturnType != null)
{
GenerateSpaceAndIdentifier(CodeGenerationSupporter.Returns);
GenerateSpaceAndFragmentIfNotNull(node.ReturnType);
}
GenerateSpaceAndKeyword(TSqlTokenType.As);
GenerateSpaceAndIdentifier(CodeGenerationSupporter.External);
GenerateSpaceAndKeyword(TSqlTokenType.Function);
GenerateSpaceAndFragmentIfNotNull(node.ExternalName);
}
}
}