Skip to content
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

Update to use OmniSharp 0.19.0 #1424

Merged
merged 32 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
11d6aee
Bump OmniSharp.Extensions.LanguageServer from 0.18.3 to 0.19.0
dependabot-preview[bot] Mar 1, 2021
cf349c6
Bump OmniSharp.Extensions.DebugAdapter.Client from 0.18.3 to 0.19.0
dependabot-preview[bot] Mar 2, 2021
f1df5ba
Bump OmniSharp.Extensions.LanguageClient from 0.18.3 to 0.19.0
dependabot-preview[bot] Mar 2, 2021
d4d7216
Bump OmniSharp.Extensions.DebugAdapter.Server from 0.18.3 to 0.19.0
andyleejordan Mar 8, 2021
fbcdc23
Bump tests' dependency on xUnit to 2.4.1 (not pre-release)
andyleejordan Mar 24, 2021
5e92f61
Fix missing update to `PowerShellStandard.Library` 5.1.1
andyleejordan Mar 13, 2021
2dcd995
Fix rename of `Serializer` to `LspSerializer`
andyleejordan Mar 8, 2021
571b8c5
`AddLanguageProtocolLogging` no longer takes a log level argument
andyleejordan Mar 12, 2021
65e232f
Fix creation of `Breakpoint` since `Verified` is init-only now
andyleejordan Mar 12, 2021
d808201
Fix use of `ContinueHandlerBase` (has `Base` suffix now)
andyleejordan Mar 12, 2021
d518f1f
Fix use of `LaunchRequestArguments` and `AttachRequestArguments` (now…
andyleejordan Mar 12, 2021
327061f
Fix use of `ThreadsResponse` (type changed for threads container)
andyleejordan Mar 12, 2021
c8fac5d
Remove use of `Proposals` (gone)
andyleejordan Mar 12, 2021
017b1ca
Convert `PsesCodeActionHandler` to inherit `CodeActionHandlerBase`
andyleejordan Mar 12, 2021
fa979b3
Convert `PsesDocumentSymbolHandler` to inherit `DocumentSymbolHandler…
andyleejordan Mar 12, 2021
93b2ec0
Convert `PsesFoldingRangeHandler` to inherit `FoldingRangeHandlerBase`
andyleejordan Mar 12, 2021
d02193d
Fix registration for `PsesSemanticTokensHandler`
andyleejordan Mar 12, 2021
c5e6668
Convert `PsesReferencesHandler` to inherit `ReferencesHandlerBase`
andyleejordan Mar 12, 2021
b311d4e
Convert `PsesTextDocumentHandler` to inherit `TextDocumentSyncHandler…
andyleejordan Mar 12, 2021
01366bb
Convert `PsesWorkspaceSymbolsHandler` to inherit `WorkspaceSymbolsHan…
andyleejordan Mar 12, 2021
ebe2180
Convert `PsesConfigurationHandler` to inherit `DidChangeConfiguration…
andyleejordan Mar 12, 2021
ce01056
Convert `PsesDocumentHighlightHandler` to inherit `DocumentHighlightH…
andyleejordan Mar 12, 2021
ec0c893
Convert `PsesDefinitionHandler` to inherit `DefinitionHandlerBase`
andyleejordan Mar 12, 2021
57c5545
Convert `PsesSignatureHelpHandler` to inherit `SignatureHelpHandlerBase`
andyleejordan Mar 12, 2021
bdfa4d3
Convert `PsesHoverHandler` to inherit `HoverHandlerBase`
andyleejordan Mar 12, 2021
01a31f9
Fix `PsesCodeLensHandlers`
andyleejordan Mar 16, 2021
4c5b418
Fix `PsesCompletionHandler`
andyleejordan Mar 16, 2021
ba9d416
Fix `PsesDocumentFormattingHandlers`
andyleejordan Mar 16, 2021
2762fea
Document "method lacks 'await'" warnings
andyleejordan Mar 16, 2021
f22259e
Fix tests
andyleejordan Mar 16, 2021
f332ce1
Use C# version 9.0
andyleejordan Mar 16, 2021
3ae17e8
Fix `TelemetryEventParams`
andyleejordan Mar 16, 2021
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
1 change: 1 addition & 0 deletions PowerShellEditorServices.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<VersionSuffix>preview.1</VersionSuffix>
<Company>Microsoft</Company>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<LangVersion>9.0</LangVersion>
<PackageTags>PowerShell;editor;development;language;debugging</PackageTags>
<PackageLicenseUrl>https://raw.githubusercontent.com/PowerShell/PowerShellEditorServices/master/LICENSE</PackageLicenseUrl>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), PowerShellEditorServices.Common.props))\PowerShellEditorServices.Common.props" />

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net461</TargetFrameworks>
<AssemblyName>Microsoft.PowerShell.EditorServices.Hosting</AssemblyName>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<ItemGroup>
<ProjectReference Include="..\PowerShellEditorServices\PowerShellEditorServices.csproj" />
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0">
<PackageReference Include="PowerShellStandard.Library" Version="5.1.1">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/PowerShellEditorServices/Logging/PsesTelemetryEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
namespace Microsoft.PowerShell.EditorServices.Logging
{
// This inheirits from Dictionary so that it can be passed in to SendTelemetryEvent()
// which takes in an IDictionary<string, JToken>
// which takes in an IDictionary<string, object>
// However, I wanted creation to be easy so you can do
// new PsesTelemetryEvent { EventName = "eventName", Data = data }
internal class PsesTelemetryEvent : Dictionary<string, JToken>
internal class PsesTelemetryEvent : Dictionary<string, object>
{
public string EventName
{
Expand Down
14 changes: 2 additions & 12 deletions src/PowerShellEditorServices/PowerShellEditorServices.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,9 @@
<Description>Provides common PowerShell editor capabilities as a .NET library.</Description>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<AssemblyName>Microsoft.PowerShell.EditorServices</AssemblyName>
<LangVersion>Latest</LangVersion>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<LangVersion>latest</LangVersion>
<CheckForOverflowUnderflow></CheckForOverflowUnderflow>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Microsoft.PowerShell.EditorServices.Hosting</_Parameter1>
Expand All @@ -39,8 +29,8 @@
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.18.3" />
<PackageReference Include="OmniSharp.Extensions.DebugAdapter.Server" Version="0.18.3" />
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.19.0" />
<PackageReference Include="OmniSharp.Extensions.DebugAdapter.Server" Version="0.19.0" />
<PackageReference Include="PowerShellStandard.Library" Version="5.1.1" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
Expand Down
3 changes: 2 additions & 1 deletion src/PowerShellEditorServices/Server/PsesLanguageServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public async Task StartAsync()
.AddPsesLanguageServices(_hostDetails))
.ConfigureLogging(builder => builder
.AddSerilog(Log.Logger)
.AddLanguageProtocolLogging(_minimumLogLevel)
.AddLanguageProtocolLogging()
.SetMinimumLevel(_minimumLogLevel))
.WithHandler<PsesWorkspaceSymbolsHandler>()
.WithHandler<PsesTextDocumentHandler>()
Expand All @@ -94,6 +94,7 @@ public async Task StartAsync()
.WithHandler<ExpandAliasHandler>()
.WithHandler<PsesSemanticTokensHandler>()
.OnInitialize(
// TODO: Either fix or ignore "method lacks 'await'" warning.
async (languageServer, request, cancellationToken) =>
{
var serviceProvider = languageServer.Services;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile
Data = JToken.FromObject(new {
Uri = scriptFile.DocumentUri,
ProviderId = nameof(PesterCodeLensProvider)
}, Serializer.Instance.JsonSerializer),
}, LspSerializer.Instance.JsonSerializer),
Command = new Command()
{
Name = "PowerShell.RunPesterTests",
Expand All @@ -66,7 +66,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile
false /* No debug */,
pesterSymbol.TestName,
pesterSymbol.ScriptRegion?.StartLineNumber
}, Serializer.Instance.JsonSerializer)
}, LspSerializer.Instance.JsonSerializer)
}
},

Expand All @@ -76,7 +76,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile
Data = JToken.FromObject(new {
Uri = scriptFile.DocumentUri,
ProviderId = nameof(PesterCodeLensProvider)
}, Serializer.Instance.JsonSerializer),
}, LspSerializer.Instance.JsonSerializer),
Command = new Command()
{
Name = "PowerShell.RunPesterTests",
Expand All @@ -88,7 +88,7 @@ private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile
pesterSymbol.TestName,
pesterSymbol.ScriptRegion?.StartLineNumber
},
Serializer.Instance.JsonSerializer)
LspSerializer.Instance.JsonSerializer)
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public CodeLens[] ProvideCodeLenses(ScriptFile scriptFile)
{
Uri = scriptFile.DocumentUri,
ProviderId = nameof(ReferencesCodeLensProvider)
}, Serializer.Instance.JsonSerializer),
}, LspSerializer.Instance.JsonSerializer),
Range = sym.ScriptRegion.ToRange()
});
}
Expand Down Expand Up @@ -145,7 +145,7 @@ public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile)
codeLens.Range.Start,
referenceLocations
},
Serializer.Instance.JsonSerializer)
LspSerializer.Instance.JsonSerializer)
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ private void DebugService_BreakpointUpdated(object sender, BreakpointUpdatedEven
break;
}

OmniSharp.Extensions.DebugAdapter.Protocol.Models.Breakpoint breakpoint;
var breakpoint = new OmniSharp.Extensions.DebugAdapter.Protocol.Models.Breakpoint
{
Verified = e.UpdateType != BreakpointUpdateType.Disabled
};

if (e.Breakpoint is LineBreakpoint)
{
breakpoint = LspDebugUtils.CreateBreakpoint(BreakpointDetails.Create(e.Breakpoint));
Expand All @@ -162,8 +166,6 @@ private void DebugService_BreakpointUpdated(object sender, BreakpointUpdatedEven
return;
}

breakpoint.Verified = e.UpdateType != BreakpointUpdateType.Disabled;

_debugAdapterServer.SendNotification(EventNames.Breakpoint,
new BreakpointEvent
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Microsoft.PowerShell.EditorServices.Handlers
{
// TODO: Inherit from ABCs instead of satisfying interfaces.
internal class DebuggerActionHandlers : IContinueHandler, INextHandler, IPauseHandler, IStepInHandler, IStepOutHandler
{
private readonly ILogger _logger;
Expand All @@ -22,7 +23,7 @@ public DebuggerActionHandlers(
ILoggerFactory loggerFactory,
DebugService debugService)
{
_logger = loggerFactory.CreateLogger<ContinueHandler>();
_logger = loggerFactory.CreateLogger<ContinueHandlerBase>();
_debugService = debugService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

namespace Microsoft.PowerShell.EditorServices.Handlers
{
internal class PsesLaunchRequestArguments : LaunchRequestArguments
internal record PsesLaunchRequestArguments : LaunchRequestArguments
{
/// <summary>
/// Gets or sets the absolute path to the script to debug.
Expand Down Expand Up @@ -70,7 +70,7 @@ internal class PsesLaunchRequestArguments : LaunchRequestArguments
public Dictionary<string, string> Env { get; set; }
}

internal class PsesAttachRequestArguments : AttachRequestArguments
internal record PsesAttachRequestArguments : AttachRequestArguments
{
public string ComputerName { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@ public Task<ThreadsResponse> Handle(ThreadsArguments request, CancellationToken
{
return Task.FromResult(new ThreadsResponse
{
// TODO: What do I do with these?
Threads = new Container<OmniSharp.Extensions.DebugAdapter.Protocol.Models.Thread>(
new OmniSharp.Extensions.DebugAdapter.Protocol.Models.Thread
{
Id = 1,
Name = "Main Thread"
})
// TODO: This is an empty container of threads...do we need to make a thread?
Threads = new Container<System.Threading.Thread>()
Copy link
Member Author

Choose a reason for hiding this comment

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

I thought this was weird, but we already didn't really know what to do with it (see "What do I do with these?")

});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,46 +19,38 @@

namespace Microsoft.PowerShell.EditorServices.Handlers
{
internal class PsesCodeActionHandler : ICodeActionHandler
internal class PsesCodeActionHandler : CodeActionHandlerBase
{
private static readonly CodeActionKind[] s_supportedCodeActions = new[]
{
CodeActionKind.QuickFix
};

private readonly CodeActionRegistrationOptions _registrationOptions;

private readonly ILogger _logger;

private readonly AnalysisService _analysisService;

private readonly WorkspaceService _workspaceService;

private CodeActionCapability _capability;

public PsesCodeActionHandler(ILoggerFactory factory, AnalysisService analysisService, WorkspaceService workspaceService)
{
_logger = factory.CreateLogger<PsesCodeActionHandler>();
_analysisService = analysisService;
_workspaceService = workspaceService;
_registrationOptions = new CodeActionRegistrationOptions
{
DocumentSelector = LspUtils.PowerShellDocumentSelector,
CodeActionKinds = s_supportedCodeActions
};
}

public CodeActionRegistrationOptions GetRegistrationOptions()
{
return _registrationOptions;
}
protected override CodeActionRegistrationOptions CreateRegistrationOptions(CodeActionCapability capability, ClientCapabilities clientCapabilities) => new CodeActionRegistrationOptions
{
// TODO: What do we do with the arguments?
DocumentSelector = LspUtils.PowerShellDocumentSelector,
CodeActionKinds = new CodeActionKind[] { CodeActionKind.QuickFix }
};

public void SetCapability(CodeActionCapability capability)
// TODO: Either fix or ignore "method lacks 'await'" warning.
public override async Task<CodeAction> Handle(CodeAction request, CancellationToken cancellationToken)
{
_capability = capability;
// TODO: How on earth do we handle a CodeAction? This is new...
if (cancellationToken.IsCancellationRequested)
{
_logger.LogDebug("CodeAction request canceled for: {0}", request.Title);
}
return request;
}

public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request, CancellationToken cancellationToken)
public override async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request, CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested)
{
Expand Down Expand Up @@ -101,7 +93,7 @@ public async Task<CommandOrCodeActionContainer> Handle(CodeActionParams request,
new WorkspaceEditDocumentChange(
new TextDocumentEdit
{
TextDocument = new VersionedTextDocumentIdentifier
TextDocument = new OptionalVersionedTextDocumentIdentifier
{
Uri = request.TextDocument.Uri
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@
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;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;

namespace Microsoft.PowerShell.EditorServices.Handlers
{
// TODO: Use ABCs.
internal class PsesCodeLensHandlers : ICodeLensHandler, ICodeLensResolveHandler
{
private readonly Guid _id = new Guid();
private readonly ILogger _logger;
private readonly SymbolsService _symbolsService;
private readonly WorkspaceService _workspaceService;

private CodeLensCapability _capability;
public Guid Id => _id;
private readonly Guid _id = Guid.NewGuid();
Guid ICanBeIdentifiedHandler.Id => _id;

public PsesCodeLensHandlers(ILoggerFactory factory, SymbolsService symbolsService, WorkspaceService workspaceService, ConfigurationService configurationService)
{
Expand All @@ -39,13 +38,15 @@ public PsesCodeLensHandlers(ILoggerFactory factory, SymbolsService symbolsServic
_symbolsService = symbolsService;
}

CodeLensRegistrationOptions IRegistration<CodeLensRegistrationOptions>.GetRegistrationOptions()
public CodeLensRegistrationOptions GetRegistrationOptions(CodeLensCapability capability, ClientCapabilities clientCapabilities) => new CodeLensRegistrationOptions
{
return new CodeLensRegistrationOptions
{
DocumentSelector = LspUtils.PowerShellDocumentSelector,
ResolveProvider = true
};
DocumentSelector = LspUtils.PowerShellDocumentSelector,
ResolveProvider = true
};

public void SetCapability(CodeLensCapability capability, ClientCapabilities clientCapabilities)
{
_capability = capability;
}

public Task<CodeLensContainer> Handle(CodeLensParams request, CancellationToken cancellationToken)
Expand All @@ -57,14 +58,6 @@ public Task<CodeLensContainer> Handle(CodeLensParams request, CancellationToken
return Task.FromResult(new CodeLensContainer(codeLensResults));
}

public TextDocumentRegistrationOptions GetRegistrationOptions()
{
return new TextDocumentRegistrationOptions
{
DocumentSelector = LspUtils.PowerShellDocumentSelector,
};
}

public bool CanResolve(CodeLens value)
{
CodeLensData codeLensData = value.Data.ToObject<CodeLensData>();
Expand Down
Loading