Skip to content

Commit

Permalink
Merge pull request #75092 from dibarbet/order_modifiers_vscode
Browse files Browse the repository at this point in the history
Include initial filter node when searching for nodes to order modifiers
  • Loading branch information
dibarbet authored Sep 12, 2024
2 parents 32dd4cc + 82776b5 commit c737a04
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/Analyzers/CSharp/Tests/OrderModifiers/OrderModifiersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -558,4 +558,22 @@ file abstract class C
}
""");
}

[Fact, WorkItem("https://github.com/dotnet/vscode-csharp/issues/7553")]
public async Task TestEmptySelection()
{
await TestInRegularAndScript1Async(
"""
namespace M;
[||]static internal class C
{
}
""",
"""
namespace M;
internal static class C
{
}
""", TestParameters.Default.WithIncludeDiagnosticsOutsideSelection(false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ private void AnalyzeSyntaxTree(SyntaxTreeAnalysisContext context, CompilationOpt
return;
}

Recurse(context, preferredOrder, option.Notification, context.GetAnalysisRoot(findInTrivia: false));
var analysisRoot = context.GetAnalysisRoot(findInTrivia: false);

// Check the root node first to see if it has any modifiers that need reordering.
CheckModifiers(context, preferredOrder, option.Notification, analysisRoot);

// Recurse to check the child nodes.
Recurse(context, preferredOrder, option.Notification, analysisRoot);
}

protected abstract void Recurse(
Expand Down

0 comments on commit c737a04

Please sign in to comment.