Skip to content

Commit 7aa41b4

Browse files
refactor AST to separate them into their own files (Azure#53454)
Co-authored-by: Copilot <[email protected]>
1 parent e11a233 commit 7aa41b4

34 files changed

+494
-346
lines changed

sdk/provisioning/Azure.Provisioning/src/Expressions/AST.cs

Lines changed: 0 additions & 346 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
namespace Azure.Provisioning.Expressions;
5+
6+
public class BicepProgram(params BicepStatement[] body)
7+
{
8+
public BicepStatement[] Body { get; } = body;
9+
public string? ModuleName { get; set; }
10+
public override string ToString()
11+
{
12+
BicepWriter writer = new();
13+
// if (ModuleName != null) { writer.Append("// module ").Append(ModuleName).AppendLine(); }
14+
foreach (BicepStatement statement in Body)
15+
{
16+
writer = writer.Append(statement).AppendLine();
17+
}
18+
return writer.ToString();
19+
}
20+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
namespace Azure.Provisioning.Expressions;
5+
6+
public class ArrayExpression(params BicepExpression[] values) : BicepExpression
7+
{
8+
public BicepExpression[] Values { get; } = values;
9+
internal override BicepWriter Write(BicepWriter writer)
10+
{
11+
if (Values.Length == 0)
12+
{
13+
return writer.Append("[]");
14+
}
15+
else
16+
{
17+
return writer.Append('[')
18+
.Indent(w => w.AppendLine().AppendAll(Values, (w, v) => w.Append(v), w => w./*Append(',').*/AppendLine()))
19+
.AppendLine().Append(']');
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)