Skip to content

Commit ffa27f8

Browse files
authored
Merge pull request #330 from PowerShell/daviwil/remote-sessions
Enable language and debugging features to use remote and attached runspaces
2 parents b2d444c + 22f17e3 commit ffa27f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1893
-311
lines changed

src/PowerShellEditorServices.Channel.WebSocket/WebsocketServerChannel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public class DebugAdapterWebSocketConnection : EditorServiceWebSocketConnection
151151
{
152152
public DebugAdapterWebSocketConnection()
153153
{
154-
Server = new DebugAdapter(null, null, Channel);
154+
Server = new DebugAdapter(null, null, Channel, null);
155155
}
156156
}
157157
}

src/PowerShellEditorServices.Host/EditorServicesHost.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ public void StartDebugService(int debugServicePort, ProfilePaths profilePaths)
164164
new DebugAdapter(
165165
hostDetails,
166166
profilePaths,
167-
new TcpSocketServerChannel(debugServicePort));
167+
new TcpSocketServerChannel(debugServicePort),
168+
this.languageServer?.EditorOperations);
168169

169170
this.debugAdapter.SessionEnded +=
170171
(obj, args) =>

src/PowerShellEditorServices.Protocol/DebugAdapter/AttachRequest.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ public static readonly
1616

1717
public class AttachRequestArguments
1818
{
19-
public string Address { get; set; }
19+
public string ComputerName { get; set; }
2020

21-
public int Port { get; set; }
21+
public int ProcessId { get; set; }
22+
23+
public int RunspaceId { get; set; }
2224
}
2325
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Copyright (c) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
4+
//
5+
6+
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
7+
8+
namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter
9+
{
10+
public class ContinuedEvent
11+
{
12+
public static readonly
13+
EventType<ContinuedEvent> Type =
14+
EventType<ContinuedEvent>.Create("continued");
15+
16+
public int ThreadId { get; set; }
17+
18+
public bool AllThreadsContinued { get; set; }
19+
}
20+
}

src/PowerShellEditorServices.Protocol/DebugAdapter/TerminatedEvent.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter
1010
public class TerminatedEvent
1111
{
1212
public static readonly
13-
EventType<object> Type =
14-
EventType<object>.Create("terminated");
13+
EventType<TerminatedEvent> Type =
14+
EventType<TerminatedEvent>.Create("terminated");
15+
16+
public bool Restart { get; set; }
1517
}
1618
}
1719

src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ public static readonly
108108
RequestType<string, EditorCommandResponse>.Create("editor/openFile");
109109
}
110110

111+
public class CloseFileRequest
112+
{
113+
public static readonly
114+
RequestType<string, EditorCommandResponse> Type =
115+
RequestType<string, EditorCommandResponse>.Create("editor/closeFile");
116+
}
117+
111118
public class ShowInformationMessageRequest
112119
{
113120
public static readonly

src/PowerShellEditorServices.Protocol/LanguageServer/PowerShellVersionRequest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer
1111
public class PowerShellVersionRequest
1212
{
1313
public static readonly
14-
RequestType<object, PowerShellVersionResponse> Type =
15-
RequestType<object, PowerShellVersionResponse>.Create("powerShell/getVersion");
14+
RequestType<object, PowerShellVersion> Type =
15+
RequestType<object, PowerShellVersion>.Create("powerShell/getVersion");
1616
}
1717

18-
public class PowerShellVersionResponse
18+
public class PowerShellVersion
1919
{
2020
public string Version { get; set; }
2121

@@ -25,11 +25,11 @@ public class PowerShellVersionResponse
2525

2626
public string Architecture { get; set; }
2727

28-
public PowerShellVersionResponse()
28+
public PowerShellVersion()
2929
{
3030
}
3131

32-
public PowerShellVersionResponse(PowerShellVersionDetails versionDetails)
32+
public PowerShellVersion(PowerShellVersionDetails versionDetails)
3333
{
3434
this.Version = versionDetails.VersionString;
3535
this.DisplayVersion = $"{versionDetails.Version.Major}.{versionDetails.Version.Minor}";
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// Copyright (c) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
4+
//
5+
6+
using Microsoft.PowerShell.EditorServices.Session;
7+
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
8+
9+
namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer
10+
{
11+
public class RunspaceChangedEvent
12+
{
13+
public static readonly
14+
EventType<RunspaceDetails> Type =
15+
EventType<RunspaceDetails>.Create("powerShell/runspaceChanged");
16+
}
17+
18+
public class RunspaceDetails
19+
{
20+
public PowerShellVersion PowerShellVersion { get; set; }
21+
22+
public RunspaceLocation RunspaceType { get; set; }
23+
24+
public string ConnectionString { get; set; }
25+
26+
public RunspaceDetails()
27+
{
28+
}
29+
30+
public RunspaceDetails(Session.RunspaceDetails eventArgs)
31+
{
32+
this.PowerShellVersion = new PowerShellVersion(eventArgs.PowerShellVersion);
33+
this.RunspaceType = eventArgs.Location;
34+
this.ConnectionString = eventArgs.ConnectionString;
35+
}
36+
}
37+
}

src/PowerShellEditorServices.Protocol/MessageProtocol/Channel/TcpSocketServerChannel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ protected override void Shutdown()
5151
{
5252
if (this.tcpListener != null)
5353
{
54+
this.networkStream.Dispose();
5455
this.tcpListener.Stop();
5556
this.tcpListener = null;
5657

src/PowerShellEditorServices.Protocol/MessageProtocol/MessageDispatcher.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public void Stop()
8989
{
9090
this.messageLoopCancellationToken.Cancel();
9191
this.messageLoopThread.Stop();
92+
SynchronizationContext.SetSynchronizationContext(null);
9293
}
9394
}
9495

0 commit comments

Comments
 (0)