Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for partial type EnC and moving declarations across files #51187

Merged
merged 4 commits into from
Feb 23, 2021

Conversation

tmat
Copy link
Member

@tmat tmat commented Feb 12, 2021

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:

Copy link
Contributor

@davidwengier davidwengier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the size, I mainly looked through the new code, rather than strictly the diff, but it seemed to make sense.

@tmat tmat force-pushed the PartialEnC2 branch 6 times, most recently from b7585c0 to cdfffef Compare February 22, 2021 05:16
Call AnalyzeChangedMemberBody from semantic analysis
@tmat tmat merged commit fc7b737 into dotnet:master Feb 23, 2021
@ghost ghost added this to the Next milestone Feb 23, 2021
@tmat tmat deleted the PartialEnC2 branch February 23, 2021 03:04
@tmat tmat modified the milestones: Next, 16.10 Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants