-
Notifications
You must be signed in to change notification settings - Fork 237
Move to Omnisharp lib 0.18.x #1376
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
Changes from 11 commits
ae1e6ee
7a85810
03572f6
36c53e7
16f0a47
0c2107a
2e152ed
46b3329
984cf55
7e04076
8a0c6fd
e25a112
59b9eea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,9 @@ | |
using Microsoft.PowerShell.EditorServices.Handlers; | ||
using Microsoft.PowerShell.EditorServices.Services; | ||
using Microsoft.PowerShell.EditorServices.Utility; | ||
using OmniSharp.Extensions.DebugAdapter.Protocol; | ||
using OmniSharp.Extensions.DebugAdapter.Protocol.Serialization; | ||
using OmniSharp.Extensions.DebugAdapter.Server; | ||
using OmniSharp.Extensions.JsonRpc; | ||
using OmniSharp.Extensions.LanguageServer.Server; | ||
|
||
|
@@ -41,7 +43,7 @@ internal class PsesDebugServer : IDisposable | |
private readonly bool _usePSReadLine; | ||
private readonly TaskCompletionSource<bool> _serverStopped; | ||
|
||
private IJsonRpcServer _jsonRpcServer; | ||
private DebugAdapterServer _debugAdapterServer; | ||
private PowerShellContextService _powerShellContextService; | ||
|
||
protected readonly ILoggerFactory _loggerFactory; | ||
|
@@ -71,12 +73,9 @@ public PsesDebugServer( | |
/// <returns>A task that completes when the server is ready.</returns> | ||
public async Task StartAsync() | ||
{ | ||
_jsonRpcServer = await JsonRpcServer.From(options => | ||
_debugAdapterServer = await DebugAdapterServer.From(options => | ||
{ | ||
options.Serializer = new DapProtocolSerializer(); | ||
options.Receiver = new DapReceiver(); | ||
options.LoggerFactory = _loggerFactory; | ||
ILogger logger = options.LoggerFactory.CreateLogger("DebugOptionsStartup"); | ||
options.WithSerializer(new DapProtocolSerializer()); | ||
|
||
// We need to let the PowerShell Context Service know that we are in a debug session | ||
// so that it doesn't send the powerShell/startDebugger message. | ||
|
@@ -97,45 +96,49 @@ public async Task StartAsync() | |
.GetResult(); | ||
} | ||
|
||
options.Services = new ServiceCollection() | ||
.AddPsesDebugServices(ServiceProvider, this, _useTempSession); | ||
|
||
options | ||
.WithInput(_inputStream) | ||
.WithOutput(_outputStream); | ||
|
||
logger.LogInformation("Adding handlers"); | ||
|
||
options | ||
.WithHandler<InitializeHandler>() | ||
.WithHandler<LaunchHandler>() | ||
.WithHandler<AttachHandler>() | ||
.WithOutput(_outputStream) | ||
.WithServices(serviceCollection => serviceCollection | ||
.AddLogging() | ||
.AddOptions() | ||
.AddPsesDebugServices(ServiceProvider, this, _useTempSession)) | ||
.WithHandler<LaunchAndAttachHandler>() | ||
.WithHandler<DisconnectHandler>() | ||
.WithHandler<SetFunctionBreakpointsHandler>() | ||
.WithHandler<SetExceptionBreakpointsHandler>() | ||
.WithHandler<BreakpointHandlers>() | ||
.WithHandler<ConfigurationDoneHandler>() | ||
.WithHandler<ThreadsHandler>() | ||
.WithHandler<SetBreakpointsHandler>() | ||
.WithHandler<StackTraceHandler>() | ||
.WithHandler<ScopesHandler>() | ||
.WithHandler<VariablesHandler>() | ||
.WithHandler<ContinueHandler>() | ||
.WithHandler<NextHandler>() | ||
.WithHandler<PauseHandler>() | ||
.WithHandler<StepInHandler>() | ||
.WithHandler<StepOutHandler>() | ||
.WithHandler<DebuggerActionHandlers>() | ||
.WithHandler<SourceHandler>() | ||
.WithHandler<SetVariableHandler>() | ||
.WithHandler<DebugEvaluateHandler>(); | ||
|
||
logger.LogInformation("Handlers added"); | ||
.WithHandler<DebugEvaluateHandler>() | ||
.OnInitialize(async (server, request, cancellationToken) => { | ||
var breakpointService = server.GetService<BreakpointService>(); | ||
// Clear any existing breakpoints before proceeding | ||
await breakpointService.RemoveAllBreakpointsAsync().ConfigureAwait(false); | ||
}) | ||
.OnInitialized((server, request, response, cancellationToken) => { | ||
response.SupportsConditionalBreakpoints = true; | ||
response.SupportsConfigurationDoneRequest = true; | ||
response.SupportsFunctionBreakpoints = true; | ||
response.SupportsHitConditionalBreakpoints = true; | ||
response.SupportsLogPoints = true; | ||
response.SupportsSetVariable = true; | ||
|
||
return Task.CompletedTask; | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the difference between these? Which of them handles the Initialize request? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added comments in a few places to explain what we're doing here... it's a bit confusing. @david-driscoll says it's cause we're weird 😛 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming things is hard... so I just stuck with the protocol naming for the events. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to do some more documentation on how things work, it's on my list. |
||
}).ConfigureAwait(false); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_powerShellContextService.IsDebugServerActive = false; | ||
_jsonRpcServer.Dispose(); | ||
_debugAdapterServer.Dispose(); | ||
_inputStream.Dispose(); | ||
_outputStream.Dispose(); | ||
_serverStopped.SetResult(true); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line won't be needed for 0.18.2