|
19 | 19 |
|
20 | 20 | namespace Microsoft.PowerShell.EditorServices.Handlers |
21 | 21 | { |
22 | | - internal class PsesCodeActionHandler : ICodeActionHandler |
| 22 | + internal class PsesCodeActionHandler : CodeActionHandlerBase |
23 | 23 | { |
24 | | - private static readonly CodeActionKind[] s_supportedCodeActions = new[] |
25 | | - { |
26 | | - CodeActionKind.QuickFix |
27 | | - }; |
28 | | - |
29 | | - private readonly CodeActionRegistrationOptions _registrationOptions; |
30 | | - |
31 | 24 | private readonly ILogger _logger; |
32 | | - |
33 | 25 | private readonly AnalysisService _analysisService; |
34 | | - |
35 | 26 | private readonly WorkspaceService _workspaceService; |
36 | 27 |
|
37 | | - private CodeActionCapability _capability; |
38 | | - |
39 | 28 | public PsesCodeActionHandler(ILoggerFactory factory, AnalysisService analysisService, WorkspaceService workspaceService) |
40 | 29 | { |
41 | 30 | _logger = factory.CreateLogger<PsesCodeActionHandler>(); |
42 | 31 | _analysisService = analysisService; |
43 | 32 | _workspaceService = workspaceService; |
44 | | - _registrationOptions = new CodeActionRegistrationOptions |
45 | | - { |
46 | | - DocumentSelector = LspUtils.PowerShellDocumentSelector, |
47 | | - CodeActionKinds = s_supportedCodeActions |
48 | | - }; |
49 | 33 | } |
50 | 34 |
|
51 | | - public CodeActionRegistrationOptions GetRegistrationOptions() |
52 | | - { |
53 | | - return _registrationOptions; |
54 | | - } |
| 35 | + protected override CodeActionRegistrationOptions CreateRegistrationOptions(CodeActionCapability capability, ClientCapabilities clientCapabilities) => new CodeActionRegistrationOptions |
| 36 | + { |
| 37 | + // TODO: What do we do with the arguments? |
| 38 | + DocumentSelector = LspUtils.PowerShellDocumentSelector, |
| 39 | + CodeActionKinds = new CodeActionKind[] { CodeActionKind.QuickFix } |
| 40 | + }; |
55 | 41 |
|
56 | | - public void SetCapability(CodeActionCapability capability) |
| 42 | + public override async Task<CodeAction> Handle(CodeAction request, CancellationToken cancellationToken) |
57 | 43 | { |
58 | | - _capability = capability; |
| 44 | + // TODO: How on earth do we handle a CodeAction? This is new... |
| 45 | + if (cancellationToken.IsCancellationRequested) |
| 46 | + { |
| 47 | + _logger.LogDebug("CodeAction request canceled for: {0}", request.Title); |
| 48 | + } |
| 49 | + return request; |
59 | 50 | } |
60 | 51 |
|
61 | | - public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request, CancellationToken cancellationToken) |
| 52 | + public override async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request, CancellationToken cancellationToken) |
62 | 53 | { |
63 | 54 | if (cancellationToken.IsCancellationRequested) |
64 | 55 | { |
@@ -101,7 +92,7 @@ public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request, |
101 | 92 | new WorkspaceEditDocumentChange( |
102 | 93 | new TextDocumentEdit |
103 | 94 | { |
104 | | - TextDocument = new VersionedTextDocumentIdentifier |
| 95 | + TextDocument = new OptionalVersionedTextDocumentIdentifier |
105 | 96 | { |
106 | 97 | Uri = request.TextDocument.Uri |
107 | 98 | }, |
|
0 commit comments