|
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 | + // TODO: Either fix or ignore "method lacks 'await'" warning. |
| 43 | + public override async Task<CodeAction> Handle(CodeAction request, CancellationToken cancellationToken) |
57 | 44 | {
|
58 |
| - _capability = capability; |
| 45 | + // TODO: How on earth do we handle a CodeAction? This is new... |
| 46 | + if (cancellationToken.IsCancellationRequested) |
| 47 | + { |
| 48 | + _logger.LogDebug("CodeAction request canceled for: {0}", request.Title); |
| 49 | + } |
| 50 | + return request; |
59 | 51 | }
|
60 | 52 |
|
61 |
| - public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request, CancellationToken cancellationToken) |
| 53 | + public override async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request, CancellationToken cancellationToken) |
62 | 54 | {
|
63 | 55 | if (cancellationToken.IsCancellationRequested)
|
64 | 56 | {
|
@@ -101,7 +93,7 @@ public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request,
|
101 | 93 | new WorkspaceEditDocumentChange(
|
102 | 94 | new TextDocumentEdit
|
103 | 95 | {
|
104 |
| - TextDocument = new VersionedTextDocumentIdentifier |
| 96 | + TextDocument = new OptionalVersionedTextDocumentIdentifier |
105 | 97 | {
|
106 | 98 | Uri = request.TextDocument.Uri
|
107 | 99 | },
|
|
0 commit comments