import { IDeploymentParametersFile , IPartialDeploymentTemplate } from "./support/diagnostics" ; import { parseParametersWithMarkers , parseTemplateWithMarkers } from "./support/parseTemplate" ; import { testGetReferences } from "./support/testGetReferences" ; suite ( "Find References for parameters" , ( ) => { suite ( "#1237 Don't mix up params in param file with params with same name in a nested template" , ( ) => { suite ( "Nested template" , ( ) => { const templateWithNestedTemplate = { parameters : { "<!topLevelParameter1Definition!>parameter1" : { type : "string" , metadata : { description : "top-level parameter1 definition" } } } , resources : [ { name : "[parameters('<!topLevelParameter1Usage!>parameter1')]" , type : "Microsoft.Resources/deployments" , apiVersion : "2020-10-01" , properties : { expressionEvaluationOptions : { scope : "inner" } , mode : "Incremental" , parameters : { "<!nestedParameter1Value!>parameter1" : { value : "nested template param1 value" } } , template : { $schema : "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#" , contentVersion : "1.0.0.0" , parameters : { "<!nestedParameter1Definition!>parameter1" : { type : "string" , metadata : { description : "nested template parameter1 definition" } } } , variables : { } , resources : [ ] , outputs : { output1 : { type : "string" , value : "[parameters('<!nestedParameter1Usage!>parameter1')]" } } } } } ] } ; const paramsFile1 = { parameters : { "<!topLevelParameter1Value!>parameter1" : { value : "Top-level parameter 1 value in parameter file" } } } ; const { dt , markers : { topLevelParameter1Definition , topLevelParameter1Usage , nestedParameter1Definition , nestedParameter1Usage , nestedParameter1Value } } = parseTemplateWithMarkers ( templateWithNestedTemplate , [ ] , { ignoreWarnings : true } ) ; const { dp , markers : { topLevelParameter1Value } } = parseParametersWithMarkers ( paramsFile1 ) ; suite ( "Top-level parameter1" , ( ) => { test ( "Cursor at definition" , ( ) => { testGetReferences ( dt , topLevelParameter1Definition . index , [ topLevelParameter1Definition . index , topLevelParameter1Usage . index , topLevelParameter1Value . index ] , { associatedDoc : dp } ) ; } ) ; test ( "Cursor at usage" , ( ) => { testGetReferences ( dt , topLevelParameter1Usage . index , [ topLevelParameter1Definition . index , topLevelParameter1Usage . index , topLevelParameter1Value . index ] , { associatedDoc : dp } ) ; } ) ; test ( "Cursor at value in parameters file" , ( ) => { testGetReferences ( dp , topLevelParameter1Value . index , [ topLevelParameter1Definition . index , topLevelParameter1Usage . index , topLevelParameter1Value . index ] , { associatedDoc : dt } ) ; } ) ; } ) ; suite ( "Parameter1 in nested template" , ( ) => { test ( "Cursor at definition" , ( ) => { testGetReferences ( dt , nestedParameter1Definition . index , [ nestedParameter1Definition . index , nestedParameter1Usage . index , nestedParameter1Value . index ] , { associatedDoc : dp } ) ; } ) ; test ( "Cursor at usage" , ( ) => { testGetReferences ( dt , nestedParameter1Usage . index , [ nestedParameter1Definition . index , nestedParameter1Usage . index , nestedParameter1Value . index ] , { associatedDoc : dp } ) ; } ) ; test ( "Cursor at value (in template file, in nested param values)" , ( ) => { testGetReferences ( dt , nestedParameter1Value . index , [ nestedParameter1Definition . index , nestedParameter1Usage . index , nestedParameter1Value . index ] , { associatedDoc : dp } ) ; } ) ; } ) ; } ) ; } ) ; } ) ;