Skip to content

Commit 2fcadd8

Browse files
justinytchenJustin ChenTylerLeonhardt
authored
Updated Semantic Handler to work with new LSP (#1343)
* change to v0.17.3 * fixed E2E tests * changed from hard code length * bumped version to 0.17.4 * Update src/PowerShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokensHandler.cs Co-authored-by: Tyler James Leonhardt <[email protected]> Co-authored-by: Justin Chen <[email protected]> Co-authored-by: Tyler James Leonhardt <[email protected]>
1 parent c407343 commit 2fcadd8

File tree

5 files changed

+12
-14
lines changed

5 files changed

+12
-14
lines changed

src/PowerShellEditorServices/PowerShellEditorServices.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
4040
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="3.1.6" />
4141
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.6" />
42-
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.17.2" />
42+
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.17.4" />
4343
<PackageReference Include="OmniSharp.Extensions.DebugAdapter.Server" Version="0.17.2" />
4444
<PackageReference Include="PowerShellStandard.Library" Version="5.1.1" />
4545
<PackageReference Include="Serilog" Version="2.9.0" />

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
using Microsoft.PowerShell.EditorServices.Utility;
1313
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
1414
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
15-
using OmniSharp.Extensions.LanguageServer.Server;
15+
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
1616

1717
namespace Microsoft.PowerShell.EditorServices.Handlers
1818
{

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

+7-9
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,24 @@
1212
using Microsoft.PowerShell.EditorServices.Services;
1313
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
1414
using Microsoft.PowerShell.EditorServices.Utility;
15-
using OmniSharp.Extensions.LanguageServer.Protocol;
15+
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
1616
using OmniSharp.Extensions.LanguageServer.Protocol.Document.Proposals;
1717
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
1818
using OmniSharp.Extensions.LanguageServer.Protocol.Models.Proposals;
1919

2020
namespace Microsoft.PowerShell.EditorServices.Handlers
2121
{
22-
internal class PsesSemanticTokensHandler : SemanticTokensHandler
22+
internal class PsesSemanticTokensHandler : SemanticTokensHandlerBase
2323
{
2424
private static readonly SemanticTokensRegistrationOptions s_registrationOptions = new SemanticTokensRegistrationOptions
2525
{
2626
DocumentSelector = LspUtils.PowerShellDocumentSelector,
2727
Legend = new SemanticTokensLegend(),
28-
DocumentProvider = new Supports<SemanticTokensDocumentProviderOptions>(
29-
isSupported: true,
30-
new SemanticTokensDocumentProviderOptions
31-
{
32-
Edits = true
33-
}),
34-
RangeProvider = true
28+
Full = new SemanticTokensCapabilityRequestFull
29+
{
30+
Delta = true
31+
},
32+
Range = true
3533
};
3634

3735
private readonly ILogger _logger;

test/PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ public async Task CanSendSemanticTokenRequest()
11471147
SemanticTokens result =
11481148
await PsesLanguageClient
11491149
.SendRequest<SemanticTokensParams>(
1150-
"textDocument/semanticTokens",
1150+
"textDocument/semanticTokens/full",
11511151
new SemanticTokensParams
11521152
{
11531153
TextDocument = new TextDocumentIdentifier
@@ -1162,7 +1162,7 @@ await PsesLanguageClient
11621162
var expectedArr = new int[5]
11631163
{
11641164
// line, index, token length, token type, token modifiers
1165-
0, 0, scriptContent.Length, 2, 0 //function token: line 0, index 0, length, type 2 = keyword, no modifiers
1165+
0, 0, scriptContent.Length, 1, 0 //function token: line 0, index 0, length of script, type 1 = keyword, no modifiers
11661166
};
11671167

11681168
Assert.Equal(expectedArr, result.Data.ToArray());

test/PowerShellEditorServices.Test/PowerShellEditorServices.Test.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
2929
<PackageReference Include="xunit" Version="2.4.1-pre.build.4059" />
3030
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
31-
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.17.2" />
31+
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.17.4" />
3232
<DotNetCliToolReference Include="dotnet-xunit" Version="2.4.0-beta.1.build3958" />
3333
</ItemGroup>
3434
<ItemGroup>

0 commit comments

Comments
 (0)