diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 1362f1c8d..000000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "submodules/PSScriptAnalyzer"] - path = submodules/PSScriptAnalyzer - url = https://github.com/PowerShell/PSScriptAnalyzer.git - branch = master diff --git a/PowerShellEditorServices.NoNano.sln b/PowerShellEditorServices.NoNano.sln index 0c1275321..94d330215 100644 --- a/PowerShellEditorServices.NoNano.sln +++ b/PowerShellEditorServices.NoNano.sln @@ -7,12 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F594E7FD-1E7 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{422E561A-8118-4BE7-A54F-9309E4F03AAE}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "submodules", "submodules", "{AF08DA0C-B0A6-47AD-AC55-E13C687D4A91}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptAnalyzerEngine", "submodules\PSScriptAnalyzer\Engine\ScriptAnalyzerEngine.csproj", "{F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptAnalyzerBuiltinRules", "submodules\PSScriptAnalyzer\Rules\ScriptAnalyzerBuiltinRules.csproj", "{C33B6B9D-E61C-45A3-9103-895FD82A5C1E}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices", "src\PowerShellEditorServices\PowerShellEditorServices.csproj", "{81E8CBCD-6319-49E7-9662-0475BD0791F4}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerShellEditorServices.Host", "src\PowerShellEditorServices.Host\PowerShellEditorServices.Host.csproj", "{B2F6369A-D737-4AFD-8B81-9B094DB07DA7}" @@ -53,14 +47,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60}.Release|Any CPU.Build.0 = Release|Any CPU - {C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C33B6B9D-E61C-45A3-9103-895FD82A5C1E}.Release|Any CPU.Build.0 = Release|Any CPU {81E8CBCD-6319-49E7-9662-0475BD0791F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {81E8CBCD-6319-49E7-9662-0475BD0791F4}.Debug|Any CPU.Build.0 = Debug|Any CPU {81E8CBCD-6319-49E7-9662-0475BD0791F4}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -102,8 +88,6 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {F4BDE3D0-3EEF-4157-8A3E-722DF7ADEF60} = {AF08DA0C-B0A6-47AD-AC55-E13C687D4A91} - {C33B6B9D-E61C-45A3-9103-895FD82A5C1E} = {AF08DA0C-B0A6-47AD-AC55-E13C687D4A91} {81E8CBCD-6319-49E7-9662-0475BD0791F4} = {EE0A010C-E246-49AE-92E7-AD4320C45086} {B2F6369A-D737-4AFD-8B81-9B094DB07DA7} = {EE0A010C-E246-49AE-92E7-AD4320C45086} {3A5DDD20-5BD0-42F4-89F4-ACC0CE554028} = {422E561A-8118-4BE7-A54F-9309E4F03AAE} diff --git a/src/PowerShellEditorServices.Protocol/Client/DebugAdapterClientBase.cs b/src/PowerShellEditorServices.Protocol/Client/DebugAdapterClientBase.cs index 5e6a1758b..5476edbe4 100644 --- a/src/PowerShellEditorServices.Protocol/Client/DebugAdapterClientBase.cs +++ b/src/PowerShellEditorServices.Protocol/Client/DebugAdapterClientBase.cs @@ -22,7 +22,7 @@ public async Task LaunchScript(string scriptFilePath) await this.SendRequest( LaunchRequest.Type, new LaunchRequestArguments { - Program = scriptFilePath + Script = scriptFilePath }); await this.SendRequest(ConfigurationDoneRequest.Type, null); diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializeRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializeRequest.cs index 16c99544e..c0c843fe4 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializeRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/InitializeRequest.cs @@ -47,10 +47,22 @@ public class InitializeResponseBody /// public bool SupportsConditionalBreakpoints { get; set; } + /// + /// Gets or sets a boolean value that determines whether the debug adapter + /// supports breakpoints that break execution after a specified number of hits. + /// + public bool SupportsHitConditionalBreakpoints { get; set; } + /// /// Gets or sets a boolean value that determines whether the debug adapter /// supports a (side effect free) evaluate request for data hovers. /// public bool SupportsEvaluateForHovers { get; set; } + + /// + /// Gets or sets a boolean value that determines whether the debug adapter + /// supports allowing the user to set a variable from the Variables debug windows. + /// + public bool SupportsSetVariable { get; set; } } } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/LaunchRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/LaunchRequest.cs index 5fa1cb10e..b81e56f8d 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/LaunchRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/LaunchRequest.cs @@ -3,6 +3,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. // +using System; using System.Collections.Generic; using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol; @@ -20,8 +21,14 @@ public class LaunchRequestArguments /// /// Gets or sets the absolute path to the program to debug. /// + [Obsolete("This property has been deprecated in favor of the Script property.")] public string Program { get; set; } + /// + /// Gets or sets the absolute path to the script to debug. + /// + public string Script { get; set; } + /// /// Gets or sets a boolean value that indicates whether the script should be /// run with (false) or without (true) debugging support. diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/SetBreakpointsRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/SetBreakpointsRequest.cs index a4993291d..5b0f88bf2 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/SetBreakpointsRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/SetBreakpointsRequest.cs @@ -34,6 +34,8 @@ public class SourceBreakpoint public int? Column { get; set; } public string Condition { get; set; } + + public string HitCondition { get; set; } } public class SetBreakpointsResponseBody diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/SetFunctionBreakpointsRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/SetFunctionBreakpointsRequest.cs index 434c6dd59..73b75f82e 100644 --- a/src/PowerShellEditorServices.Protocol/DebugAdapter/SetFunctionBreakpointsRequest.cs +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/SetFunctionBreakpointsRequest.cs @@ -27,5 +27,7 @@ public class FunctionBreakpoint public string Name { get; set; } public string Condition { get; set; } + + public string HitCondition { get; set; } } } diff --git a/src/PowerShellEditorServices.Protocol/DebugAdapter/SetVariableRequest.cs b/src/PowerShellEditorServices.Protocol/DebugAdapter/SetVariableRequest.cs new file mode 100644 index 000000000..333327454 --- /dev/null +++ b/src/PowerShellEditorServices.Protocol/DebugAdapter/SetVariableRequest.cs @@ -0,0 +1,36 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System.Diagnostics; +using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol; + +namespace Microsoft.PowerShell.EditorServices.Protocol.DebugAdapter +{ + /// + /// SetVariable request; value of command field is "setVariable". + /// Request is initiated when user uses the debugger Variables UI to change the value of a variable. + /// + public class SetVariableRequest + { + public static readonly + RequestType Type = + RequestType.Create("setVariable"); + } + + [DebuggerDisplay("VariablesReference = {VariablesReference}")] + public class SetVariableRequestArguments + { + public int VariablesReference { get; set; } + + public string Name { get; set; } + + public string Value { get; set; } + } + + public class SetVariableResponseBody + { + public string Value { get; set; } + } +} diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs new file mode 100644 index 000000000..deb0cb17f --- /dev/null +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/CodeAction.cs @@ -0,0 +1,32 @@ +using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol; +using Newtonsoft.Json.Linq; + +namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer +{ + public class CodeActionRequest + { + public static readonly + RequestType Type = + RequestType.Create("textDocument/codeAction"); + + public TextDocumentIdentifier TextDocument { get; set; } + + public Range Range { get; set; } + + public CodeActionContext Context { get; set; } + } + + public class CodeActionContext + { + public Diagnostic[] Diagnostics { get; set; } + } + + public class CodeActionCommand + { + public string Title { get; set; } + + public string Command { get; set; } + + public JArray Arguments { get; set; } + } +} diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs index cdd128135..f97b26ee1 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/EditorCommands.cs @@ -107,5 +107,40 @@ public static readonly RequestType Type = RequestType.Create("editor/openFile"); } + + public class ShowInformationMessageRequest + { + public static readonly + RequestType Type = + RequestType.Create("editor/showInformationMessage"); + } + + public class ShowWarningMessageRequest + { + public static readonly + RequestType Type = + RequestType.Create("editor/showWarningMessage"); + } + + public class ShowErrorMessageRequest + { + public static readonly + RequestType Type = + RequestType.Create("editor/showErrorMessage"); + } + + public class SetStatusBarMessageRequest + { + public static readonly + RequestType Type = + RequestType.Create("editor/setStatusBarMessage"); + } + + public class StatusBarMessageDetails + { + public string Message { get; set; } + + public int? Timeout { get; set; } + } } diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/PowerShellVersionRequest.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/PowerShellVersionRequest.cs new file mode 100644 index 000000000..37f7ce1b0 --- /dev/null +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/PowerShellVersionRequest.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol; +using Microsoft.PowerShell.EditorServices.Session; + +namespace Microsoft.PowerShell.EditorServices.Protocol.LanguageServer +{ + public class PowerShellVersionRequest + { + public static readonly + RequestType Type = + RequestType.Create("powerShell/getVersion"); + } + + public class PowerShellVersionResponse + { + public string Version { get; set; } + + public string DisplayVersion { get; set; } + + public string Edition { get; set; } + + public string Architecture { get; set; } + + public PowerShellVersionResponse() + { + } + + public PowerShellVersionResponse(PowerShellVersionDetails versionDetails) + { + this.Version = versionDetails.VersionString; + this.DisplayVersion = $"{versionDetails.Version.Major}.{versionDetails.Version.Minor}"; + this.Edition = versionDetails.Edition; + + switch (versionDetails.Architecture) + { + case PowerShellProcessArchitecture.X64: + this.Architecture = "x64"; + break; + case PowerShellProcessArchitecture.X86: + this.Architecture = "x86"; + break; + default: + this.Architecture = "Architecture Unknown"; + break; + } + } + } +} diff --git a/src/PowerShellEditorServices.Protocol/LanguageServer/ServerCapabilities.cs b/src/PowerShellEditorServices.Protocol/LanguageServer/ServerCapabilities.cs index 34ba312f8..aeebb411d 100644 --- a/src/PowerShellEditorServices.Protocol/LanguageServer/ServerCapabilities.cs +++ b/src/PowerShellEditorServices.Protocol/LanguageServer/ServerCapabilities.cs @@ -24,6 +24,8 @@ public class ServerCapabilities public bool? DocumentSymbolProvider { get; set; } public bool? WorkspaceSymbolProvider { get; set; } + + public bool? CodeActionProvider { get; set; } } /// diff --git a/src/PowerShellEditorServices.Protocol/PowerShellEditorServices.Protocol.csproj b/src/PowerShellEditorServices.Protocol/PowerShellEditorServices.Protocol.csproj index ea0bc7f84..c26ab8381 100644 --- a/src/PowerShellEditorServices.Protocol/PowerShellEditorServices.Protocol.csproj +++ b/src/PowerShellEditorServices.Protocol/PowerShellEditorServices.Protocol.csproj @@ -54,9 +54,12 @@ + + + @@ -153,7 +156,7 @@ -