Skip to content

Commit 68b44ce

Browse files
committed
Introduce service to the Extension
1 parent a3aa198 commit 68b44ce

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

src/PowerShellEditorServices/Server/PsesServiceCollectionExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public static IServiceCollection AddPsesLanguageServices(
5050
extensionService.InitializeAsync();
5151
return extensionService;
5252
})
53-
.AddSingleton<AnalysisService>();
53+
.AddSingleton<AnalysisService>()
54+
.AddSingleton<RenameService>();
5455
}
5556

5657
public static IServiceCollection AddPsesDebugServices(

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@
1111
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
1212
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
1313

14-
1514
namespace Microsoft.PowerShell.EditorServices.Handlers;
1615

1716
/// <summary>
1817
/// A handler for <a href="https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_prepareRename">textDocument/prepareRename</a>
19-
/// LSP Ref: <see cref="PrepareRename()"/>
2018
/// </summary>
2119
internal class PrepareRenameHandler
2220
(
23-
IRenameService renameService
21+
RenameService renameService
2422
) : IPrepareRenameHandler
2523
{
2624
public RenameRegistrationOptions GetRegistrationOptions(RenameCapability capability, ClientCapabilities clientCapabilities) => capability.PrepareSupport ? new() { PrepareProvider = true } : new();
@@ -30,11 +28,10 @@ IRenameService renameService
3028
}
3129

3230
/// <summary>
33-
/// A handler for textDocument/prepareRename
34-
/// <para />LSP Ref: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_rename
31+
/// A handler for <a href="https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_rename">textDocument/rename</a>
3532
/// </summary>
3633
internal class RenameHandler(
37-
IRenameService renameService
34+
RenameService renameService
3835
) : IRenameHandler
3936
{
4037
// RenameOptions may only be specified if the client states that it supports prepareSupport in its initial initialize request.

src/PowerShellEditorServices/Services/TextDocument/Services/RenameService.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,24 @@ ILanguageServerConfiguration config
4242
public async Task<RangeOrPlaceholderRange?> PrepareRenameSymbol(PrepareRenameParams request, CancellationToken cancellationToken)
4343
{
4444
// FIXME: Config actually needs to be read and implemented, this is to make the referencing satisfied
45-
config.ToString();
46-
ShowMessageRequestParams reqParams = new()
47-
{
48-
Type = MessageType.Warning,
49-
Message = "Test Send",
50-
Actions = new MessageActionItem[] {
51-
new MessageActionItem() { Title = "I Accept" },
52-
new MessageActionItem() { Title = "I Accept [Workspace]" },
53-
new MessageActionItem() { Title = "Decline" }
54-
}
55-
};
56-
57-
MessageActionItem result = await lsp.SendRequest(reqParams, cancellationToken).ConfigureAwait(false);
58-
if (result.Title == "Test Action")
59-
{
60-
// FIXME: Need to accept
61-
Console.WriteLine("yay");
62-
}
45+
// config.ToString();
46+
// ShowMessageRequestParams reqParams = new()
47+
// {
48+
// Type = MessageType.Warning,
49+
// Message = "Test Send",
50+
// Actions = new MessageActionItem[] {
51+
// new MessageActionItem() { Title = "I Accept" },
52+
// new MessageActionItem() { Title = "I Accept [Workspace]" },
53+
// new MessageActionItem() { Title = "Decline" }
54+
// }
55+
// };
56+
57+
// MessageActionItem result = await lsp.SendRequest(reqParams, cancellationToken).ConfigureAwait(false);
58+
// if (result.Title == "Test Action")
59+
// {
60+
// // FIXME: Need to accept
61+
// Console.WriteLine("yay");
62+
// }
6363

6464
ScriptFile scriptFile = workspaceService.GetFile(request.TextDocument.Uri);
6565

0 commit comments

Comments
 (0)