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 3 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.3" />
<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 @@ -91,7 +91,7 @@ private async Task CheckPackageManagement()

if (_powerShellContextService.CurrentRunspace.Runspace.SessionStateProxy.LanguageMode != PSLanguageMode.FullLanguage)
{
_languageServer.Window.ShowWarning("You have an older version of PackageManagement known to cause issues with the PowerShell extension. Please run the following command in a new Windows PowerShell session and then restart the PowerShell extension: `Install-Module PackageManagement -Force -AllowClobber -MinimumVersion 1.4.6`");
_languageServer.Window.LogWarning("You have an older version of PackageManagement known to cause issues with the PowerShell extension. Please run the following command in a new Windows PowerShell session and then restart the PowerShell extension: `Install-Module PackageManagement -Force -AllowClobber -MinimumVersion 1.4.6`");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right... the spec says there's a ShowMessage and a LogMessage...

https://microsoft.github.io/language-server-protocol/specifications/specification-current/#window_showMessage

@david-driscoll did this API change?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... not intentionally.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taking a look at the assembly.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I deleted one to many methods!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will bring those back and get 0.17.4 out to fix that.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a work around for the moment you can use ShowMessage and give it the correct message type.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New package is out, this should restore that function.
https://www.nuget.org/packages/OmniSharp.Extensions.LanguageServer/0.17.4

return;
}

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.3" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.4.0-beta.1.build3958" />
</ItemGroup>
<ItemGroup>
Expand Down