Skip to content

Commit

Permalink
Pass in computed data
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Dec 2, 2024
1 parent eac65d5 commit 654c0b3
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using Microsoft.CodeAnalysis.Operations;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.Utilities;
using Roslyn.Utilities;

Expand Down Expand Up @@ -198,7 +197,7 @@ [.. surroundingStatements
var usingStatement = CreateUsingStatement(declarationStatement, statementsToSurround);

return await ReplaceWithUsingStatementAsync(
document, declarationStatement, statementsToSurround, usingStatement, cancellationToken).ConfigureAwait(false);
document, declarationStatement, statementsToSurround, usingStatement, surroundingStatements, declarationStatementIndex, cancellationToken).ConfigureAwait(false);
}
}
}
Expand Down Expand Up @@ -233,7 +232,7 @@ private async Task<Document> IntroduceUsingStatementAsync(
var usingStatement = CreateUsingBlockStatement(expressionStatement, statementsToSurround);

return await ReplaceWithUsingStatementAsync(
document, expressionStatement, statementsToSurround, usingStatement, cancellationToken).ConfigureAwait(false);
document, expressionStatement, statementsToSurround, usingStatement, surroundingStatements, statementIndex, cancellationToken).ConfigureAwait(false);
}
}

Expand All @@ -242,13 +241,12 @@ private async Task<Document> ReplaceWithUsingStatementAsync(
TStatementSyntax statementToReplace,
SyntaxList<TStatementSyntax> statementsToSurround,
TStatementSyntax usingStatement,
SyntaxList<TStatementSyntax> surroundingStatements,
int statementIndex,
CancellationToken cancellationToken)
{
var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

var surroundingStatements = GetSurroundingStatements(statementToReplace);
var statementIndex = surroundingStatements.IndexOf(statementToReplace);

if (statementsToSurround.Any())
{
var newParent = WithStatements(
Expand Down

0 comments on commit 654c0b3

Please sign in to comment.