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

Slight improvement to refactoring preview performance for InlineTemporaryCodeRefactoringProvider #70440

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ private static async Task<Document> InlineTemporaryAsync(Document document, Vari

// Annotate the variable declarator so that we can get back to it later.
document = await document.ReplaceNodeAsync(declarator, declarator.WithAdditionalAnnotations(DefinitionAnnotation), cancellationToken).ConfigureAwait(false);
var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);

declarator = await FindDeclaratorAsync(document, cancellationToken).ConfigureAwait(false);

Expand All @@ -155,7 +154,6 @@ private static async Task<Document> InlineTemporaryAsync(Document document, Vari
(o, n) => n.WithAdditionalAnnotations(ReferenceAnnotation),
cancellationToken).ConfigureAwait(false);

semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
declarator = await FindDeclaratorAsync(document, cancellationToken).ConfigureAwait(false);

allReferences = await FindReferenceAnnotatedNodesAsync(document, cancellationToken).ConfigureAwait(false);
Expand All @@ -172,7 +170,6 @@ private static async Task<Document> InlineTemporaryAsync(Document document, Vari
var newScope = ReferenceRewriter.Visit(scope, conflictReferences, nonConflictReferences, expressionToInline, cancellationToken);

document = await document.ReplaceNodeAsync(scope, newScope, cancellationToken).ConfigureAwait(false);
semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);

declarator = await FindDeclaratorAsync(document, cancellationToken).ConfigureAwait(false);
newScope = GetScope(declarator);
Expand All @@ -183,7 +180,6 @@ private static async Task<Document> InlineTemporaryAsync(Document document, Vari
// No semantic conflicts, we can remove the definition.
document = await document.ReplaceNodeAsync(
newScope, RemoveDeclaratorFromScope(declarator, newScope), cancellationToken).ConfigureAwait(false);
semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
}

// Finally, check all the places we inlined an expression and add some final warnings there if appropriate.
Expand All @@ -192,6 +188,8 @@ private static async Task<Document> InlineTemporaryAsync(Document document, Vari
.OfType<ExpressionSyntax>()
.Select(e => GetTopMostParentingExpression(e));

var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);

// Make each topmost parenting statement or Equals Clause Expressions semantically explicit.
document = await document.ReplaceNodesAsync(topmostParentingExpressions, (o, n) =>
{
Expand Down