experimental HiFi tree diff algorithm for use with quick-fixes and refactoring commands in the IDE #2031
+320
−0
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.
This transforms a pair of parse Trees <original, rewritten> to a list[TextEdit]s. The resulting
TextEdits are ready for use in VScode extensions via LSP features in util::LanguageServer and
util::IDEServices.
The single pass parse tree recursion maps sub-tree and sub-list differences to textual differences in a special way.
It lifts on the semantics of special parse tree non-terminals (literals, lexicals, separators) to ignore certain
superfluous changes made in the rewritten tree. As a result the edited source text retains more of
its original layout, including indentation and comments, as compared to yielding the
rewritten parse tree to a string and replacing the entire file.
Especially with separated lists this algorithm does amazing work. Suppose you have a target pattern:
<Element e>, <{Element ","}* newElems, <Element f>
andnewElems
happens to be empty, then:e
and before thef
eventhough these have been replaced by the concrete target pattern.
original list where possible.
The smaller diffs are not only good for high-fidelity in general, but also in particular smaller diffs are essential for providing interactive preview and undo features in the IDE. This PR enables language engineers to use parse tree rewriting rather than collecting the text edits themselves.
TODO's: