Skip to content

The entire Debug Adapter moved over... #1043

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

Merged
2 changes: 2 additions & 0 deletions PowerShellEditorServices.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ $script:RequiredBuildAssets = @{
'publish/OmniSharp.Extensions.JsonRpc.dll',
'publish/OmniSharp.Extensions.LanguageProtocol.dll',
'publish/OmniSharp.Extensions.LanguageServer.dll',
'publish/OmniSharp.Extensions.DebugAdapter.dll',
'publish/OmniSharp.Extensions.DebugAdapter.Server.dll',
'publish/runtimes/linux-64/native/libdisablekeyecho.so',
'publish/runtimes/osx-64/native/libdisablekeyecho.dylib',
'publish/Serilog.dll',
Expand Down
4 changes: 2 additions & 2 deletions docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ the PowerShell debugger.
Use the @Microsoft.PowerShell.EditorServices.Console.ConsoleService to provide interactive
console support in the user's editor.

Use the @Microsoft.PowerShell.EditorServices.Extensions.ExtensionService to allow
Use the @Microsoft.PowerShell.EditorServices.Engine.Services.ExtensionService to allow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the @s here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure but since this use to be a docfx website, there might be some special syntax with that.

the user to extend the host editor with new capabilities using PowerShell code.

The core of all the services is the @Microsoft.PowerShell.EditorServices.PowerShellContext
class. This class manages a session's runspace and handles script and command
execution no matter what state the runspace is in.
execution no matter what state the runspace is in.
14 changes: 7 additions & 7 deletions docs/guide/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ uses PowerShell Editor Services.
### Introducing `$psEditor`

The entry point for the PowerShell Editor Services extensibility model is the `$psEditor`
object of the type @Microsoft.PowerShell.EditorServices.Extensions.EditorObject. For
object of the type @Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorObject. For
those familiar with the PowerShell ISE's `$psISE` object, the `$psEditor` object is very
similar. The primary difference is that this model has been generalized to work against
any editor which leverages PowerShell Editor Services for its PowerShell editing experience.
Expand All @@ -19,7 +19,7 @@ any editor which leverages PowerShell Editor Services for its PowerShell editing
> please file an issue on our GitHub page.

This object gives access to all of the high-level services in the current
editing session. For example, the @Microsoft.PowerShell.EditorServices.Extensions.EditorObject.Workspace
editing session. For example, the @Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorObject.Workspace
property gives access to the editor's workspace, allowing you to create or open files
in the editor.

Expand Down Expand Up @@ -79,17 +79,17 @@ Register-EditorCommand `
-ScriptBlock { Write-Output "My command's script block was invoked!" }
```

### The @Microsoft.PowerShell.EditorServices.Extensions.EditorContext parameter
### The @Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorContext parameter

Your function, cmdlet, or ScriptBlock can optionally accept a single parameter
of type @Microsoft.PowerShell.EditorServices.Extensions.EditorContext which provides
of type @Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorContext which provides
information about the state of the host editor at the time your command was
invoked. With this object you can easily perform operations like manipulatin the
state of the user's active editor buffer or changing the current selection.

The usual convention is that a `$context` parameter is added to your editor
command's function. For now it is recommended that you fully specify the
type of the @Microsoft.PowerShell.EditorServices.Extensions.EditorContext object
type of the @Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorContext object
so that you get full IntelliSense on your context parameter.

Here is an example of using the `$context` parameter:
Expand All @@ -99,7 +99,7 @@ Register-EditorCommand `
-Name "MyModule.MyEditorCommandWithContext" `
-DisplayName "My command with context usage" `
-ScriptBlock {
param([Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context)
param([Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorContext]$context)
Write-Output "The user's cursor is on line $($context.CursorPosition.Line)!"
}
```
Expand Down Expand Up @@ -165,4 +165,4 @@ in that editor starts up.
> NOTE: In the future we plan to provide an easy way for the user to opt-in
> to the automatic loading of any editor command modules that they've installed
> from the PowerShell Gallery. If this interests you, please let us know on
> [this GitHub issue](https://github.com/PowerShell/PowerShellEditorServices/issues/215).
> [this GitHub issue](https://github.com/PowerShell/PowerShellEditorServices/issues/215).
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.1.602"
"version": "2.1.801"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Microsoft.PowerShell.EditorServices.VSCode.dll"

if ($psEditor -is [Microsoft.PowerShell.EditorServices.Extensions.EditorObject]) {
if ($psEditor -is [Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorObject]) {
[Microsoft.PowerShell.EditorServices.VSCode.ComponentRegistration]::Register($psEditor.Components)
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function New-VSCodeHtmlContentView {
)

process {
if ($psEditor -is [Microsoft.PowerShell.EditorServices.Extensions.EditorObject]) {
if ($psEditor -is [Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorObject]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like if we're keeping the extensions concept, it should be given a friendly namespace of its own that doesn't depend on the implementation detail of the PowerShellContext service. But not a huge thing for this PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I agree.

$viewFeature = $psEditor.Components.Get([Microsoft.PowerShell.EditorServices.VSCode.CustomViews.IHtmlContentViews])
$view = $viewFeature.CreateHtmlContentViewAsync($Title).Result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Register-EditorCommand `
-DisplayName 'Open Editor Profile' `
-SuppressOutput `
-ScriptBlock {
param([Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context)
param([Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorContext]$context)
If (!(Test-Path -Path $Profile)) { New-Item -Path $Profile -ItemType File }
$psEditor.Workspace.OpenFile($Profile)
}
Expand All @@ -13,18 +13,18 @@ Register-EditorCommand `
-DisplayName 'Open Profile from List (Current User)' `
-SuppressOutput `
-ScriptBlock {
param([Microsoft.PowerShell.EditorServices.Extensions.EditorContext]$context)
$Current = Split-Path -Path $profile -Leaf
param([Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorContext]$context)

$Current = Split-Path -Path $profile -Leaf
$List = @($Current,'Microsoft.VSCode_profile.ps1','Microsoft.PowerShell_profile.ps1','Microsoft.PowerShellISE_profile.ps1','Profile.ps1') | Select-Object -Unique
$Choices = [System.Management.Automation.Host.ChoiceDescription[]] @($List)
$Selection = $host.ui.PromptForChoice('Please Select a Profile', '(Current User)', $choices,'0')
$Name = $List[$Selection]

$ProfileDir = Split-Path $Profile -Parent
$ProfileName = Join-Path -Path $ProfileDir -ChildPath $Name

If (!(Test-Path -Path $ProfileName)) { New-Item -Path $ProfileName -ItemType File }

$psEditor.Workspace.OpenFile($ProfileName)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function Register-EditorCommand {
$commandArgs += $Function
}

$editorCommand = New-Object Microsoft.PowerShell.EditorServices.Extensions.EditorCommand -ArgumentList $commandArgs
$editorCommand = New-Object Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorCommand -ArgumentList $commandArgs
if ($psEditor.RegisterCommand($editorCommand))
{
Write-Verbose "Registered new command '$Name'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function Import-EditorCommand {
<#
.EXTERNALHELP ..\PowerShellEditorServices.Commands-help.xml
#>
[OutputType([Microsoft.PowerShell.EditorServices.Extensions.EditorCommand])]
[OutputType([Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorCommand])]
[CmdletBinding(DefaultParameterSetName='ByCommand')]
param(
[Parameter(Position=0,
Expand Down Expand Up @@ -75,7 +75,7 @@ function Import-EditorCommand {
$commands = $Command | Get-Command -ErrorAction SilentlyContinue
}
}
$attributeType = [Microsoft.PowerShell.EditorServices.Extensions.EditorCommandAttribute]
$attributeType = [Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorCommandAttribute]
foreach ($aCommand in $commands) {
# Get the attribute from our command to get name info.
$details = $aCommand.ScriptBlock.Attributes | Where-Object TypeId -eq $attributeType
Expand All @@ -99,7 +99,7 @@ function Import-EditorCommand {
}
# Check for a context parameter.
$contextParameter = $aCommand.Parameters.Values |
Where-Object ParameterType -eq ([Microsoft.PowerShell.EditorServices.Extensions.EditorContext])
Where-Object ParameterType -eq ([Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorContext])

# If one is found then add a named argument. Otherwise call the command directly.
if ($contextParameter) {
Expand All @@ -109,7 +109,7 @@ function Import-EditorCommand {
$scriptBlock = [scriptblock]::Create($aCommand.Name)
}

$editorCommand = New-Object Microsoft.PowerShell.EditorServices.Extensions.EditorCommand @(
$editorCommand = New-Object Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorCommand @(
<# commandName: #> $details.Name,
<# displayName: #> $details.DisplayName,
<# suppressOutput: #> $details.SuppressOutput,
Expand Down
6 changes: 3 additions & 3 deletions module/docs/Import-EditorCommand.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The Import-EditorCommand function will search the specified module for functions

Alternatively, you can specify command info objects (like those from the Get-Command cmdlet) to be processed directly.

To tag a command as an editor command, attach the attribute 'Microsoft.PowerShell.EditorServices.Extensions.EditorCommandAttribute' to the function like you would with 'CmdletBindingAttribute'. The attribute accepts the named parameters 'Name', 'DisplayName', and 'SuppressOutput'.
To tag a command as an editor command, attach the attribute 'Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorCommandAttribute' to the function like you would with 'CmdletBindingAttribute'. The attribute accepts the named parameters 'Name', 'DisplayName', and 'SuppressOutput'.

## EXAMPLES

Expand All @@ -55,7 +55,7 @@ Registers all editor commands that contain "Editor" in the name and return all s
```powershell
function Invoke-MyEditorCommand {
[CmdletBinding()]
[Microsoft.PowerShell.EditorServices.Extensions.EditorCommand(DisplayName='My Command', SuppressOutput)]
[Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorCommand(DisplayName='My Command', SuppressOutput)]
param()
end {
ConvertTo-ScriptExtent -Offset 0 | Set-ScriptExtent -Text 'My Command!'
Expand Down Expand Up @@ -145,7 +145,7 @@ You can pass commands to register as editor commands.

## OUTPUTS

### Microsoft.PowerShell.EditorServices.Extensions.EditorCommand
### Microsoft.PowerShell.EditorServices.Engine.Services.PowerShellContext.EditorCommand

If the "PassThru" parameter is specified editor commands that were successfully registered
will be returned. This function does not output to the pipeline otherwise.
Expand Down
Loading