Skip to content

Commit d342685

Browse files
authored
Merge pull request #244 from dfinke/master
Wired up Show Information|Warning|Error Message
2 parents 50ab29f + 5304a26 commit d342685

38 files changed

+1277
-103
lines changed

.gitmodules

Lines changed: 0 additions & 4 deletions
This file was deleted.

PowerShellEditorServices.NoNano.sln

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F594E7FD-1E7
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{422E561A-8118-4BE7-A54F-9309E4F03AAE}"
99
EndProject
10-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "submodules", "submodules", "{AF08DA0C-B0A6-47AD-AC55-E13C687D4A91}"
11-
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptAnalyzerEngine", "submodules\PSScriptAnalyzer\Engine\ScriptAnalyzerEngine.csproj", "{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}"
13-
EndProject
14-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptAnalyzerBuiltinRules", "submodules\PSScriptAnalyzer\Rules\ScriptAnalyzerBuiltinRules.csproj", "{C33B6B9D-E61C-45A3-9103-895FD82A5C1E}"
15-
EndProject
1610
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices", "src\PowerShellEditorServices\PowerShellEditorServices.csproj", "{81E8CBCD-6319-49E7-9662-0475BD0791F4}"
1711
EndProject
1812
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices.Host", "src\PowerShellEditorServices.Host\PowerShellEditorServices.Host.csproj", "{B2F6369A-D737-4AFD-8B81-9B094DB07DA7}"
@@ -53,14 +47,6 @@ Global
5347
Release|Any CPU = Release|Any CPU
5448
EndGlobalSection
5549
GlobalSection(ProjectConfigurationPlatforms) = postSolution
56-
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
57-
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Debug|Any CPU.Build.0 = Debug|Any CPU
58-
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Release|Any CPU.ActiveCfg = Release|Any CPU
59-
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Release|Any CPU.Build.0 = Release|Any CPU
60-
{C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
61-
{C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
62-
{C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
63-
{C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Release|Any CPU.Build.0 = Release|Any CPU
6450
{81E8CBCD-6319-49E7-9662-0475BD0791F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
6551
{81E8CBCD-6319-49E7-9662-0475BD0791F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
6652
{81E8CBCD-6319-49E7-9662-0475BD0791F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -102,8 +88,6 @@ Global
10288
HideSolutionNode = FALSE
10389
EndGlobalSection
10490
GlobalSection(NestedProjects) = preSolution
105-
{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60} = {AF08DA0C-B0A6-47AD-AC55-E13C687D4A91}
106-
{C33B6B9D-E61C-45A3-9103-895FD82A5C1E} = {AF08DA0C-B0A6-47AD-AC55-E13C687D4A91}
10791
{81E8CBCD-6319-49E7-9662-0475BD0791F4} = {EE0A010C-E246-49AE-92E7-AD4320C45086}
10892
{B2F6369A-D737-4AFD-8B81-9B094DB07DA7} = {EE0A010C-E246-49AE-92E7-AD4320C45086}
10993
{3A5DDD20-5BD0-42F4-89F4-ACC0CE554028} = {422E561A-8118-4BE7-A54F-9309E4F03AAE}

src/PowerShellEditorServices.Protocol/Client/DebugAdapterClientBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public async Task LaunchScript(string scriptFilePath)
2222
await this.SendRequest(
2323
LaunchRequest.Type,
2424
new LaunchRequestArguments {
25-
Program = scriptFilePath
25+
Script = scriptFilePath
2626
});
2727

2828
await this.SendRequest(ConfigurationDoneRequest.Type, null);

src/PowerShellEditorServices.Protocol/DebugAdapter/InitializeRequest.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,22 @@ public class InitializeResponseBody
4747
/// </summary>
4848
public bool SupportsConditionalBreakpoints { get; set; }
4949

50+
/// <summary>
51+
/// Gets or sets a boolean value that determines whether the debug adapter
52+
/// supports breakpoints that break execution after a specified number of hits.
53+
/// </summary>
54+
public bool SupportsHitConditionalBreakpoints { get; set; }
55+
5056
/// <summary>
5157
/// Gets or sets a boolean value that determines whether the debug adapter
5258
/// supports a (side effect free) evaluate request for data hovers.
5359
/// </summary>
5460
public bool SupportsEvaluateForHovers { get; set; }
61+
62+
/// <summary>
63+
/// Gets or sets a boolean value that determines whether the debug adapter
64+
/// supports allowing the user to set a variable from the Variables debug windows.
65+
/// </summary>
66+
public bool SupportsSetVariable { get; set; }
5567
}
5668
}

src/PowerShellEditorServices.Protocol/DebugAdapter/LaunchRequest.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
44
//
55

6+
using System;
67
using System.Collections.Generic;
78
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
89

@@ -20,8 +21,14 @@ public class LaunchRequestArguments
2021
/// <summary>
2122
/// Gets or sets the absolute path to the program to debug.
2223
/// </summary>
24+
[Obsolete("This property has been deprecated in favor of the Script property.")]
2325
public string Program { get; set; }
2426

27+
/// <summary>
28+
/// Gets or sets the absolute path to the script to debug.
29+
/// </summary>
30+
public string Script { get; set; }
31+
2532
/// <summary>
2633
/// Gets or sets a boolean value that indicates whether the script should be
2734
/// run with (false) or without (true) debugging support.

src/PowerShellEditorServices.Protocol/DebugAdapter/SetBreakpointsRequest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public class SourceBreakpoint
3434
public int? Column { get; set; }
3535

3636
public string Condition { get; set; }
37+
38+
public string HitCondition { get; set; }
3739
}
3840

3941
public class SetBreakpointsResponseBody

src/PowerShellEditorServices.Protocol/DebugAdapter/SetFunctionBreakpointsRequest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@ public class FunctionBreakpoint
2727
public string Name { get; set; }
2828

2929
public string Condition { get; set; }
30+
31+
public string HitCondition { get; set; }
3032
}
3133
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 System.Diagnostics;
7+
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
8+
9+
namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter
10+
{
11+
/// <summary>
12+
/// SetVariable request; value of command field is "setVariable".
13+
/// Request is initiated when user uses the debugger Variables UI to change the value of a variable.
14+
/// </summary>
15+
public class SetVariableRequest
16+
{
17+
public static readonly
18+
RequestType<SetVariableRequestArguments, SetVariableResponseBody> Type =
19+
RequestType<SetVariableRequestArguments, SetVariableResponseBody>.Create("setVariable");
20+
}
21+
22+
[DebuggerDisplay("VariablesReference = {VariablesReference}")]
23+
public class SetVariableRequestArguments
24+
{
25+
public int VariablesReference { get; set; }
26+
27+
public string Name { get; set; }
28+
29+
public string Value { get; set; }
30+
}
31+
32+
public class SetVariableResponseBody
33+
{
34+
public string Value { get; set; }
35+
}
36+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol;
2+
using Newtonsoft.Json.Linq;
3+
4+
namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer
5+
{
6+
public class CodeActionRequest
7+
{
8+
public static readonly
9+
RequestType<CodeActionRequest, CodeActionCommand[]> Type =
10+
RequestType<CodeActionRequest, CodeActionCommand[]>.Create("textDocument/codeAction");
11+
12+
public TextDocumentIdentifier TextDocument { get; set; }
13+
14+
public Range Range { get; set; }
15+
16+
public CodeActionContext Context { get; set; }
17+
}
18+
19+
public class CodeActionContext
20+
{
21+
public Diagnostic[] Diagnostics { get; set; }
22+
}
23+
24+
public class CodeActionCommand
25+
{
26+
public string Title { get; set; }
27+
28+
public string Command { get; set; }
29+
30+
public JArray Arguments { get; set; }
31+
}
32+
}

src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,40 @@ public static readonly
107107
RequestType<string, EditorCommandResponse> Type =
108108
RequestType<string, EditorCommandResponse>.Create("editor/openFile");
109109
}
110+
111+
public class ShowInformationMessageRequest
112+
{
113+
public static readonly
114+
RequestType<string, EditorCommandResponse> Type =
115+
RequestType<string, EditorCommandResponse>.Create("editor/showInformationMessage");
116+
}
117+
118+
public class ShowWarningMessageRequest
119+
{
120+
public static readonly
121+
RequestType<string, EditorCommandResponse> Type =
122+
RequestType<string, EditorCommandResponse>.Create("editor/showWarningMessage");
123+
}
124+
125+
public class ShowErrorMessageRequest
126+
{
127+
public static readonly
128+
RequestType<string, EditorCommandResponse> Type =
129+
RequestType<string, EditorCommandResponse>.Create("editor/showErrorMessage");
130+
}
131+
132+
public class SetStatusBarMessageRequest
133+
{
134+
public static readonly
135+
RequestType<StatusBarMessageDetails, EditorCommandResponse> Type =
136+
RequestType<StatusBarMessageDetails, EditorCommandResponse>.Create("editor/setStatusBarMessage");
137+
}
138+
139+
public class StatusBarMessageDetails
140+
{
141+
public string Message { get; set; }
142+
143+
public int? Timeout { get; set; }
144+
}
110145
}
111146

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
using Microsoft.PowerShell.EditorServices.Session;
8+
9+
namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer
10+
{
11+
public class PowerShellVersionRequest
12+
{
13+
public static readonly
14+
RequestType<object, PowerShellVersionResponse> Type =
15+
RequestType<object, PowerShellVersionResponse>.Create("powerShell/getVersion");
16+
}
17+
18+
public class PowerShellVersionResponse
19+
{
20+
public string Version { get; set; }
21+
22+
public string DisplayVersion { get; set; }
23+
24+
public string Edition { get; set; }
25+
26+
public string Architecture { get; set; }
27+
28+
public PowerShellVersionResponse()
29+
{
30+
}
31+
32+
public PowerShellVersionResponse(PowerShellVersionDetails versionDetails)
33+
{
34+
this.Version = versionDetails.VersionString;
35+
this.DisplayVersion = $"{versionDetails.Version.Major}.{versionDetails.Version.Minor}";
36+
this.Edition = versionDetails.Edition;
37+
38+
switch (versionDetails.Architecture)
39+
{
40+
case PowerShellProcessArchitecture.X64:
41+
this.Architecture = "x64";
42+
break;
43+
case PowerShellProcessArchitecture.X86:
44+
this.Architecture = "x86";
45+
break;
46+
default:
47+
this.Architecture = "Architecture Unknown";
48+
break;
49+
}
50+
}
51+
}
52+
}

src/PowerShellEditorServices.Protocol/LanguageServer/ServerCapabilities.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class ServerCapabilities
2424
public bool? DocumentSymbolProvider { get; set; }
2525

2626
public bool? WorkspaceSymbolProvider { get; set; }
27+
28+
public bool? CodeActionProvider { get; set; }
2729
}
2830

2931
/// <summary>

src/PowerShellEditorServices.Protocol/PowerShellEditorServices.Protocol.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,12 @@
5454
<Compile Include="DebugAdapter\ConfigurationDoneRequest.cs" />
5555
<Compile Include="DebugAdapter\ContinueRequest.cs" />
5656
<Compile Include="DebugAdapter\SetFunctionBreakpointsRequest.cs" />
57+
<Compile Include="DebugAdapter\SetVariableRequest.cs" />
5758
<Compile Include="LanguageServer\EditorCommands.cs" />
59+
<Compile Include="LanguageServer\CodeAction.cs" />
5860
<Compile Include="LanguageServer\FindModuleRequest.cs" />
5961
<Compile Include="LanguageServer\InstallModuleRequest.cs" />
62+
<Compile Include="LanguageServer\PowerShellVersionRequest.cs" />
6063
<Compile Include="MessageProtocol\Channel\NamedPipeClientChannel.cs" />
6164
<Compile Include="MessageProtocol\Channel\NamedPipeServerChannel.cs" />
6265
<Compile Include="MessageProtocol\Channel\TcpSocketClientChannel.cs" />
@@ -153,7 +156,7 @@
153156
</PropertyGroup>
154157
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
155158
</Target>
156-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
159+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
157160
Other similar extension points exist, see Microsoft.Common.targets.
158161
<Target Name="BeforeBuild">
159162
</Target>

0 commit comments

Comments
 (0)