microsoft / azure-pipelines-language-server

A language server for Azure Pipelines YAML
37 stars 25 forks source link

Handle scalar properties with dynamic keys #130

Closed 50Wliu closed 2 years ago

50Wliu commented 2 years ago

This handles a case where, when looping through a sequence (array) of items, we would see a map (object) with a dynamic expression as the key but a scalar as the value and not know what to do with it (leading to a proactive error being thrown).

In the general case, when the first item in a sequence (array) is a map with an expression as the key, that means the key will vanish at compile time, and we should hoist its children up as the "real" values instead. However, that doesn't hold true when the value is a simple scalar. In that case, we do need to preserve the key and treat it as a regular key/value pair.

Because it took me way too long to re-understand this code (and I wrote it not too long ago!), I've added extensive comments to hopefully make it easier for the next person.