Skip to content

Updated Semantic Handler to work with new LSP #1343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="3.1.6" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.6" />
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.17.2" />
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.17.4" />
<PackageReference Include="OmniSharp.Extensions.DebugAdapter.Server" Version="0.17.2" />
<PackageReference Include="PowerShellStandard.Library" Version="5.1.1" />
<PackageReference Include="Serilog" Version="2.9.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using Microsoft.PowerShell.EditorServices.Utility;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Server;
using OmniSharp.Extensions.LanguageServer.Protocol.Document;

namespace Microsoft.PowerShell.EditorServices.Handlers
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,23 @@
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.Proposals;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
using OmniSharp.Extensions.LanguageServer.Protocol.Models.Proposals;

namespace Microsoft.PowerShell.EditorServices.Handlers
{
internal class PsesSemanticTokensHandler : SemanticTokensHandler
internal class PsesSemanticTokensHandler : SemanticTokensHandlerBase
{
private static readonly SemanticTokensRegistrationOptions s_registrationOptions = new SemanticTokensRegistrationOptions
{
DocumentSelector = LspUtils.PowerShellDocumentSelector,
Legend = new SemanticTokensLegend(),
DocumentProvider = new Supports<SemanticTokensDocumentProviderOptions>(
isSupported: true,
new SemanticTokensDocumentProviderOptions
{
Edits = true
}),
RangeProvider = true
Full = new SemanticTokensCapabilityRequestFull() {
Delta = true
},
Range = true
};

private readonly ILogger _logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ public async Task CanSendSemanticTokenRequest()
SemanticTokens result =
await PsesLanguageClient
.SendRequest<SemanticTokensParams>(
"textDocument/semanticTokens",
"textDocument/semanticTokens/full",
new SemanticTokensParams
{
TextDocument = new TextDocumentIdentifier
Expand All @@ -1162,7 +1162,7 @@ await PsesLanguageClient
var expectedArr = new int[5]
{
// line, index, token length, token type, token modifiers
0, 0, scriptContent.Length, 2, 0 //function token: line 0, index 0, length, type 2 = keyword, no modifiers
0, 0, scriptContent.Length, 1, 0 //function token: line 0, index 0, length of script, type 1 = keyword, no modifiers
};

Assert.Equal(expectedArr, result.Data.ToArray());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="xunit" Version="2.4.1-pre.build.4059" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.17.2" />
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.17.4" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.4.0-beta.1.build3958" />
</ItemGroup>
<ItemGroup>
Expand Down