Skip to content

Commit 3194f8a

Browse files
committed
TODO: Use ABCs in these classes.
1 parent 105bc89 commit 3194f8a

File tree

3 files changed

+20
-26
lines changed

3 files changed

+20
-26
lines changed

src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeLensHandlers.cs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
using Microsoft.PowerShell.EditorServices.Services;
1616
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
1717
using Microsoft.PowerShell.EditorServices.Utility;
18-
using OmniSharp.Extensions.LanguageServer.Protocol;
1918
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
2019
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
2120
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
2221

2322
namespace Microsoft.PowerShell.EditorServices.Handlers
2423
{
24+
// TODO: Use ABCs.
2525
internal class PsesCodeLensHandlers : ICodeLensHandler, ICodeLensResolveHandler
2626
{
2727
private readonly Guid _id = new Guid();
@@ -39,13 +39,15 @@ public PsesCodeLensHandlers(ILoggerFactory factory, SymbolsService symbolsServic
3939
_symbolsService = symbolsService;
4040
}
4141

42-
CodeLensRegistrationOptions IRegistration<CodeLensRegistrationOptions>.GetRegistrationOptions()
42+
public CodeLensRegistrationOptions GetRegistrationOptions(CodeLensCapability capability, ClientCapabilities clientCapabilities) => new CodeLensRegistrationOptions
4343
{
44-
return new CodeLensRegistrationOptions
45-
{
46-
DocumentSelector = LspUtils.PowerShellDocumentSelector,
47-
ResolveProvider = true
48-
};
44+
DocumentSelector = LspUtils.PowerShellDocumentSelector,
45+
ResolveProvider = true
46+
};
47+
48+
public void SetCapability(CodeLensCapability capability, ClientCapabilities clientCapabilities)
49+
{
50+
_capability = capability;
4951
}
5052

5153
public Task<CodeLensContainer> Handle(CodeLensParams request, CancellationToken cancellationToken)
@@ -57,14 +59,6 @@ public Task<CodeLensContainer> Handle(CodeLensParams request, CancellationToken
5759
return Task.FromResult(new CodeLensContainer(codeLensResults));
5860
}
5961

60-
public TextDocumentRegistrationOptions GetRegistrationOptions()
61-
{
62-
return new TextDocumentRegistrationOptions
63-
{
64-
DocumentSelector = LspUtils.PowerShellDocumentSelector,
65-
};
66-
}
67-
6862
public bool CanResolve(CodeLens value)
6963
{
7064
CodeLensData codeLensData = value.Data.ToObject<CodeLensData>();

src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
namespace Microsoft.PowerShell.EditorServices.Handlers
2323
{
24+
// TODO: Use ABCs.
2425
internal class PsesCompletionHandler : ICompletionHandler, ICompletionResolveHandler
2526
{
2627
const int DefaultWaitTimeoutMilliseconds = 5000;
@@ -51,17 +52,14 @@ public PsesCompletionHandler(
5152
_workspaceService = workspaceService;
5253
}
5354

54-
public CompletionRegistrationOptions GetRegistrationOptions()
55+
protected override CompletionRegistrationOptions CreateRegistrationOptions(CompletionCapability capability, ClientCapabilities clientCapabilities) => new CompletionRegistrationOptions
5556
{
56-
return new CompletionRegistrationOptions
57-
{
5857
DocumentSelector = LspUtils.PowerShellDocumentSelector,
5958
ResolveProvider = true,
6059
TriggerCharacters = new[] { ".", "-", ":", "\\" }
61-
};
62-
}
60+
};
6361

64-
public async Task<CompletionList> Handle(CompletionParams request, CancellationToken cancellationToken)
62+
public override async Task<CompletionList> Handle(CompletionParams request, CancellationToken cancellationToken)
6563
{
6664
int cursorLine = request.Position.Line + 1;
6765
int cursorColumn = request.Position.Character + 1;
@@ -117,7 +115,7 @@ public bool CanResolve(CompletionItem value)
117115
}
118116

119117
// 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)
121119
{
122120
// We currently only support this request for anything that returns a CommandInfo: functions, cmdlets, aliases.
123121
if (request.Kind != CompletionItemKind.Function)
@@ -145,10 +143,11 @@ await CommandHelpers.GetCommandInfoAsync(
145143

146144
if (commandInfo != null)
147145
{
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+
};
152151
}
153152

154153
// Send back the updated CompletionItem

src/PowerShellEditorServices/Services/TextDocument/Handlers/FormattingHandlers.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
namespace Microsoft.PowerShell.EditorServices.Handlers
1818
{
1919
// TODO: Add IDocumentOnTypeFormatHandler to support on-type formatting.
20+
// TODO: Use ABCs.
2021
internal class PsesDocumentFormattingHandlers : IDocumentFormattingHandler, IDocumentRangeFormattingHandler
2122
{
2223
private readonly ILogger _logger;

0 commit comments

Comments
 (0)