File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
src/RoslynWorkspaceAccess Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 22using Microsoft . CodeAnalysis . CodeActions ;
33using Microsoft . CodeAnalysis . CodeFixes ;
44using Microsoft . CodeAnalysis . Diagnostics ;
5+ using Microsoft . CodeAnalysis . ExtractClass ;
6+ using Microsoft . CodeAnalysis . ExtractInterface ;
57using Microsoft . CodeAnalysis . GenerateType ;
68using Microsoft . CodeAnalysis . Host ;
79using Microsoft . CodeAnalysis . Host . Mef ;
@@ -23,7 +25,20 @@ public static async Task<IEnumerable<CodeAction>> GetCodeActionsAsync(this Docum
2325 var codeFixService = document . Project . Solution . Services . ExportProvider . GetExports < ICodeFixService > ( ) . Single ( ) . Value ;
2426 var fixes = await codeFixService . GetFixesAsync ( document , span , cancellationToken ) ;
2527 return fixes . Where ( static c => c . Fixes . Length != 0 )
26- . SelectMany ( static c => c . Fixes . Select ( static f => f . Action ) ) ;
28+ . SelectMany ( static c => c . Fixes . Select ( static f => f . Action ) )
29+ . Where ( isSupportedCodeAction ) ;
30+
31+ // https://github.com/dotnet/roslyn/blob/8aa0e2e2ccb66c8b0fe0e002d80a92e870304665/src/LanguageServer/Protocol/Handler/CodeActions/CodeActionHelpers.cs#L96
32+ static bool isSupportedCodeAction ( CodeAction codeAction )
33+ {
34+ if ( ( codeAction is CodeActionWithOptions and not ExtractInterfaceCodeAction and not ExtractClassWithDialogCodeAction ) ||
35+ codeAction . Tags . Contains ( CodeAction . RequiresNonDocumentChange ) )
36+ {
37+ return false ;
38+ }
39+
40+ return true ;
41+ }
2742 }
2843
2944 public static DocumentTextDifferencingService GetDocumentTextDifferencingService ( this SolutionServices services )
You can’t perform that action at this time.
0 commit comments