mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-18 01:25:41 -05:00
Initial commit of SqlTools Service API
This commit is contained in:
73
ServiceHost/Server/DebugAdapterBase.cs
Normal file
73
ServiceHost/Server/DebugAdapterBase.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
#if false
|
||||
using Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter;
|
||||
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
|
||||
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.Channel;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.PowerShell.EditorServices.Protocol.Server
|
||||
{
|
||||
public abstract class DebugAdapterBase : ProtocolEndpoint
|
||||
{
|
||||
public DebugAdapterBase(ChannelBase serverChannel)
|
||||
: base (serverChannel, MessageProtocolType.DebugAdapter)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overridden by the subclass to provide initialization
|
||||
/// logic after the server channel is started.
|
||||
/// </summary>
|
||||
protected abstract void Initialize();
|
||||
|
||||
/// <summary>
|
||||
/// Can be overridden by the subclass to provide shutdown
|
||||
/// logic before the server exits.
|
||||
/// </summary>
|
||||
protected virtual void Shutdown()
|
||||
{
|
||||
// No default implementation yet.
|
||||
}
|
||||
|
||||
protected override Task OnStart()
|
||||
{
|
||||
// Register handlers for server lifetime messages
|
||||
this.SetRequestHandler(InitializeRequest.Type, this.HandleInitializeRequest);
|
||||
|
||||
// Initialize the implementation class
|
||||
this.Initialize();
|
||||
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
protected override Task OnStop()
|
||||
{
|
||||
this.Shutdown();
|
||||
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
private async Task HandleInitializeRequest(
|
||||
object shutdownParams,
|
||||
RequestContext<InitializeResponseBody> requestContext)
|
||||
{
|
||||
// Now send the Initialize response to continue setup
|
||||
await requestContext.SendResult(
|
||||
new InitializeResponseBody {
|
||||
SupportsConfigurationDoneRequest = true,
|
||||
SupportsConditionalBreakpoints = true,
|
||||
SupportsFunctionBreakpoints = true
|
||||
});
|
||||
|
||||
// Send the Initialized event so that we get breakpoints
|
||||
await requestContext.SendEvent(
|
||||
InitializedEvent.Type,
|
||||
null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user