feat: suggest template variables when symbol is unknown #48
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What was the problem/requirement? (What/Why)
When the user has a format string in their template that references a template variable that doesn't exist (either at that scope or otherwise) we just provide a generic "symbol unknown" style error message. We can do better.
What was the solution? (How)
Add a recommender based on the edit distance between the unknown symbol and the available symbols at that location. This is mostly targetting typo errors (e.g. "Parm.Foo" instead of "Param.Foo") right now, so we also have a threshold distance to avoid some misleading suggestions.
What is the impact of this change?
Given a template like:
We generate the error:
How was this change tested?
I added unit tests to cover the new functionality.
Was this change documented?
No need.
Is this a breaking change?
Nope.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.