diff --git a/.vscode/launch.json b/.vscode/launch.json index 12408974b..241c18936 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -56,7 +56,7 @@ "DISABLE_SLOW_TESTS": "0", "ECHO_OUTPUT_CHANNEL_TO_CONSOLE": "1", "BREAK_ON_ASSERT": "0", - "ALWAYS_ECHO_TEST_LOG": "1" // If 1 or true, always immediately echos test log to console; otherwise test log is only echoed after a failed testcase + "ALWAYS_ECHO_TEST_LOG": "0" // If 1 or true, always immediately echos test log to console; otherwise test log is only echoed after a failed testcase } }, // Launch extension with webpack diff --git a/test/DeploymentTemplate.CodeLenses.test.ts b/test/DeploymentTemplate.CodeLenses.test.ts index b7882ccce..8364c45d6 100644 --- a/test/DeploymentTemplate.CodeLenses.test.ts +++ b/test/DeploymentTemplate.CodeLenses.test.ts @@ -124,13 +124,13 @@ suite("DeploymentTemplate code lenses", () => { suite("parameters section code lens", () => { suite("if no parameter file then", () => { test("expect only a single parameters section code lens", async () => { - const dt = await parseTemplate(template1); + const dt = parseTemplate(template1); const lenses = dt.getCodeLenses(undefined); assert.equal(lenses.length, 1, "Expecting only a code lens for the parameters section itself"); }); test("code lens should show command to select/create one", async () => { - const dt = await parseTemplate(template1); + const dt = parseTemplate(template1); const lenses = dt.getCodeLenses(undefined); for (const lens of lenses) { const result = await lens.resolve(); @@ -147,7 +147,7 @@ suite("DeploymentTemplate code lenses", () => { suite("if there is a parameter file then", () => { test("parameter section code lens should show command to open current parameter file and one to change the selection", async () => { - const dt = await parseTemplate(template1); + const dt = parseTemplate(template1); const { dp } = await parseParametersWithMarkers({}); const lenses = dt.getCodeLenses(new FakeParameterValuesSourceProvider(dp.documentUri, dp.parameterValuesSource)); assert.equal(lenses.length, 2 + dt.topLevelScope.parameterDefinitions.length); @@ -185,7 +185,7 @@ suite("DeploymentTemplate code lenses", () => { test(testName, async () => { let a = testName; a = a; - const dt = await parseTemplate(template1); + const dt = parseTemplate(template1); const param = dt.topLevelScope.getParameterDefinition(topLevelParamName); assert(!!param); const { dp } = await parseParametersWithMarkers( @@ -286,7 +286,7 @@ suite("DeploymentTemplate code lenses", () => { function createCodeLensTest(testName: string, template: IPartialDeploymentTemplate, expected: (string | RegExp)[]): void { testWithLanguageServer(testName, async () => { testName = testName; - const dt = await parseTemplate(template); + const dt = parseTemplate(template); await ensureLanguageServerAvailable(); diff --git a/test/DeploymentTemplate.test.ts b/test/DeploymentTemplate.test.ts index 4dadece5e..f620975b0 100644 --- a/test/DeploymentTemplate.test.ts +++ b/test/DeploymentTemplate.test.ts @@ -297,7 +297,7 @@ suite("DeploymentTemplate", () => { }); test("with one user function where function name matches a built-in function name", async () => { - await parseTemplate( + parseTemplate( // tslint:disable-next-line:no-any { "name": "[contoso.reference()]", // This is not a call to the built-in "reference" function @@ -413,7 +413,7 @@ suite("DeploymentTemplate", () => { } }; - await parseTemplate(template, []); + parseTemplate(template, []); }); test("with reference() call inside a different expression in a variable definition", () => { @@ -1118,7 +1118,7 @@ ${err}`); test("https://github.com/Microsoft/vscode-azurearmtools/issues/193", async () => { // Just make sure nothing throws let modifiedTemplate = template.replace('"type": "string"', '"type": string'); - let dt = await parseTemplate(modifiedTemplate); + let dt = parseTemplate(modifiedTemplate); findReferences(dt, DefinitionKind.Parameter, "adminUsername", dt.topLevelScope); findReferences(dt, DefinitionKind.Variable, "resourceGroup", dt.topLevelScope); dt.getFunctionCounts(); @@ -1126,7 +1126,7 @@ ${err}`); test("Unended string", async () => { const json = "{ \""; - let dt = await parseTemplate(json); + let dt = parseTemplate(json); findReferences(dt, DefinitionKind.Parameter, "adminUsername", dt.topLevelScope); findReferences(dt, DefinitionKind.Variable, "resourceGroup", dt.topLevelScope); dt.getFunctionCounts(); @@ -1134,7 +1134,7 @@ ${err}`); test("No top-level object", async () => { const json = "\"hello\""; - let dt = await parseTemplate(json); + let dt = parseTemplate(json); findReferences(dt, DefinitionKind.Parameter, "adminUsername", dt.topLevelScope); findReferences(dt, DefinitionKind.Variable, "resourceGroup", dt.topLevelScope); dt.getFunctionCounts(); @@ -1151,7 +1151,7 @@ ${err}`); "subnetRef": "[concat(variables('vne2tId'), '/subnets/', parameters('subnetName'))]" } }`; - let dt = await parseTemplate(json); + let dt = parseTemplate(json); findReferences(dt, DefinitionKind.Parameter, "adminUsername", dt.topLevelScope); findReferences(dt, DefinitionKind.Variable, "resourceGroup", dt.topLevelScope); dt.getFunctionCounts(); @@ -1168,7 +1168,7 @@ ${err}`); "subnetRef": "[concat(variables('vne2tId'), '/subnets/', parameters('subnetName'))]" } }`; - let dt = await parseTemplate(json); + let dt = parseTemplate(json); findReferences(dt, DefinitionKind.Parameter, "adminUsername", dt.topLevelScope); findReferences(dt, DefinitionKind.Variable, "resourceGroup", dt.topLevelScope); dt.getFunctionCounts(); @@ -1183,7 +1183,7 @@ ${err}`); // Just make sure nothing throws for (let i = 0; i < template.length; ++i) { let partialTemplate = template.slice(0, i); - let dt = await parseTemplate(partialTemplate); + let dt = parseTemplate(partialTemplate); findReferences(dt, DefinitionKind.Parameter, "adminUsername", dt.topLevelScope); findReferences(dt, DefinitionKind.Variable, "resourceGroup", dt.topLevelScope); dt.getFunctionCounts(); @@ -1201,7 +1201,7 @@ ${err}`); // Just make sure nothing throws for (let i = 0; i < template.length; ++i) { let partialTemplate = template.slice(i); - let dt = await parseTemplate(partialTemplate); + let dt = parseTemplate(partialTemplate); findReferences(dt, DefinitionKind.Parameter, "adminUsername", dt.topLevelScope); findReferences(dt, DefinitionKind.Variable, "resourceGroup", dt.topLevelScope); dt.getFunctionCounts(); @@ -1220,7 +1220,7 @@ ${err}`); for (let i = 0; i < template.length; ++i) { // Remove the single character at position i let partialTemplate = template.slice(0, i) + template.slice(i + 1); - let dt = await parseTemplate(partialTemplate); + let dt = parseTemplate(partialTemplate); findReferences(dt, DefinitionKind.Parameter, "adminUsername", dt.topLevelScope); findReferences(dt, DefinitionKind.Variable, "resourceGroup", dt.topLevelScope); dt.getFunctionCounts(); @@ -1265,13 +1265,13 @@ ${err}`); let dt: DeploymentTemplateDoc; try { - dt = await parseTemplate(modifiedTemplate); + dt = parseTemplate(modifiedTemplate); } catch (err) { if (parseError(err).message.includes('Malformed marker')) { // We messed up the markers in the template (testcase issue). Revert this modification and try again // next loop modifiedTemplate = previousTemplate; - dt = await parseTemplate(modifiedTemplate); + dt = parseTemplate(modifiedTemplate); } else { // Valid failure throw err; @@ -1289,7 +1289,7 @@ ${err}`); suite("getMultilineStringCount", () => { test("TLE strings", async () => { - const dt = await parseTemplate(`{ + const dt = parseTemplate(`{ "abc": "[abc def]", "xyz": "[xyz @@ -1299,7 +1299,7 @@ ${err}`); }); test("JSON strings", async () => { - const dt = await parseTemplate(`{ + const dt = parseTemplate(`{ "abc": "abc def" }`); @@ -1307,7 +1307,7 @@ ${err}`); }); test("don't count escaped \\n, \\r", async () => { - const dt = await parseTemplate(`{ + const dt = parseTemplate(`{ "abc": "abc\\r\\ndef" }`); assert.equal(dt.getMultilineStringCount(), 0); @@ -1317,7 +1317,7 @@ ${err}`); suite("getMaxLineLength", () => { test("getMaxLineLength", async () => { - const dt = await parseTemplate(`{ + const dt = parseTemplate(`{ //345678 //345678901234567890 //345 @@ -1333,7 +1333,7 @@ ${err}`); suite("getCommentsCount()", () => { test("no comments", async () => { // tslint:disable-next-line:no-any - const dt = await parseTemplate({ + const dt = parseTemplate({ "$schema": "foo", "contentVersion": "1.2.3 /*not a comment*/", "whoever": "1.2.3 //not a comment" @@ -1344,7 +1344,7 @@ ${err}`); test("block comments", async () => { // tslint:disable-next-line:no-any - const dt = await parseTemplate(`{ + const dt = parseTemplate(`{ "$schema": "foo", /* This is a comment */ @@ -1357,7 +1357,7 @@ ${err}`); test("single-line comments", async () => { // tslint:disable-next-line:no-any - const dt = await parseTemplate(`{ + const dt = parseTemplate(`{ "$schema": "foo", // This is a comment "contentVersion": "1.2.3", // Another comment "whoever": "1.2.3" // This is a comment @@ -1369,14 +1369,14 @@ ${err}`); suite("apiProfile", () => { test("no apiProfile", async () => { - const dt = await parseTemplate({ + const dt = parseTemplate({ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#" }); assert.equal(dt.apiProfile, undefined); }); test("empty apiProfile", async () => { - const dt = await parseTemplate({ + const dt = parseTemplate({ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", apiProfile: "" }); @@ -1386,7 +1386,7 @@ ${err}`); test("non-string apiProfile", async () => { // tslint:disable-next-line: no-any - const dt = await parseTemplate({ + const dt = parseTemplate({ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", apiProfile: false }); @@ -1395,7 +1395,7 @@ ${err}`); }); test("valid apiProfile", async () => { - const dt = await parseTemplate({ + const dt = parseTemplate({ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "apiProfile": "2018–03-01-hybrid" }); @@ -1407,7 +1407,7 @@ ${err}`); suite("getDocumentPosition", () => { function createGetDocumentPositionTest(json: string, index: number, expectedPosition: LineColPos): void { test(`${JSON.stringify(json)}, index=${index}`, async () => { - const dt = await parseTemplate(json); + const dt = parseTemplate(json); const pos: LineColPos = dt.getDocumentPosition(index); assert.deepEqual(pos, expectedPosition); }); diff --git a/test/NestedTemplates.test.ts b/test/NestedTemplates.test.ts index 516d94104..f15db97a2 100644 --- a/test/NestedTemplates.test.ts +++ b/test/NestedTemplates.test.ts @@ -47,7 +47,7 @@ suite("Nested templates", () => { ] }; - const dt = await parseTemplate(template); + const dt = parseTemplate(template); const child = dt.topLevelScope.resources[0].childDeployment; const actualScopeKind = child?.scopeKind === TemplateScopeKind.NestedDeploymentWithInnerScope @@ -158,7 +158,7 @@ suite("Nested templates", () => { v1innerdef, v1innerref1, v1innerref2, v2innerdef, v2innerref1 } - } = await parseTemplateWithMarkers( + } = parseTemplateWithMarkers( template, [ // testMessages.nestedTemplateNoValidation("nested"), @@ -260,7 +260,7 @@ suite("Nested templates", () => { const { dt, markers: { p1rootdef, p1rootref1, p1rootref2, p1rootref3, p1innerdef, p1innerref1, p1innerref2, p1innerref3 } - } = await parseTemplateWithMarkers(template, [ + } = parseTemplateWithMarkers(template, [ "Warning: The variable 'v1' is never used.", // testMessages.nestedTemplateNoValidation("nested"), ]); @@ -376,13 +376,13 @@ suite("Nested templates", () => { }; test("no errors", async () => { - await parseTemplateWithMarkers(template, [ + parseTemplateWithMarkers(template, [ // testMessages.nestedTemplateNoValidation("nested"), ]); }); test("inner.func1", async () => { - const { dt, markers: { innerfunc1def, innerfunc1ref1 } } = await parseTemplateWithMarkers(template); + const { dt, markers: { innerfunc1def, innerfunc1ref1 } } = parseTemplateWithMarkers(template); const innerfunc1defpc = dt.getContextFromDocumentCharacterIndex(innerfunc1def.index, undefined); const innerfunc1defRefs = innerfunc1defpc.getReferences(); assert.deepEqual( @@ -395,7 +395,7 @@ suite("Nested templates", () => { test("inner.func1.innerp1", async () => { const { dt, markers: { innerp1def, innerp1ref } - } = await parseTemplateWithMarkers(template); + } = parseTemplateWithMarkers(template); const pc = dt.getContextFromDocumentCharacterIndex(innerp1def.index, undefined); const refs = pc.getReferences(); assert.deepEqual( @@ -452,7 +452,7 @@ suite("Nested templates", () => { const { dt, markers: { v1def, v1ref1, v1ref2, v1ref3, v1ref4, v2def, v2ref1 } - } = await parseTemplateWithMarkers( + } = parseTemplateWithMarkers( template, [ "Warning: Variables, parameters and user functions of an outer-scoped nested template are inaccessible to any expressions. If you intended inner scope, set the deployment resource's properties.expressionEvaluationOptions.scope to 'inner'.", @@ -528,7 +528,7 @@ suite("Nested templates", () => { const { dt, markers: { p1def, p1ref1, p1ref2, p1ref3, p1ref4, p1ref5 } - } = await parseTemplateWithMarkers( + } = parseTemplateWithMarkers( template, [ // `11: ${testMessages.nestedTemplateNoValidation("nested")}`, @@ -614,7 +614,7 @@ suite("Nested templates", () => { }; test("no errors", async () => { - await parseTemplateWithMarkers( + parseTemplateWithMarkers( template, [ // testMessages.nestedTemplateNoValidation("nested"), @@ -622,7 +622,7 @@ suite("Nested templates", () => { }); test("root.func1", async () => { - const { dt, markers: { rootfunc1def, rootfunc1ref1, rootfunc1ref2 } } = await parseTemplateWithMarkers(template); + const { dt, markers: { rootfunc1def, rootfunc1ref1, rootfunc1ref2 } } = parseTemplateWithMarkers(template); const pc = dt.getContextFromDocumentCharacterIndex(rootfunc1def.index, undefined); const refs = pc.getReferences(); assert.deepEqual( @@ -636,7 +636,7 @@ suite("Nested templates", () => { test("root.func1.rootp1", async () => { const { dt, markers: { rootp1def, rootp1ref } - } = await parseTemplateWithMarkers(template); + } = parseTemplateWithMarkers(template); const pc = dt.getContextFromDocumentCharacterIndex(rootp1ref.index, undefined); const refs = pc.getReferences(); assert.deepEqual( @@ -649,7 +649,7 @@ suite("Nested templates", () => { }); test("errors/warnings", async () => { - await parseTemplate( + parseTemplate( 'templates/nestedTemplateScopesErrorsAndWarnings.json', [ "8: Warning: The parameter 'p2' is never used.", @@ -675,7 +675,7 @@ suite("Nested templates", () => { }); }); test("No duplicate warnings from outer scoped nested template using same scope as parent", async () => { - await parseTemplate( + parseTemplate( { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", @@ -910,7 +910,7 @@ suite("Nested templates", () => { }; test("no errors", async () => { - await parseTemplateWithMarkers( + parseTemplateWithMarkers( deeplyNestedTemplate, [ // testMessages.nestedTemplateNoValidation("inner1"), @@ -921,7 +921,7 @@ suite("Nested templates", () => { }); test("outer3 references inner2.func1 from parent scope", async () => { - const { dt, markers: { inner2func1def, inner2func1ref1, inner2func1ref2 } } = await parseTemplateWithMarkers(deeplyNestedTemplate); + const { dt, markers: { inner2func1def, inner2func1ref1, inner2func1ref2 } } = parseTemplateWithMarkers(deeplyNestedTemplate); const pc = dt.getContextFromDocumentCharacterIndex(inner2func1def.index, undefined); const refs = pc.getReferences(); assert.deepEqual( @@ -933,7 +933,7 @@ suite("Nested templates", () => { }); test("inner2.innerp2", async () => { - const { dt, markers: { inner2func1innerp2def, inner2func1innerp2ref1 } } = await parseTemplateWithMarkers(deeplyNestedTemplate); + const { dt, markers: { inner2func1innerp2def, inner2func1innerp2ref1 } } = parseTemplateWithMarkers(deeplyNestedTemplate); const pc = dt.getContextFromDocumentCharacterIndex(inner2func1innerp2def.index, undefined); const refs = pc.getReferences(); assert.deepEqual( @@ -946,7 +946,7 @@ suite("Nested templates", () => { suite("real examples", () => { testWithRealFunctionMetadata("https://github.com/Azure/azure-resource-manager-schemas/issues/994", async () => { - await parseTemplate( + parseTemplate( { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", diff --git a/test/ParameterFileGeneration.test.ts b/test/ParameterFileGeneration.test.ts index 62125177b..f3e157e0f 100644 --- a/test/ParameterFileGeneration.test.ts +++ b/test/ParameterFileGeneration.test.ts @@ -28,7 +28,7 @@ suite("parameterFileGeneration tests", () => { ], parameters: <{ [key: string]: IDeploymentParameterDefinition }>parameters }; - const dt = await parseTemplate(template); + const dt = parseTemplate(template); const paramFile = createParameterFileContents(dt.topLevelScope, 4, onlyRequiredParams); assert.equal(paramFile, expectedContents); }); @@ -63,7 +63,7 @@ suite("parameterFileGeneration tests", () => { template.parameters![parameterName] = parameterDefinition; const templateStringIndent4 = JSON.stringify(template, null, 4); - const dt = await parseTemplate(templateStringIndent4); + const dt = parseTemplate(templateStringIndent4); const foundDefinition = dt.topLevelScope.getParameterDefinition(parameterName); assert(foundDefinition); // tslint:disable-next-line:no-non-null-assertion diff --git a/test/ParentAndChildCodeLenses.test.ts b/test/ParentAndChildCodeLenses.test.ts index 81bd4ab05..af77ba9c4 100644 --- a/test/ParentAndChildCodeLenses.test.ts +++ b/test/ParentAndChildCodeLenses.test.ts @@ -19,7 +19,7 @@ suite("ParentAndChildCodeLenses", () => { expected: Expected[] ): void { test(name, async () => { - const dt = await parseTemplate(template, [], { ignoreInfos: true }); + const dt = parseTemplate(template, [], { ignoreInfos: true }); const lenses: ParentOrChildCodeLens[] = dt.getCodeLenses(undefined).filter(cl => cl instanceof ParentOrChildCodeLens) as ParentOrChildCodeLens[]; const allInfos: IJsonResourceInfo[] = []; diff --git a/test/ResourceUsage.test.ts b/test/ResourceUsage.test.ts index 7a101cd2d..739a369a5 100644 --- a/test/ResourceUsage.test.ts +++ b/test/ResourceUsage.test.ts @@ -14,7 +14,7 @@ suite("ResourceUsage (schema.stats telemetry)", () => { async function testGetResourceUsage(template: Partial, expectedResourceUsage: { [key: string]: number }): Promise { // tslint:disable-next-line:no-any - const dt = await parseTemplate(template); + const dt = parseTemplate(template); const resourceUsage: Histogram = dt.getResourceUsage(); const expected = new Histogram(); for (let propName of Object.getOwnPropertyNames(expectedResourceUsage)) { diff --git a/test/TLE.test.ts b/test/TLE.test.ts index 3a21223c4..19b0764b5 100644 --- a/test/TLE.test.ts +++ b/test/TLE.test.ts @@ -2167,7 +2167,7 @@ suite("TLE", () => { suite("visit(tle.Value,string,string)", () => { test("with undefined TLE", async () => { - const dt = await parseTemplate(template); + const dt = parseTemplate(template); const referenceListsMap = new Map(); const issues: Issue[] = []; const param = dt.topLevelScope.getParameterDefinition("pName")!; @@ -2179,7 +2179,7 @@ suite("TLE", () => { }); test("with undefined TLE", async () => { - const dt = await parseTemplate(template); + const dt = parseTemplate(template); const referenceListsMap = new Map(); const issues: Issue[] = []; const param = dt.topLevelScope.getParameterDefinition("pName")!; @@ -2192,7 +2192,7 @@ suite("TLE", () => { }); test("with TLE", async () => { - const dt = await parseTemplate(template); + const dt = parseTemplate(template); const referenceListsMap = new Map(); const issues: Issue[] = []; const param = dt.topLevelScope.getParameterDefinition("pName")!; diff --git a/test/TemplatePositionContext.completions.test.ts b/test/TemplatePositionContext.completions.test.ts index 02b0bd5e3..bfd4f3028 100644 --- a/test/TemplatePositionContext.completions.test.ts +++ b/test/TemplatePositionContext.completions.test.ts @@ -580,7 +580,7 @@ suite("TemplatePositionContext.completions", () => { suite("Variable value with array nested in object", () => { test("variables('v1').a.b.c", async () => { // Shouldn't throw - see https://github.com/microsoft/vscode-azurearmtools/issues/441 - await parseTemplate( + parseTemplate( { "variables": { "v1": { @@ -625,7 +625,7 @@ suite("TemplatePositionContext.completions", () => { templateWithReplacement = stringify(templateWithReplacement); const template = templateWithReplacement.replace(/TESTEXPRESSION/, expression); - const { dt, markers: { cursor, replstart } } = await parseTemplateWithMarkers(template); + const { dt, markers: { cursor, replstart } } = parseTemplateWithMarkers(template); // tslint:disable-next-line: strict-boolean-expressions assert(!!replstart!, "Didn't find in test expression"); // tslint:disable-next-line: strict-boolean-expressions diff --git a/test/TemplatePositionContext.test.ts b/test/TemplatePositionContext.test.ts index 6dc3d72a5..bfedac2c2 100644 --- a/test/TemplatePositionContext.test.ts +++ b/test/TemplatePositionContext.test.ts @@ -23,7 +23,7 @@ suite("TemplatePositionContext", () => { test("documentColumnIndex cannot be greater than the line's maximum index", async () => { const line = 200; const col = 11; - const dt = await parseTemplate(template); + const dt = parseTemplate(template); const pc = dt.getContextFromDocumentLineAndColumnIndexes(line, col, undefined, true); assert(pc); assert.equal(pc.documentLineIndex, 11); @@ -33,7 +33,7 @@ suite("TemplatePositionContext", () => { test("documentLineIndex cannot be greater than or equal to the deployment template's line count", async () => { const line = 7; const col = 11; - const dt = await parseTemplate(template); + const dt = parseTemplate(template); const pc = dt.getContextFromDocumentLineAndColumnIndexes(line, col, undefined, true); assert(pc); assert.equal(pc.documentLineIndex, 7); @@ -41,7 +41,7 @@ suite("TemplatePositionContext", () => { }); test("documentCharacterIndex cannot be greater than the maximum character index", async () => { - const dt = await parseTemplate(template); + const dt = parseTemplate(template); const pc = dt.getContextFromDocumentCharacterIndex(10000, undefined, true); assert(pc); assert.equal(pc.documentLineIndex, 11); @@ -199,7 +199,7 @@ suite("TemplatePositionContext", () => { } test("hyphens and exclamation points", async () => { - const dt = await parseTemplate("{ arm-keyvault!hello }"); + const dt = parseTemplate("{ arm-keyvault!hello }"); assert.equal(getTextAtReplacementSpan(dt, 0), undefined); // { assert.equal(getTextAtReplacementSpan(dt, 1), undefined); @@ -711,7 +711,7 @@ suite("TemplatePositionContext", () => { async function testUdfSignatureHelp(expressionWithCursorMarker: string, expected: TLE.FunctionSignatureHelp | undefined): Promise { const templateString = stringify(udfTemplate).replace('', expressionWithCursorMarker); - const { dt, markers: { cursor } } = await parseTemplateWithMarkers(templateString); + const { dt, markers: { cursor } } = parseTemplateWithMarkers(templateString); assert(cursor, "You must place a '' cursor in the expression string to indicate position"); const pc: TemplatePositionContext = dt.getContextFromDocumentCharacterIndex(cursor.index, undefined); const functionSignatureHelp: TLE.FunctionSignatureHelp | undefined = pc.getSignatureHelp(); @@ -979,7 +979,7 @@ suite("TemplatePositionContext", () => { suite("Templates", () => { test("Parameter reference", async () => { - const { dt, markers: { param1ref } } = await parseTemplateWithMarkers(template1); + const { dt, markers: { param1ref } } = parseTemplateWithMarkers(template1); const pc = TemplatePositionContext.fromDocumentCharacterIndex(dt, param1ref.index, undefined); const site = pc.getReferenceSiteInfo(false); assert.notEqual(site, undefined); @@ -991,7 +991,7 @@ suite("TemplatePositionContext", () => { }); test("Parameter definition", async () => { - const { dt, markers: { param1def } } = await parseTemplateWithMarkers(template1); + const { dt, markers: { param1def } } = parseTemplateWithMarkers(template1); const pc = TemplatePositionContext.fromDocumentCharacterIndex(dt, param1def.index, undefined); const site = pc.getReferenceSiteInfo(true); assert.notEqual(site, undefined); @@ -1004,7 +1004,7 @@ suite("TemplatePositionContext", () => { }); test("Variable reference", async () => { - const { dt, markers: { var1ref } } = await parseTemplateWithMarkers(template1); + const { dt, markers: { var1ref } } = parseTemplateWithMarkers(template1); const pc = TemplatePositionContext.fromDocumentCharacterIndex(dt, var1ref.index, undefined); const site = pc.getReferenceSiteInfo(false); assert.notEqual(site, undefined); @@ -1016,7 +1016,7 @@ suite("TemplatePositionContext", () => { }); test("Variable definition", async () => { - const { dt, markers: { var1def } } = await parseTemplateWithMarkers(template1); + const { dt, markers: { var1def } } = parseTemplateWithMarkers(template1); const pc = TemplatePositionContext.fromDocumentCharacterIndex(dt, var1def.index, undefined); const site = pc.getReferenceSiteInfo(true); assert.notEqual(site, undefined); @@ -1029,7 +1029,7 @@ suite("TemplatePositionContext", () => { }); test("namespace definition", async () => { - const { dt, markers: { ns1def } } = await parseTemplateWithMarkers(template1); + const { dt, markers: { ns1def } } = parseTemplateWithMarkers(template1); const pc = TemplatePositionContext.fromDocumentCharacterIndex(dt, ns1def.index, undefined); const site = pc.getReferenceSiteInfo(true); assert.notEqual(site, undefined); @@ -1042,7 +1042,7 @@ suite("TemplatePositionContext", () => { }); test("namespace reference", async () => { - const { dt, markers: { ns1ref } } = await parseTemplateWithMarkers(template1); + const { dt, markers: { ns1ref } } = parseTemplateWithMarkers(template1); const pc = TemplatePositionContext.fromDocumentCharacterIndex(dt, ns1ref.index, undefined); const site = pc.getReferenceSiteInfo(true); assert.notEqual(site, undefined); @@ -1054,7 +1054,7 @@ suite("TemplatePositionContext", () => { }); test("user function definition", async () => { - const { dt, markers: { func1def } } = await parseTemplateWithMarkers(template1); + const { dt, markers: { func1def } } = parseTemplateWithMarkers(template1); const pc = TemplatePositionContext.fromDocumentCharacterIndex(dt, func1def.index, undefined); const site = pc.getReferenceSiteInfo(true); assert.notEqual(site, undefined); @@ -1067,7 +1067,7 @@ suite("TemplatePositionContext", () => { }); test("user function reference", async () => { - const { dt, markers: { func1ref } } = await parseTemplateWithMarkers(template1); + const { dt, markers: { func1ref } } = parseTemplateWithMarkers(template1); const pc = TemplatePositionContext.fromDocumentCharacterIndex(dt, func1ref.index, undefined); const site = pc.getReferenceSiteInfo(true); assert.notEqual(site, undefined); @@ -1079,7 +1079,7 @@ suite("TemplatePositionContext", () => { }); test("built-in function reference", async () => { - const { dt, markers: { builtinref } } = await parseTemplateWithMarkers(template1); + const { dt, markers: { builtinref } } = parseTemplateWithMarkers(template1); const pc = TemplatePositionContext.fromDocumentCharacterIndex(dt, builtinref.index, undefined); const site = pc.getReferenceSiteInfo(true); assert.notEqual(site, undefined); @@ -1093,7 +1093,7 @@ suite("TemplatePositionContext", () => { suite("Parameter files", () => { test("Deployment parameter file parameter definition", async () => { - const { dt } = await parseTemplateWithMarkers(template1); + const { dt } = parseTemplateWithMarkers(template1); const { dp, markers: { param1def } } = await parseParametersWithMarkers(params1); const ppc = ParametersPositionContext.fromDocumentCharacterIndex(dp, param1def.index, dt); const site = ppc.getReferenceSiteInfo(true); diff --git a/test/UserFunctions.test.ts b/test/UserFunctions.test.ts index 0c0a6cee4..2bab8eaa8 100644 --- a/test/UserFunctions.test.ts +++ b/test/UserFunctions.test.ts @@ -123,7 +123,7 @@ suite("User functions", () => { ] }; - const dt = await parseTemplate(template, [ + const dt = parseTemplate(template, [ "Error: Undefined parameter reference: 'number'" ]); assert.equal(0, dt.topLevelScope.namespaceDefinitions.length); @@ -153,7 +153,7 @@ suite("User functions", () => { } ]`; - const dt = await parseTemplate(template, [ + const dt = parseTemplate(template, [ ]); assert.equal(0, dt.topLevelScope.namespaceDefinitions.length); }); @@ -188,7 +188,7 @@ suite("User functions", () => { }] }; - await parseTemplate(template, [ + parseTemplate(template, [ "Warning: The parameter 'param1' is never used.", 'Warning: The user-defined function \'udf.(none)\' is never used.' ]); @@ -218,7 +218,7 @@ suite("User functions", () => { "resources": [] }; - await parseTemplate(template, [ + parseTemplate(template, [ 'Warning: The user-defined function \'(none).odd\' is never used.' ]); }); @@ -252,7 +252,7 @@ suite("User functions", () => { }] }; - await parseTemplate(template, [ + parseTemplate(template, [ "Warning: The parameter 'param1' is never used.", 'Warning: The user-defined function \'(none).odd\' is never used.' ]); @@ -283,7 +283,7 @@ suite("User functions", () => { }]; // tslint:disable-next-line:no-any - const dt = await parseTemplate(template, [ + const dt = parseTemplate(template, [ ]); assert.equal(0, dt.topLevelScope.namespaceDefinitions.length); }); @@ -312,7 +312,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, []); + parseTemplate(template, []); }); test("function definition with local parameter reference in output", async () => { @@ -340,7 +340,7 @@ suite("User functions", () => { ] }; - await parseTemplate(template, [ + parseTemplate(template, [ 'Warning: The user-defined function \'udf.odd\' is never used.' ]); }); @@ -372,7 +372,7 @@ suite("User functions", () => { ] }; - const dt = await parseTemplate(template); + const dt = parseTemplate(template); assert.equal(dt.topLevelScope.parameterDefinitions.length, 0); assert(!dt.topLevelScope.getParameterDefinition('notfound')); assert.equal(dt.topLevelScope.namespaceDefinitions.length, 1); @@ -406,7 +406,7 @@ suite("User functions", () => { }] }; - await parseTemplate(template, [ + parseTemplate(template, [ 'Warning: The user-defined function \'udf.odd\' is never used.' ]); }); @@ -440,7 +440,7 @@ suite("User functions", () => { }] }; - await parseTemplate( + parseTemplate( template, [ "Error: Undefined parameter reference: 'outerParam'" @@ -477,7 +477,7 @@ suite("User functions", () => { } }; - await parseTemplate( + parseTemplate( template, [ "Error: User functions cannot reference variables" @@ -516,7 +516,7 @@ suite("User functions", () => { }] }; - await parseTemplate( + parseTemplate( template, [ "Error: Undefined parameter reference: 'outerParam'" @@ -549,7 +549,7 @@ suite("User functions", () => { }] }; - await parseTemplate(template, [ + parseTemplate(template, [ 'Warning: The user-defined function \'udf.odd\' is never used.' ]); }); @@ -584,7 +584,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, []); + parseTemplate(template, []); }); test("Calling function with no parameters", async () => { @@ -613,7 +613,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, []); + parseTemplate(template, []); }); test("Calling function with no parameters, with extra arg", async () => { @@ -642,7 +642,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, [ + parseTemplate(template, [ 'Error: The function \'udf.nothing\' takes 0 arguments.' ]); }); @@ -669,7 +669,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, [ + parseTemplate(template, [ 'Error: Unrecognized function name \'boo\' in user-defined namespace \'udf\'.', 'Warning: The user-defined function \'udf.hoo\' is never used.' ]); @@ -697,7 +697,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, [ + parseTemplate(template, [ 'Error: Unrecognized user-defined function namespace \'ufo\'.', 'Warning: The user-defined function \'udf.boo\' is never used.' ]); @@ -725,7 +725,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, [ + parseTemplate(template, [ 'Error: Missing function argument list.' ]); }); @@ -752,7 +752,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, [ + parseTemplate(template, [ 'Error: Unrecognized user-defined function namespace \'ufo\'.', 'Error: Expected a right parenthesis (\')\').', 'Warning: The user-defined function \'udf.boo\' is never used.' @@ -809,7 +809,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, []); + parseTemplate(template, []); }); test("Calling function with one parameter", async () => { @@ -844,7 +844,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, []); + parseTemplate(template, []); }); test("Calling function with one parameter, only giving one argument", async () => { @@ -879,7 +879,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, [ + parseTemplate(template, [ "Error: The function 'udf.odd' takes 1 argument." ]); }); @@ -916,7 +916,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, [ + parseTemplate(template, [ "Error: The function 'udf.odd' takes 1 argument." ]); }); @@ -954,7 +954,7 @@ suite("User functions", () => { }] }; - await parseTemplate(template, []); + parseTemplate(template, []); }); test("Calling function with two parameters", async () => { @@ -990,7 +990,7 @@ suite("User functions", () => { }] }; - await parseTemplate(template, []); + parseTemplate(template, []); }); test("Namespaces are case insensitive", async () => { @@ -1015,7 +1015,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, []); + parseTemplate(template, []); }); test("Function names are case insensitive", async () => { @@ -1040,7 +1040,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, []); + parseTemplate(template, []); }); // CONSIDER: Give better error message. Right now we get this (from backend validation): @@ -1078,7 +1078,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, [ + parseTemplate(template, [ 'Error: Unrecognized user-defined function namespace \'udf\'.' ]); }); @@ -1105,7 +1105,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, []); + parseTemplate(template, []); }); test("Calling user function with namespace name same as built-in function", async () => { @@ -1130,7 +1130,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, []); + parseTemplate(template, []); }); @@ -1156,7 +1156,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, []); + parseTemplate(template, []); }); }); @@ -1166,131 +1166,131 @@ suite("User functions", () => { suite("Find parameter references", () => { test("At reference to top-level parameter", async () => { - const { dt, markers: { apiVersionDef, apiVersionReference } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { apiVersionDef, apiVersionReference } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at reference to "apiVersion" inside resources - await testGetReferences(dt, apiVersionReference.index, [apiVersionReference.index, apiVersionDef.index]); + await testGetReferences(dt, apiVersionReference.index, undefined, [apiVersionReference.index, apiVersionDef.index]); }); test("At definition of top-level parameter", async () => { - const { dt, markers: { apiVersionDef, apiVersionReference } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { apiVersionDef, apiVersionReference } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at definition of "apiVersion" parameter - await testGetReferences(dt, apiVersionDef.index, [apiVersionDef.index, apiVersionReference.index]); + await testGetReferences(dt, apiVersionDef.index, undefined, [apiVersionDef.index, apiVersionReference.index]); }); test("At reference to user function parameter", async () => { - const { dt, markers: { udfyearReference, udfyearDefinition } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfyearReference, udfyearDefinition } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at reference to "year" inside user function output - await testGetReferences(dt, udfyearReference.index, [udfyearReference.index, udfyearDefinition.index]); + await testGetReferences(dt, udfyearReference.index, undefined, [udfyearReference.index, udfyearDefinition.index]); }); test("At definition of user function parameter", async () => { - const { dt, markers: { udfyearReference, udfyearDefinition } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfyearReference, udfyearDefinition } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at definition of "year" inside user function - await testGetReferences(dt, udfyearDefinition.index, [udfyearReference.index, udfyearDefinition.index]); + await testGetReferences(dt, udfyearDefinition.index, undefined, [udfyearReference.index, udfyearDefinition.index]); }); test("At reference to parameter in user function only finds UDF scope parameter, not top-level param", async () => { - const { dt, markers: { udfyearReference, udfyearDefinition } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfyearReference, udfyearDefinition } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at reference to "year" inside user function output - await testGetReferences(dt, udfyearReference.index, [udfyearReference.index, udfyearDefinition.index]); + await testGetReferences(dt, udfyearReference.index, undefined, [udfyearReference.index, udfyearDefinition.index]); }); test("At definition to parameter in user function only finds UDF scope parameter, not top-level param", async () => { - const { dt, markers: { udfyearReference, udfyearDefinition } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfyearReference, udfyearDefinition } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at definition of "year" inside user function - await testGetReferences(dt, udfyearDefinition.index, [udfyearReference.index, udfyearDefinition.index]); + await testGetReferences(dt, udfyearDefinition.index, undefined, [udfyearReference.index, udfyearDefinition.index]); }); test("At reference to top-level parameter only finds top-level parameter definition, not param in user function", async () => { - const { dt, markers: { udfyearReference, udfyearDefinition } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfyearReference, udfyearDefinition } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at reference to "year" inside user function output - await testGetReferences(dt, udfyearReference.index, [udfyearReference.index, udfyearDefinition.index]); + await testGetReferences(dt, udfyearReference.index, undefined, [udfyearReference.index, udfyearDefinition.index]); }); }); suite("UDF Find variable references", () => { test("At reference to variable", async () => { - const { dt, markers: { var1Definition, var1Reference1, var1Reference2 } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { var1Definition, var1Reference1, var1Reference2 } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at reference to "var1" inside var2 - await testGetReferences(dt, var1Reference1.index, [var1Definition.index, var1Reference1.index, var1Reference2.index]); + await testGetReferences(dt, var1Reference1.index, undefined, [var1Definition.index, var1Reference1.index, var1Reference2.index]); // Cursor at reference to "var1" inside outputs2 - await testGetReferences(dt, var1Reference2.index, [var1Definition.index, var1Reference1.index, var1Reference2.index]); + await testGetReferences(dt, var1Reference2.index, undefined, [var1Definition.index, var1Reference1.index, var1Reference2.index]); }); test("Deeply nested", async () => { - const { dt, markers: { var1Definition, var1Reference1, var1Reference2 } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { var1Definition, var1Reference1, var1Reference2 } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at reference to "var1" inside var2 - await testGetReferences(dt, var1Reference1.index, [var1Definition.index, var1Reference1.index, var1Reference2.index]); + await testGetReferences(dt, var1Reference1.index, undefined, [var1Definition.index, var1Reference1.index, var1Reference2.index]); // Cursor at reference to "var1" inside outputs2 - await testGetReferences(dt, var1Reference2.index, [var1Definition.index, var1Reference1.index, var1Reference2.index]); + await testGetReferences(dt, var1Reference2.index, undefined, [var1Definition.index, var1Reference1.index, var1Reference2.index]); }); test("At definition of variable", async () => { - const { dt, markers: { var1Definition, var1Reference1, var1Reference2 } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { var1Definition, var1Reference1, var1Reference2 } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at definition to "var1" variable - await testGetReferences(dt, var1Definition.index, [var1Definition.index, var1Reference1.index, var1Reference2.index]); + await testGetReferences(dt, var1Definition.index, undefined, [var1Definition.index, var1Reference1.index, var1Reference2.index]); }); }); suite("UDF Find user function references", () => { // tslint:disable-next-line: no-suspicious-comment test("At reference to user-defined function, cursor inside the namespace portion", async () => { - const { dt, markers: { udfDef, udfReferenceAtNamespace } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfDef, udfReferenceAtNamespace } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at reference to "udf.string" inside the namespace - await testGetReferences(dt, udfReferenceAtNamespace.index, [udfDef.index, udfReferenceAtNamespace.index]); + await testGetReferences(dt, udfReferenceAtNamespace.index, undefined, [udfDef.index, udfReferenceAtNamespace.index]); }); test("At reference to user-defined function, cursor inside the name portion", async () => { - const { dt, markers: { udfStringDefinition, udfReferenceAtName } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfStringDefinition, udfReferenceAtName } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at reference to "udf.string" inside the name - await testGetReferences(dt, udfReferenceAtName.index, [udfStringDefinition.index, udfReferenceAtName.index]); + await testGetReferences(dt, udfReferenceAtName.index, undefined, [udfStringDefinition.index, udfReferenceAtName.index]); }); test("At definition of user-defined function", async () => { - const { dt, markers: { udfStringDefinition, udfReferenceAtName } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfStringDefinition, udfReferenceAtName } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at definition of "udf.string" - await testGetReferences(dt, udfStringDefinition.index, [udfStringDefinition.index, udfReferenceAtName.index]); + await testGetReferences(dt, udfStringDefinition.index, undefined, [udfStringDefinition.index, udfReferenceAtName.index]); }); test("At definition of user-defined namespace", async () => { - const { dt, markers: { udfDef, udfReferenceAtNamespace } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfDef, udfReferenceAtNamespace } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at definition of "udf.string" - await testGetReferences(dt, udfDef.index, [udfDef.index, udfReferenceAtNamespace.index]); + await testGetReferences(dt, udfDef.index, undefined, [udfDef.index, udfReferenceAtNamespace.index]); }); test("Reference to built-in function with same name as UDF function doesn't find UDF function call", async () => { - const { dt, markers: { stringRef1, stringRef2, stringRef3, stringRef4 } } = await parseTemplateWithMarkers(userFuncsTemplate1); - await testGetReferences(dt, stringRef4.index, [stringRef1.index, stringRef2.index, stringRef3.index, stringRef4.index]); + const { dt, markers: { stringRef1, stringRef2, stringRef3, stringRef4 } } = parseTemplateWithMarkers(userFuncsTemplate1); + await testGetReferences(dt, stringRef4.index, undefined, [stringRef1.index, stringRef2.index, stringRef3.index, stringRef4.index]); }); test("Reference to built-in function in outer scope finds it in all scopes", async () => { - const { dt, markers: { addReferenceInUdfString, addReferenceInOutput4 } } = await parseTemplateWithMarkers(userFuncsTemplate1); + const { dt, markers: { addReferenceInUdfString, addReferenceInOutput4 } } = parseTemplateWithMarkers(userFuncsTemplate1); // Cursor at "add" in output4 - await testGetReferences(dt, addReferenceInOutput4.index, [addReferenceInOutput4.index, addReferenceInUdfString.index]); + await testGetReferences(dt, addReferenceInOutput4.index, undefined, [addReferenceInOutput4.index, addReferenceInUdfString.index]); }); test("Reference to built-in function in function scope finds it in all scopes", async () => { - const { dt, markers: { addReferenceInUdfString, addReferenceInOutput4 } } = await parseTemplateWithMarkers(userFuncsTemplate1); + const { dt, markers: { addReferenceInUdfString, addReferenceInOutput4 } } = parseTemplateWithMarkers(userFuncsTemplate1); // Cursor at "add" in udf 'string's output - await testGetReferences(dt, addReferenceInUdfString.index, [addReferenceInOutput4.index, addReferenceInUdfString.index]); + await testGetReferences(dt, addReferenceInUdfString.index, undefined, [addReferenceInOutput4.index, addReferenceInUdfString.index]); }); }); @@ -1318,32 +1318,32 @@ suite("User functions", () => { } test("Hover over top-level parameter reference", async () => { - const { dt, markers: { yearReference } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { yearReference } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); await testHover(dt, yearReference.index, `**year**${os.EOL}*(parameter)*`); }); test("Hover over UDF parameter reference", async () => { - const { dt, markers: { udfyearReference } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfyearReference } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); await testHover(dt, udfyearReference.index, `**year**${os.EOL}*(function parameter)*`); }); test("Hover over top-level variable reference", async () => { - const { dt, markers: { var1Reference1 } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { var1Reference1 } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); await testHover(dt, var1Reference1.index, `**var1**${os.EOL}*(variable)*`); }); test("Hover over built-in function reference", async () => { - const { dt, markers: { stringRef4 } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { stringRef4 } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); await testHover(dt, stringRef4.index, `**string(valueToConvert)**${os.EOL}*(function)*${os.EOL}${os.EOL}Converts the specified value to String.`); }); test("Hover over user-defined function reference's name", async () => { - const { dt, markers: { udfReferenceAtName } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfReferenceAtName } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); await testHover(dt, udfReferenceAtName.index, `**udf.string(year [int], month, day [int]) [string]**${os.EOL}*(user-defined function)*`); }); test("Hover over user-defined function reference's namespace", async () => { - const { dt, markers: { udfReferenceAtNamespace } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfReferenceAtNamespace } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); await testHover( dt, udfReferenceAtNamespace.index, @@ -1367,21 +1367,21 @@ suite("User functions", () => { } test("Top-level parameter", async () => { - const { dt, markers: { apiVersionDef, apiVersionReference } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { apiVersionDef, apiVersionReference } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at reference to "apiVersion" inside resources // -1 because go to definition currently goes to the quote at the start of the string await testGoToDefinition(dt, apiVersionReference.index, DefinitionKind.Parameter, apiVersionDef.index - 1); }); test("User function parameter", async () => { - const { dt, markers: { udfyearReference, udfyearDefinition } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfyearReference, udfyearDefinition } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at reference to "year" inside user function output await testGoToDefinition(dt, udfyearReference.index, DefinitionKind.Parameter, udfyearDefinition.index - 1); }); test("Variable reference", async () => { - const { dt, markers: { var1Definition, var1Reference1, var1Reference2 } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { var1Definition, var1Reference1, var1Reference2 } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at reference to "var1" inside var2 await testGoToDefinition(dt, var1Reference1.index, DefinitionKind.Variable, var1Definition.index - 1); @@ -1391,14 +1391,14 @@ suite("User functions", () => { }); test("User-defined function, cursor inside the namespace portion", async () => { - const { dt, markers: { udfDef, udfReferenceAtNamespace } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfDef, udfReferenceAtNamespace } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at reference to "udf.string" inside the namespace -> goes to namespace definition await testGoToDefinition(dt, udfReferenceAtNamespace.index, DefinitionKind.Namespace, udfDef.index - 1); }); test("User-defined function, cursor inside the name portion", async () => { - const { dt, markers: { udfStringDefinition, udfReferenceAtName } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + const { dt, markers: { udfStringDefinition, udfReferenceAtName } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); // Cursor at reference to "udf.string" inside the name await testGoToDefinition(dt, udfReferenceAtName.index, DefinitionKind.UserFunction, udfStringDefinition.index - 1); @@ -1419,7 +1419,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, [ + parseTemplate(template, [ "Warning: The parameter 'param1' is never used." ]); }); @@ -1453,7 +1453,7 @@ suite("User functions", () => { }] }; - await parseTemplate(template, [ + parseTemplate(template, [ "Warning: The parameter 'param1' is never used.", "Warning: The user-defined function 'udf.odd' is never used." ]); @@ -1482,7 +1482,7 @@ suite("User functions", () => { }] }; - await parseTemplate(template, [ + parseTemplate(template, [ "Warning: The user-defined function 'udf.odd' is never used.", "Warning: User-function parameter 'param1' is never used.", ]); @@ -1523,7 +1523,7 @@ suite("User functions", () => { } }; - await parseTemplate(template, [ + parseTemplate(template, [ "Warning: The user-defined function 'udf.odd' is never used.", "Warning: User-function parameter 'param1' is never used.", ]); @@ -1558,7 +1558,7 @@ suite("User functions", () => { }] }; - await parseTemplate(template, [ + parseTemplate(template, [ "Warning: The parameter 'param1' is never used.", 'Warning: The user-defined function \'udf.odd\' is never used.', "Warning: User-function parameter 'param1' is never used.", @@ -1592,7 +1592,7 @@ suite("User functions", () => { }; - await parseTemplate(template, [ + parseTemplate(template, [ "Warning: The user-defined function 'myNamespace.unused' is never used." ]); }); @@ -1629,7 +1629,7 @@ suite("User functions", () => { // } // }; - // await parseTemplate(template, [ + // parseTemplate(template, [ // "Warning: The user-defined namespace 'unusedNamespace1' is never used.", // "Warning: The user-defined namespace 'unusedNamespace2' is never used." // ]); diff --git a/test/UserNamespaceInfo.test.ts b/test/UserNamespaceInfo.test.ts index 6f70c59b3..01bc46038 100644 --- a/test/UserNamespaceInfo.test.ts +++ b/test/UserNamespaceInfo.test.ts @@ -17,7 +17,7 @@ suite("Hover.UserNamespaceInfo", () => { test("no members", async () => { // tslint:disable-next-line:no-any - const dt = await parseTemplate({ + const dt = parseTemplate({ $schema: "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", contentVersion: "1.0.0.0", functions: [ @@ -35,7 +35,7 @@ suite("Hover.UserNamespaceInfo", () => { }); test("one member, no params", async () => { - const dt = await parseTemplate({ + const dt = parseTemplate({ $schema: "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", contentVersion: "1.0.0.0", functions: [ @@ -57,7 +57,7 @@ suite("Hover.UserNamespaceInfo", () => { test("one member, one param, no type", async () => { // tslint:disable-next-line:no-any - const dt = await parseTemplate({ + const dt = parseTemplate({ $schema: "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", contentVersion: "1.0.0.0", functions: [ @@ -81,7 +81,7 @@ suite("Hover.UserNamespaceInfo", () => { }); test("one member, one param", async () => { - const dt = await parseTemplate({ + const dt = parseTemplate({ $schema: "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", contentVersion: "1.0.0.0", functions: [ @@ -108,7 +108,7 @@ suite("Hover.UserNamespaceInfo", () => { }); test("one member, two params", async () => { - const dt = await parseTemplate({ + const dt = parseTemplate({ $schema: "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", contentVersion: "1.0.0.0", functions: [ @@ -139,7 +139,7 @@ suite("Hover.UserNamespaceInfo", () => { }); test("two members", async () => { - const dt = await parseTemplate({ + const dt = parseTemplate({ $schema: "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", contentVersion: "1.0.0.0", functions: [ diff --git a/test/VariableIteration.test.ts b/test/VariableIteration.test.ts index 9290ae3dc..5013a0ee7 100644 --- a/test/VariableIteration.test.ts +++ b/test/VariableIteration.test.ts @@ -45,12 +45,12 @@ suite("Variable iteration (copy blocks)", () => { }; test("'copy' not found as a variable", async () => { - const dt = await parseTemplate(topLevelVariableCopyBlocks); + const dt = parseTemplate(topLevelVariableCopyBlocks); assert(!dt.topLevelScope.getVariableDefinition('copy')); }); test("copy block names are added as variables", async () => { - const dt = await parseTemplate(topLevelVariableCopyBlocks); + const dt = parseTemplate(topLevelVariableCopyBlocks); assert(dt.topLevelScope.variableDefinitions.length === 2); assert(dt.topLevelScope.variableDefinitions[0].nameValue.unquotedValue === "diskNames"); @@ -59,7 +59,7 @@ suite("Variable iteration (copy blocks)", () => { }); test("copy block value is an array of the input property", async () => { - const dt = await parseTemplate(topLevelVariableCopyBlocks); + const dt = parseTemplate(topLevelVariableCopyBlocks); const value = dt.topLevelScope.getVariableDefinition('diskNames')!.value!; assert(value); @@ -70,7 +70,7 @@ suite("Variable iteration (copy blocks)", () => { }); test("copy block usage info", async () => { - const dt = await parseTemplate(topLevelVariableCopyBlocks); + const dt = parseTemplate(topLevelVariableCopyBlocks); const diskNames = dt.topLevelScope.getVariableDefinition('diskNames')!; assert.deepStrictEqual(diskNames.usageInfo, { @@ -81,7 +81,7 @@ suite("Variable iteration (copy blocks)", () => { }); test("Find references at variable reference points to the copy block element's name property", async () => { - const { dt, markers: { diskNamesDefName, diskNamesRef } } = await parseTemplateWithMarkers( + const { dt, markers: { diskNamesDefName, diskNamesRef } } = parseTemplateWithMarkers( { ...topLevelVariableCopyBlocks, outputs: { @@ -95,7 +95,7 @@ suite("Variable iteration (copy blocks)", () => { [], { ignoreWarnings: true }); - await testGetReferences(dt, diskNamesRef.index, [diskNamesRef.index, diskNamesDefName.index]); + await testGetReferences(dt, diskNamesRef.index, undefined, [diskNamesRef.index, diskNamesDefName.index]); }); @@ -169,7 +169,7 @@ suite("Variable iteration (copy blocks)", () => { }); test("case insensitive lookup", async () => { - const dt = await parseTemplate(topLevelVariableCopyBlocks); + const dt = parseTemplate(topLevelVariableCopyBlocks); assert(!!dt.topLevelScope.getVariableDefinition('DISKnAMES')); }); @@ -295,7 +295,7 @@ suite("Variable iteration (copy blocks)", () => { }; suiteSetup(async () => { - dt = await parseTemplate(embeddedVariableCopyBlocks); + dt = parseTemplate(embeddedVariableCopyBlocks); variable = dt.topLevelScope.getVariableDefinition('Disk-array-in-object')!; assert(variable); }); @@ -350,7 +350,7 @@ suite("Variable iteration (copy blocks)", () => { }); test("multiple copy members", async () => { - const dt2: DeploymentTemplateDoc = await parseTemplate({ + const dt2: DeploymentTemplateDoc = parseTemplate({ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "variables": { @@ -527,7 +527,7 @@ suite("Variable iteration (copy blocks)", () => { // } // } - const dt2 = await parseTemplate(template); + const dt2 = parseTemplate(template); const vTop: IVariableDefinition = dt2.topLevelScope.getVariableDefinition('top')!; const vTopValue = Json.asObjectValue(vTop.value)!; assert.deepStrictEqual(vTopValue.propertyNames.sort(), ["array1", "mid"]); @@ -652,7 +652,7 @@ suite("Variable iteration (copy blocks)", () => { }; // Make sure no errors - await parseTemplate(variableCopySampleTemplate, []); + parseTemplate(variableCopySampleTemplate, []); }); }); // end suite Variable iteration sample diff --git a/test/areDecoupledChildAndParent.test.ts b/test/areDecoupledChildAndParent.test.ts index de58dbf82..a25c88be8 100644 --- a/test/areDecoupledChildAndParent.test.ts +++ b/test/areDecoupledChildAndParent.test.ts @@ -22,7 +22,7 @@ suite("areDecoupledChildAndParent", () => { expectedReverse: boolean ): void { test(`${name ? name + ':' : ''}child=${childNameExpression}, parent=${parentNameExpression}`, async () => { - const dt = await parseTemplate(template, []); + const dt = parseTemplate(template, []); const infos = getResourcesInfo({ scope: dt.topLevelScope, recognizeDecoupledChildren: false }); testLog.writeLine(`Resource Infos found:\n` + infos.map(i => `${i.getFullNameExpression()} (${i.getFullTypeExpression()})`).join('\n')); @@ -51,7 +51,7 @@ suite("areDecoupledChildAndParent", () => { parent ] }; - const dt = await parseTemplate(template); + const dt = parseTemplate(template); const infos = getResourcesInfo({ scope: dt.topLevelScope, recognizeDecoupledChildren: true }); testLog.writeLine(`Resource Infos found:\n` + infos.map(i => `${i.getFullNameExpression()} (${i.getFullTypeExpression()})`).join('\n')); diff --git a/test/dependsOn.completions.test.ts b/test/dependsOn.completions.test.ts index b0753c730..54a3e8457 100644 --- a/test/dependsOn.completions.test.ts +++ b/test/dependsOn.completions.test.ts @@ -25,7 +25,7 @@ suite("dependsOn completions", () => { } ): void { test(testName, async () => { - const { dt, markers: { cursor, replaceStart } } = await parseTemplateWithMarkers(options.template); + const { dt, markers: { cursor, replaceStart } } = parseTemplateWithMarkers(options.template); assert(cursor, "Missing in testcase template"); const pc = dt.getContextFromDocumentCharacterIndex(cursor.index, undefined); const { items: completions } = await pc.getCompletionItems(options.triggerCharacter, 4); diff --git a/test/functional/contextualizedSnippets.test.ts b/test/functional/contextualizedSnippets.test.ts index 6cadcd917..36c13260d 100644 --- a/test/functional/contextualizedSnippets.test.ts +++ b/test/functional/contextualizedSnippets.test.ts @@ -37,7 +37,7 @@ suite("Contextualized snippets", () => { // tslint:disable-next-line: prefer-template const name = `${testName}, triggered by ${triggerCharacter ? ("'" + triggerCharacter + "'") : 'CTRL+SPACE'}`; testWithRealSnippets(name, async () => { - const { dt, markers: { cursor } } = await parseTemplateWithMarkers(templateWithCursorMarker); + const { dt, markers: { cursor } } = parseTemplateWithMarkers(templateWithCursorMarker); assert(cursor !== undefined, " not found in template"); let tempFile: TempFile | undefined; diff --git a/test/getResourceFriendlyName.test.ts b/test/getResourceFriendlyName.test.ts index ecaa51fb5..1170bf6b2 100644 --- a/test/getResourceFriendlyName.test.ts +++ b/test/getResourceFriendlyName.test.ts @@ -18,7 +18,7 @@ suite("getFriendlyNameForResource", () => { let keepTestNameInClosure = testName; keepTestNameInClosure = keepTestNameInClosure; - const dt = await parseTemplate({ + const dt = parseTemplate({ resources: [ resource ] @@ -32,7 +32,7 @@ suite("getFriendlyNameForResource", () => { let keepTestNameInClosure = testName; keepTestNameInClosure = keepTestNameInClosure; - const dt = await parseTemplate({ + const dt = parseTemplate({ resources: [ resource ] diff --git a/test/paramFiles.addMissingParameters.inTemplateFile.test.ts b/test/paramFiles.addMissingParameters.inTemplateFile.test.ts index 16602cc2a..1b7d8f28b 100644 --- a/test/paramFiles.addMissingParameters.inTemplateFile.test.ts +++ b/test/paramFiles.addMissingParameters.inTemplateFile.test.ts @@ -34,7 +34,7 @@ suite("Add missing parameters for nested/linked templates", () => { testWithLanguageServer(testName, async () => { const tabSize = 4; //const expectedResultText = stringify(expectedResult, tabSize); - const { dt: expectedDt } = await parseTemplateWithMarkers(expectedResult, undefined, { fromFile: true }); + const { dt: expectedDt } = parseTemplateWithMarkers(expectedResult, undefined, { fromFile: true }); const expectedResultText = expectedDt.documentText; // Get template @@ -43,14 +43,14 @@ suite("Add missing parameters for nested/linked templates", () => { const childUri = Uri.file(`${root}childTemplate.json`); // Get linked template - const { dt, markers: { bang } } = await parseTemplateWithMarkers(template, undefined, { fromFile: true, documentUri: templateUri, tabSize }); + const { dt, markers: { bang } } = parseTemplateWithMarkers(template, undefined, { fromFile: true, documentUri: templateUri, tabSize }); assert(bang, "Didn't find bang marker"); const span = new Span(bang.index, 0); const range = getVSCodeRangeFromSpan(dt, span); // Set up template with linked file information if (linkedTemplate) { - const { dt: childDt } = await parseTemplateWithMarkers(linkedTemplate, undefined, { fromFile: true, documentUri: childUri, tabSize }); + const { dt: childDt } = parseTemplateWithMarkers(linkedTemplate, undefined, { fromFile: true, documentUri: childUri, tabSize }); const graph: INotifyTemplateGraphArgs = { rootTemplateUri: templateUri.toString(), linkedTemplates: [ diff --git a/test/parameterFileCompletions.test.ts b/test/parameterFileCompletions.test.ts index 5c3a021cb..cc57a5498 100644 --- a/test/parameterFileCompletions.test.ts +++ b/test/parameterFileCompletions.test.ts @@ -34,7 +34,7 @@ suite("Parameter file completions", () => { ): void { const fullName = isNullOrUndefined(options.cursorIndex) ? testName : `${testName}, index=${options.cursorIndex}`; test(fullName, async () => { - let dt: DeploymentTemplateDoc | undefined = template ? await parseTemplate(template) : undefined; + let dt: DeploymentTemplateDoc | undefined = template ? parseTemplate(template) : undefined; const { dp, markers: { cursor } } = await parseParametersWithMarkers(params); // tslint:disable-next-line: strict-boolean-expressions diff --git a/test/performance.test.ts b/test/performance.test.ts index 39a44d38d..d973fb77d 100644 --- a/test/performance.test.ts +++ b/test/performance.test.ts @@ -17,7 +17,7 @@ suite("Performance tests", () => { const sourcePath = resolveInTestFolder('templates/performance/50params5000vars5refs.json'); const templateContents = (await fse.readFile(sourcePath)).toString(); - const dt = await parseTemplate(templateContents); + const dt = parseTemplate(templateContents); const warnings = dt.getWarnings(); // Results to large for assert.equal to handle directly diff --git a/test/support/createCompletionsTest.ts b/test/support/createCompletionsTest.ts index 7344af914..e50fc50d7 100644 --- a/test/support/createCompletionsTest.ts +++ b/test/support/createCompletionsTest.ts @@ -82,7 +82,7 @@ export function createExpressionCompletionsTestEx( template = stringify(template).replace(contextFind, expressionWithCursorMarker); - const { dt, markers: { cursor } } = await parseTemplateWithMarkers(template); + const { dt, markers: { cursor } } = parseTemplateWithMarkers(template); assert(cursor, "Didn't find marker in text"); const pc = dt.getContextFromDocumentCharacterIndex(cursor.index, undefined); const completions = await pc.getCompletionItems(options?.triggerCharacter, 4); diff --git a/test/support/parseTemplate.ts b/test/support/parseTemplate.ts index 1bebe1c75..70df61967 100644 --- a/test/support/parseTemplate.ts +++ b/test/support/parseTemplate.ts @@ -14,7 +14,7 @@ import { stringify } from "./stringify"; /** * Given a deployment template (string or object), parses it, optionally verifying expected diagnostic messages */ -export async function parseTemplate( +export function parseTemplate( template: string | IPartialDeploymentTemplate, expectedDiagnosticMessages?: string[], options?: { @@ -24,9 +24,9 @@ export async function parseTemplate( includeDiagnosticLineNumbers?: boolean; replacements?: { [key: string]: string | { [key: string]: unknown } }; } -): Promise { +): DeploymentTemplateDoc { // Go ahead and allow markers in the document to be removed, we just won't mark them (makes it easier to share the same template in multiple places) - const { dt } = await parseTemplateWithMarkers(template, expectedDiagnosticMessages, options); + const { dt } = parseTemplateWithMarkers(template, expectedDiagnosticMessages, options); return dt; } @@ -45,7 +45,7 @@ interface Markers { // tslint:disable-next-line: no-suspicious-comment // TODO: Make synchronous // tslint:disable-next-line: no-suspicious-comment -export async function parseTemplateWithMarkers( +export function parseTemplateWithMarkers( template: string | IPartialDeploymentTemplate, expectedDiagnosticMessages?: string[], options?: { @@ -57,7 +57,7 @@ export async function parseTemplateWithMarkers( documentUri?: Uri; tabSize?: number; } -): Promise<{ dt: DeploymentTemplateDoc; markers: Markers }> { +): { dt: DeploymentTemplateDoc; markers: Markers } { if (options?.fromFile) { const absPath = resolveInTestFolder(template); const contents: string = fse.readFileSync(absPath).toString(); diff --git a/test/support/testGetReferences.ts b/test/support/testGetReferences.ts index bffb42b85..a850a489d 100644 --- a/test/support/testGetReferences.ts +++ b/test/support/testGetReferences.ts @@ -3,7 +3,7 @@ // ---------------------------------------------------------------------------- import * as assert from 'assert'; -import { DeploymentTemplateDoc, ReferenceList } from '../../extension.bundle'; +import { DeploymentParametersDoc, DeploymentTemplateDoc, ReferenceList } from '../../extension.bundle'; /** * Given a deployment template and a character index into it, verify that getReferences on the template @@ -12,12 +12,12 @@ import { DeploymentTemplateDoc, ReferenceList } from '../../extension.bundle'; * Usually parseTemplateWithMarkers will be used to parse the document and find the indices of a set of locations * Example: * - * const { dt, markers: { apiVersionDef, apiVersionReference } } = await parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); + * const { dt, markers: { apiVersionDef, apiVersionReference } } = parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true }); * // Cursor at reference to "apiVersion" inside resources * await testFindReferences(dt, apiVersionReference.index, [apiVersionReference.index, apiVersionDef.index]); */ -export async function testGetReferences(dt: DeploymentTemplateDoc, cursorIndex: number, expectedReferenceIndices: number[]): Promise { - const pc = dt.getContextFromDocumentCharacterIndex(cursorIndex, undefined); +export async function testGetReferences(dt: DeploymentTemplateDoc, cursorIndexInTemplate: number, dp: DeploymentParametersDoc | undefined, expectedReferenceIndices: number[]): Promise { + const pc = dt.getContextFromDocumentCharacterIndex(cursorIndexInTemplate, undefined); // tslint:disable-next-line: no-non-null-assertion const references: ReferenceList = pc.getReferences()!; assert(references, "Expected non-empty list of references"); diff --git a/test/templates/ResourceInfo.test.ts b/test/templates/ResourceInfo.test.ts index de04734cb..48bc421c4 100644 --- a/test/templates/ResourceInfo.test.ts +++ b/test/templates/ResourceInfo.test.ts @@ -15,7 +15,7 @@ suite("ResourceInfo", () => { suite("split names", () => { function createSplitNameTest(nameAsJsonString: string, expected: string[]): void { test(nameAsJsonString, async () => { - const dt = await parseTemplate({ + const dt = parseTemplate({ resources: [ { name: nameAsJsonString, @@ -45,7 +45,7 @@ suite("ResourceInfo", () => { suite("split types", () => { function createSplitTypeTest(typeAsJsonString: string, expected: string[]): void { test(typeAsJsonString, async () => { - const dt = await parseTemplate({ + const dt = parseTemplate({ resources: [ { name: "name", @@ -549,7 +549,7 @@ suite("ResourceInfo", () => { ] }; - const dt = await parseTemplate(template); + const dt = parseTemplate(template); const infos = getResourcesInfo({ scope: dt.topLevelScope, recognizeDecoupledChildren: false }); const actual = infos.map(info => ({