Skip to content

Commit a86b19e

Browse files
josefpihrtJochemHarmes
authored andcommitted
Small fix of refactoring RR0194
1 parent 1681c31 commit a86b19e

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/Refactorings/CSharp/Refactorings/SplitLocalDeclarationAndAssignmentRefactoring.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,24 @@ public static async Task ComputeRefactoringAsync(
1616
RefactoringContext context,
1717
LocalDeclarationStatementSyntax localDeclaration)
1818
{
19+
if (!context.Span.IsEmpty)
20+
return;
21+
1922
StatementListInfo statementsInfo = SyntaxInfo.StatementListInfo(localDeclaration);
2023

2124
if (!statementsInfo.Success)
2225
return;
2326

2427
SingleLocalDeclarationStatementInfo localInfo = SyntaxInfo.SingleLocalDeclarationStatementInfo(localDeclaration);
2528

26-
if (!localInfo.Success)
27-
return;
28-
29-
if (!context.Span.IsEmpty
30-
&& context.Span.Start == localInfo.EqualsToken.SpanStart)
31-
{
32-
return;
33-
}
34-
3529
ExpressionSyntax value = localInfo.Value;
3630

3731
if (value is null)
3832
return;
3933

34+
if (context.Span.Start != localInfo.EqualsToken.SpanStart)
35+
return;
36+
4037
SemanticModel semanticModel = await context.GetSemanticModelAsync().ConfigureAwait(false);
4138

4239
TypeSyntax type = localInfo.Type;

src/Tests/Refactorings.Tests/RR0194SplitLocalDeclarationAndAssignmentTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class C
1818
{
1919
void M()
2020
{
21-
string s [||]= new string(' ', 1);
21+
var s [||]= new string(' ', 1);
2222
}
2323
}
2424
", @"

0 commit comments

Comments
 (0)