Bicep should store snippets internally as syntax trees rather than strings
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 21m
- Merged PRs (30d)
- 79
Description
Now that we're doing more advanced operations on snippets rather than just returning them directly, we are ending up having to modify snippets on the fly (for example, doing `string.Replace()` operations. This is fragile w.r.t syntax changes, and potentially inaccurate if the regular expressions being used are not specific enough.
Example from a recent PR to motivate this change:
https://github.com/Azure/bicep/blob/7b0006f7711c8301edd2c1d20b839728fd2dfa39/src/Bicep.LangServer/Snippets/SnippetsProvider.cs#L236-L237
This logic will break if:
* We have parent property values which can span multiple lines.
* There are any other properties in the snippet named "parent" which we don't intend to replace.
Contributor guide
Research direction
Read src/Bicep.LangServer/Snippets/SnippetsProvider.cs, especially the logic around the linked lines, to understand where snippets are currently stored and modified as strings. Trace the snippet operations that depend on string replacement, then define completion as those operations working on syntax trees without breaking multiline values or replacing unrelated properties.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100