@@ -184,9 +184,7 @@ function recursivelyBuildAst(parent: ASTNode, node: Yaml.YAMLNode): ASTNode {
184
184
// and remove the expression from the parsed YAML.
185
185
function addPropertiesToObjectNode ( node : ObjectASTNode , properties : Yaml . YAMLMapping [ ] ) : void {
186
186
for ( const property of properties ) {
187
- // The endsWith check is necessary because you can have dynamically-generated variables;
188
- // for example, ${{ environment }}Release: true.
189
- if ( property . key . value . startsWith ( "${{" ) && property . key . value . endsWith ( "}}" ) ) {
187
+ if ( isCompileTimeExpression ( property ) ) {
190
188
// Ensure we have a value (object) _and_ that the value has mappings (properties).
191
189
if ( property . value ?. mappings !== undefined ) {
192
190
addPropertiesToObjectNode ( node , property . value . mappings ) ;
@@ -214,9 +212,7 @@ function addItemsToArrayNode(node: ArrayASTNode, items: Yaml.YAMLNode[]): void {
214
212
// Hoisted expressions must be the first (and only) property in an object,
215
213
// so we can safely check only the first key.
216
214
// TODO: Confirm the above statement.
217
- if ( item . kind === Yaml . Kind . MAP &&
218
- item . mappings [ 0 ] . key . value . startsWith ( "${{" ) &&
219
- item . mappings [ 0 ] . key . value . endsWith ( "}}" ) ) {
215
+ if ( item . kind === Yaml . Kind . MAP && isCompileTimeExpression ( item . mappings [ 0 ] ) ) {
220
216
const value = item . mappings [ 0 ] . value ;
221
217
if ( value === null ) {
222
218
// Incomplete object: they're still working on the value :).
@@ -274,6 +270,12 @@ function addItemsToArrayNode(node: ArrayASTNode, items: Yaml.YAMLNode[]): void {
274
270
}
275
271
}
276
272
273
+ function isCompileTimeExpression ( node : Yaml . YAMLNode ) : boolean {
274
+ return node . key . kind === Yaml . Kind . SCALAR &&
275
+ node . key . value . startsWith ( "${{" ) &&
276
+ node . key . value . endsWith ( "}}" ) ;
277
+ }
278
+
277
279
function convertError ( e : Yaml . YAMLException ) : YAMLError {
278
280
return { getMessage : ( ) => e . reason , start : e . mark . position , end : e . mark . position + e . mark . column } ;
279
281
}
0 commit comments