Azure / Azure/bicep

Bicep should store snippets internally as syntax trees rather than strings

Open
#3,384 1 comment 0 reactions 0 assignees View on GitHub
enhancement tech debt
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.