Support for partial type EnC and moving declarations across files #51187
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.
Adds support for editing partial types, moving members across files (in between different parts of a partial type declaration), adding a file to a compilation, or moving whole type declaration to another file.
The core of the change is in inverting the approach to the analysis. Previously we had two separate passes: syntactic (top-level and statement level) and semantic. If a rude edit was found during the first one we did not run the second one. The whole analysis was entirely based on the document content except for constructor semantic analysis, which could use semantic information from other documents. The new approach performs top-level only syntactic analysis and then feeds the top-level edits directly into semantic analysis. The semantic analysis translates the syntactic edits to symbol edits and if performs statement level syntactic and semantic analysis for members with updated bodies. This allows us to compare member bodies across documents - since we can run the body analysis not only on bodies located in the document being analyzed but also bodies retrieved from the syntax references of symbols.
The new approach requires the semantic and member body analysis to be more robust and handle semantically incorrect code since we no can no longer discover many of the rude edits in the first phase (top-level) and bail. E.g. the first phase can't distinguish between a deleted member declaration and a member declaration moved to another file.
Some edits in partial classes require additional post-processing. E.g. if field initializers of a partial type located in different documents are updated the resulting semantic edit should be a single edit of each of the constructors that emits these initializers. Since we still perform and store the results of the analysis per document (for each changed document) we'll end up with the constructor updates recorded for each document. The final results must merge these results before passing it to the compiler when emitting deltas.
Fixes:
#50016
#50876
Follow-ups/potential improvements: