|
21 | 21 |
|
22 | 22 | namespace Microsoft.PowerShell.EditorServices.Handlers
|
23 | 23 | {
|
| 24 | + // TODO: Use ABCs. |
24 | 25 | internal class PsesCompletionHandler : ICompletionHandler, ICompletionResolveHandler
|
25 | 26 | {
|
26 | 27 | const int DefaultWaitTimeoutMilliseconds = 5000;
|
@@ -51,17 +52,14 @@ public PsesCompletionHandler(
|
51 | 52 | _workspaceService = workspaceService;
|
52 | 53 | }
|
53 | 54 |
|
54 |
| - public CompletionRegistrationOptions GetRegistrationOptions() |
| 55 | + protected override CompletionRegistrationOptions CreateRegistrationOptions(CompletionCapability capability, ClientCapabilities clientCapabilities) => new CompletionRegistrationOptions |
55 | 56 | {
|
56 |
| - return new CompletionRegistrationOptions |
57 |
| - { |
58 | 57 | DocumentSelector = LspUtils.PowerShellDocumentSelector,
|
59 | 58 | ResolveProvider = true,
|
60 | 59 | TriggerCharacters = new[] { ".", "-", ":", "\\" }
|
61 |
| - }; |
62 |
| - } |
| 60 | + }; |
63 | 61 |
|
64 |
| - public async Task<CompletionList> Handle(CompletionParams request, CancellationToken cancellationToken) |
| 62 | + public override async Task<CompletionList> Handle(CompletionParams request, CancellationToken cancellationToken) |
65 | 63 | {
|
66 | 64 | int cursorLine = request.Position.Line + 1;
|
67 | 65 | int cursorColumn = request.Position.Character + 1;
|
@@ -117,7 +115,7 @@ public bool CanResolve(CompletionItem value)
|
117 | 115 | }
|
118 | 116 |
|
119 | 117 | // Handler for "completionItem/resolve". In VSCode this is fired when a completion item is highlighted in the completion list.
|
120 |
| - public async Task<CompletionItem> Handle(CompletionItem request, CancellationToken cancellationToken) |
| 118 | + public async override Task<CompletionItem> Handle(CompletionItem request, CancellationToken cancellationToken) |
121 | 119 | {
|
122 | 120 | // We currently only support this request for anything that returns a CommandInfo: functions, cmdlets, aliases.
|
123 | 121 | if (request.Kind != CompletionItemKind.Function)
|
@@ -145,10 +143,11 @@ await CommandHelpers.GetCommandInfoAsync(
|
145 | 143 |
|
146 | 144 | if (commandInfo != null)
|
147 | 145 | {
|
148 |
| - request.Documentation = |
149 |
| - await CommandHelpers.GetCommandSynopsisAsync( |
150 |
| - commandInfo, |
151 |
| - _powerShellContextService).ConfigureAwait(false); |
| 146 | + return new CompletionItem() |
| 147 | + { |
| 148 | + // TODO: Do we need to fill in the rest of the fields? |
| 149 | + Documentation = await CommandHelpers.GetCommandSynopsisAsync(commandInfo, _powerShellContextService).ConfigureAwait(false) |
| 150 | + }; |
152 | 151 | }
|
153 | 152 |
|
154 | 153 | // Send back the updated CompletionItem
|
|
0 commit comments