diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs index 4bcd45a916..961f702caf 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs @@ -15,13 +15,13 @@ using Microsoft.PowerShell.EditorServices.Services; using Microsoft.PowerShell.EditorServices.Services.TextDocument; using Microsoft.PowerShell.EditorServices.Utility; -using OmniSharp.Extensions.LanguageServer.Protocol; using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities; using OmniSharp.Extensions.LanguageServer.Protocol.Document; using OmniSharp.Extensions.LanguageServer.Protocol.Models; namespace Microsoft.PowerShell.EditorServices.Handlers { + // TODO: Use ABCs. internal class PsesCodeLensHandlers : ICodeLensHandler, ICodeLensResolveHandler { private readonly Guid _id = new Guid(); @@ -39,13 +39,15 @@ public PsesCodeLensHandlers(ILoggerFactory factory, SymbolsService symbolsServic _symbolsService = symbolsService; } - CodeLensRegistrationOptions IRegistration.GetRegistrationOptions() + public CodeLensRegistrationOptions GetRegistrationOptions(CodeLensCapability capability, ClientCapabilities clientCapabilities) => new CodeLensRegistrationOptions { - return new CodeLensRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - ResolveProvider = true - }; + DocumentSelector = LspUtils.PowerShellDocumentSelector, + ResolveProvider = true + }; + + public void SetCapability(CodeLensCapability capability, ClientCapabilities clientCapabilities) + { + _capability = capability; } public Task Handle(CodeLensParams request, CancellationToken cancellationToken) @@ -57,14 +59,6 @@ public Task Handle(CodeLensParams request, CancellationToken return Task.FromResult(new CodeLensContainer(codeLensResults)); } - public TextDocumentRegistrationOptions GetRegistrationOptions() - { - return new TextDocumentRegistrationOptions - { - DocumentSelector = LspUtils.PowerShellDocumentSelector, - }; - } - public bool CanResolve(CodeLens value) { CodeLensData codeLensData = value.Data.ToObject(); diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs index 188a97ce32..de807b8ffe 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs @@ -21,6 +21,7 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { + // TODO: Use ABCs. internal class PsesCompletionHandler : ICompletionHandler, ICompletionResolveHandler { const int DefaultWaitTimeoutMilliseconds = 5000; @@ -51,17 +52,14 @@ public PsesCompletionHandler( _workspaceService = workspaceService; } - public CompletionRegistrationOptions GetRegistrationOptions() + protected override CompletionRegistrationOptions CreateRegistrationOptions(CompletionCapability capability, ClientCapabilities clientCapabilities) => new CompletionRegistrationOptions { - return new CompletionRegistrationOptions - { DocumentSelector = LspUtils.PowerShellDocumentSelector, ResolveProvider = true, TriggerCharacters = new[] { ".", "-", ":", "\\" } - }; - } + }; - public async Task Handle(CompletionParams request, CancellationToken cancellationToken) + public override async Task Handle(CompletionParams request, CancellationToken cancellationToken) { int cursorLine = request.Position.Line + 1; int cursorColumn = request.Position.Character + 1; @@ -117,7 +115,7 @@ public bool CanResolve(CompletionItem value) } // Handler for "completionItem/resolve". In VSCode this is fired when a completion item is highlighted in the completion list. - public async Task Handle(CompletionItem request, CancellationToken cancellationToken) + public async override Task Handle(CompletionItem request, CancellationToken cancellationToken) { // We currently only support this request for anything that returns a CommandInfo: functions, cmdlets, aliases. if (request.Kind != CompletionItemKind.Function) @@ -145,10 +143,11 @@ await CommandHelpers.GetCommandInfoAsync( if (commandInfo != null) { - request.Documentation = - await CommandHelpers.GetCommandSynopsisAsync( - commandInfo, - _powerShellContextService).ConfigureAwait(false); + return new CompletionItem() + { + // TODO: Do we need to fill in the rest of the fields? + Documentation = await CommandHelpers.GetCommandSynopsisAsync(commandInfo, _powerShellContextService).ConfigureAwait(false) + }; } // Send back the updated CompletionItem diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/FormattingHandlers.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/FormattingHandlers.cs index a229fbea92..0b78e91dce 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/FormattingHandlers.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/FormattingHandlers.cs @@ -17,6 +17,7 @@ namespace Microsoft.PowerShell.EditorServices.Handlers { // TODO: Add IDocumentOnTypeFormatHandler to support on-type formatting. + // TODO: Use ABCs. internal class PsesDocumentFormattingHandlers : IDocumentFormattingHandler, IDocumentRangeFormattingHandler { private readonly ILogger _logger;