Skip to content

Commit c8b397d

Browse files
authored
Add "required-properties" snippet to modules (#2658)
* Add required-properties snippet to module * Removed empty line * Fix TypeSymbol issue and update baseline for tests
1 parent b8362b1 commit c8b397d

File tree

14 files changed

+285
-16
lines changed

14 files changed

+285
-16
lines changed

src/Bicep.Core.Samples/Files/Completions/moduleObject.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@
6969
},
7070
{
7171
"label": "{}",
72-
"kind": "value",
72+
"kind": "snippet",
7373
"detail": "{}",
74+
"documentation": {
75+
"kind": "markdown",
76+
"value": "```bicep\n{\n\t\n}\n```"
77+
},
7478
"deprecated": false,
7579
"preselect": true,
76-
"sortText": "1_{}",
80+
"sortText": "2_{}",
7781
"insertTextFormat": "snippet",
7882
"insertTextMode": "adjustIndentation",
7983
"textEdit": {
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
[
2+
{
3+
"label": "for",
4+
"kind": "snippet",
5+
"detail": "for",
6+
"documentation": {
7+
"kind": "markdown",
8+
"value": "```bicep\n[for item in list: {\n\t\n}]\n```"
9+
},
10+
"deprecated": false,
11+
"preselect": false,
12+
"sortText": "1_for",
13+
"insertTextFormat": "snippet",
14+
"insertTextMode": "adjustIndentation",
15+
"textEdit": {
16+
"range": {},
17+
"newText": "[for ${2:item} in ${1:list}: {\n\t$0\n}]"
18+
}
19+
},
20+
{
21+
"label": "for-filtered",
22+
"kind": "snippet",
23+
"detail": "for-filtered",
24+
"documentation": {
25+
"kind": "markdown",
26+
"value": "```bicep\n[for (item, index) in list: if (condition) {\n\t\n}]\n```"
27+
},
28+
"deprecated": false,
29+
"preselect": false,
30+
"sortText": "1_for-filtered",
31+
"insertTextFormat": "snippet",
32+
"insertTextMode": "adjustIndentation",
33+
"textEdit": {
34+
"range": {},
35+
"newText": "[for (${2:item}, ${3:index}) in ${1:list}: if (${4:condition}) {\n\t$0\n}]"
36+
}
37+
},
38+
{
39+
"label": "for-indexed",
40+
"kind": "snippet",
41+
"detail": "for-indexed",
42+
"documentation": {
43+
"kind": "markdown",
44+
"value": "```bicep\n[for (item, index) in list: {\n\t\n}]\n```"
45+
},
46+
"deprecated": false,
47+
"preselect": false,
48+
"sortText": "1_for-indexed",
49+
"insertTextFormat": "snippet",
50+
"insertTextMode": "adjustIndentation",
51+
"textEdit": {
52+
"range": {},
53+
"newText": "[for (${2:item}, ${3:index}) in ${1:list}: {\n\t$0\n}]"
54+
}
55+
},
56+
{
57+
"label": "if",
58+
"kind": "snippet",
59+
"detail": "if",
60+
"deprecated": false,
61+
"preselect": false,
62+
"sortText": "1_if",
63+
"insertTextFormat": "snippet",
64+
"insertTextMode": "adjustIndentation",
65+
"textEdit": {
66+
"range": {},
67+
"newText": "if (${1:condition}) {\n\t$0\n}"
68+
}
69+
},
70+
{
71+
"label": "required-properties",
72+
"kind": "snippet",
73+
"detail": "Required properties",
74+
"documentation": {
75+
"kind": "markdown",
76+
"value": "```bicep\n{\n\tname: \n\tparams: {\n\t\tarrayParam: \n\t\tobjParam: {\n\t\t}\n\t\tstringParamB: \n\t}\n\t\n}\n```"
77+
},
78+
"deprecated": false,
79+
"preselect": true,
80+
"sortText": "2_required-properties",
81+
"insertTextFormat": "snippet",
82+
"insertTextMode": "adjustIndentation",
83+
"textEdit": {
84+
"range": {},
85+
"newText": "{\n\tname: $1\n\tparams: {\n\t\tarrayParam: $2\n\t\tobjParam: {\n\t\t}\n\t\tstringParamB: $3\n\t}\n\t$0\n}"
86+
}
87+
},
88+
{
89+
"label": "{}",
90+
"kind": "snippet",
91+
"detail": "{}",
92+
"documentation": {
93+
"kind": "markdown",
94+
"value": "```bicep\n{\n\t\n}\n```"
95+
},
96+
"deprecated": false,
97+
"preselect": true,
98+
"sortText": "2_{}",
99+
"insertTextFormat": "snippet",
100+
"insertTextMode": "adjustIndentation",
101+
"textEdit": {
102+
"range": {},
103+
"newText": "{\n\t$0\n}"
104+
}
105+
}
106+
]

src/Bicep.Core.Samples/Files/InvalidModules_LF/Completions/symbolsPlusX.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,6 +1671,20 @@
16711671
"newText": "moduleWithNotAttachableDecorators"
16721672
}
16731673
},
1674+
{
1675+
"label": "moduleWithPath",
1676+
"kind": "module",
1677+
"detail": "moduleWithPath",
1678+
"deprecated": false,
1679+
"preselect": false,
1680+
"sortText": "2_moduleWithPath",
1681+
"insertTextFormat": "plainText",
1682+
"insertTextMode": "adjustIndentation",
1683+
"textEdit": {
1684+
"range": {},
1685+
"newText": "moduleWithPath"
1686+
}
1687+
},
16741688
{
16751689
"label": "moduleWithSelfCycle",
16761690
"kind": "module",

src/Bicep.Core.Samples/Files/InvalidModules_LF/Completions/symbolsPlusX_if.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,6 +1671,20 @@
16711671
"newText": "moduleWithNotAttachableDecorators"
16721672
}
16731673
},
1674+
{
1675+
"label": "moduleWithPath",
1676+
"kind": "module",
1677+
"detail": "moduleWithPath",
1678+
"deprecated": false,
1679+
"preselect": false,
1680+
"sortText": "2_moduleWithPath",
1681+
"insertTextFormat": "plainText",
1682+
"insertTextMode": "adjustIndentation",
1683+
"textEdit": {
1684+
"range": {},
1685+
"newText": "moduleWithPath"
1686+
}
1687+
},
16741688
{
16751689
"label": "moduleWithSelfCycle",
16761690
"kind": "module",

src/Bicep.Core.Samples/Files/InvalidModules_LF/main.bicep

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ module moduleWithoutPath = {
1616

1717
}
1818

19+
// #completionTest(41) -> moduleBodyCompletions
20+
module moduleWithPath './moduleb.bicep' =
21+
1922
// missing identifier #completionTest(7) -> empty
2023
module
2124

src/Bicep.Core.Samples/Files/InvalidModules_LF/main.diagnostics.bicep

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ module moduleWithoutPath = {
2323
}
2424
//@[0:1) [BCP007 (Error)] This declaration type is not recognized. Specify a parameter, variable, resource, or output declaration. |}|
2525

26+
// #completionTest(41) -> moduleBodyCompletions
27+
module moduleWithPath './moduleb.bicep' =
28+
//@[41:41) [BCP118 (Error)] Expected the "{" character, the "[" character, or the "if" keyword at this location. ||
29+
2630
// missing identifier #completionTest(7) -> empty
2731
module
2832
//@[7:7) [BCP096 (Error)] Expected a module identifier at this location. ||

src/Bicep.Core.Samples/Files/InvalidModules_LF/main.formatted.bicep

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ module moduleWithoutPath = {
1010

1111
}
1212

13+
// #completionTest(41) -> moduleBodyCompletions
14+
module moduleWithPath './moduleb.bicep' =
15+
1316
// missing identifier #completionTest(7) -> empty
1417
module
1518

src/Bicep.Core.Samples/Files/InvalidModules_LF/main.symbols.bicep

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ module moduleWithoutPath = {
2020

2121
}
2222

23+
// #completionTest(41) -> moduleBodyCompletions
24+
module moduleWithPath './moduleb.bicep' =
25+
//@[7:21) Module moduleWithPath. Type: module. Declaration start char: 0, length: 41
26+
2327
// missing identifier #completionTest(7) -> empty
2428
module
2529
//@[7:7) Module <missing>. Type: error. Declaration start char: 0, length: 7

src/Bicep.Core.Samples/Files/InvalidModules_LF/main.syntax.bicep

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,19 @@ module moduleWithoutPath = {
6767
//@[0:1) RightBrace |}|
6868
//@[1:3) NewLine |\n\n|
6969

70+
// #completionTest(41) -> moduleBodyCompletions
71+
//@[47:48) NewLine |\n|
72+
module moduleWithPath './moduleb.bicep' =
73+
//@[0:41) ModuleDeclarationSyntax
74+
//@[0:6) Identifier |module|
75+
//@[7:21) IdentifierSyntax
76+
//@[7:21) Identifier |moduleWithPath|
77+
//@[22:39) StringSyntax
78+
//@[22:39) StringComplete |'./moduleb.bicep'|
79+
//@[40:41) Assignment |=|
80+
//@[41:41) SkippedTriviaSyntax
81+
//@[41:43) NewLine |\n\n|
82+
7083
// missing identifier #completionTest(7) -> empty
7184
//@[49:50) NewLine |\n|
7285
module

src/Bicep.Core.Samples/Files/InvalidModules_LF/main.tokens.bicep

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ module moduleWithoutPath = {
4949
//@[0:1) RightBrace |}|
5050
//@[1:3) NewLine |\n\n|
5151

52+
// #completionTest(41) -> moduleBodyCompletions
53+
//@[47:48) NewLine |\n|
54+
module moduleWithPath './moduleb.bicep' =
55+
//@[0:6) Identifier |module|
56+
//@[7:21) Identifier |moduleWithPath|
57+
//@[22:39) StringComplete |'./moduleb.bicep'|
58+
//@[40:41) Assignment |=|
59+
//@[41:43) NewLine |\n\n|
60+
5261
// missing identifier #completionTest(7) -> empty
5362
//@[49:50) NewLine |\n|
5463
module

0 commit comments

Comments
 (0)