Skip to content

Commit 8fbd01c

Browse files
committed
Add new client/server API for host process
This change introduces a new set of classes that make it much easier to write a language server or debug adapter and clients for either type of server. All client/server logic has been moved to the Protocol library so that it can be used in other host applications outside of the provided host process.
1 parent 580742c commit 8fbd01c

File tree

97 files changed

+2010
-1120
lines changed

Some content is hidden

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

97 files changed

+2010
-1120
lines changed

PowerShellEditorServices.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.40629.0
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.24720.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F594E7FD-1E72-4E51-A496-B019C2BA3180}"
77
EndProject

scripts/AddCopyrightHeaders.ps1

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,30 @@ $copyrightHeaderString =
1111
//
1212
'@
1313

14-
$srcPath = Resolve-Path $PSScriptRoot\..\src
15-
Push-Location $srcPath
14+
$global:updateCount = 0;
1615

17-
$updateCount = 0;
18-
$allSourceFiles = Get-ChildItem $srcPath -Recurse -Filter *.cs | ?{ $_.FullName -notmatch "\\obj\\?" }
19-
20-
foreach ($sourceFile in $allSourceFiles)
16+
function Add-CopyrightHeaders($basePath)
2117
{
22-
$fileContent = (Get-Content $sourceFile.FullName -Raw).TrimStart()
18+
Push-Location $basePath
19+
$allSourceFiles = Get-ChildItem $basePath -Recurse -Filter *.cs | ?{ $_.FullName -notmatch "\\obj\\?" }
2320

24-
if ($fileContent.StartsWith($copyrightHeaderString) -eq $false)
21+
foreach ($sourceFile in $allSourceFiles)
2522
{
26-
# Add the copyright header to the file
27-
Set-Content $sourceFile.FullName ($copyrightHeaderString + "`r`n`r`n" + $fileContent)
28-
Write-Output ("Updated {0}" -f (Resolve-Path $sourceFile.FullName -Relative))
23+
$fileContent = (Get-Content $sourceFile.FullName -Raw).TrimStart()
24+
25+
if ($fileContent.StartsWith($copyrightHeaderString) -eq $false)
26+
{
27+
# Add the copyright header to the file
28+
Set-Content $sourceFile.FullName ($copyrightHeaderString + "`r`n`r`n" + $fileContent)
29+
Write-Output ("Updated {0}" -f (Resolve-Path $sourceFile.FullName -Relative))
30+
$global:updateCount++
31+
}
2932
}
33+
34+
Pop-Location
3035
}
3136

32-
Write-Output "`r`nDone, $updateCount files updated."
37+
Add-CopyrightHeaders(Resolve-Path $PSScriptRoot\..\src)
38+
Add-CopyrightHeaders(Resolve-Path $PSScriptRoot\..\test)
3339

34-
Pop-Location
40+
Write-Output "`r`nDone, $global:updateCount file(s) updated."

src/PowerShellEditorServices.Host/IMessageProcessor.cs

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

src/PowerShellEditorServices.Host/MessageLoop.cs

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

src/PowerShellEditorServices.Host/PowerShellEditorServices.Host.csproj

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,8 @@
5959
<Reference Include="System.Management.Automation" />
6060
</ItemGroup>
6161
<ItemGroup>
62-
<Compile Include="DebugAdapter.cs" />
63-
<Compile Include="IMessageProcessor.cs" />
64-
<Compile Include="LanguageServer.cs" />
65-
<Compile Include="LanguageServerSettings.cs" />
66-
<Compile Include="MessageLoop.cs" />
6762
<Compile Include="Program.cs" />
6863
<Compile Include="Properties\AssemblyInfo.cs" />
69-
<Compile Include="StdioConsoleHost.cs" />
7064
</ItemGroup>
7165
<ItemGroup>
7266
<None Include="App.config" />

src/PowerShellEditorServices.Host/Program.cs

Lines changed: 15 additions & 2 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 Microsoft.PowerShell.EditorServices.Protocol.Server;
67
using Microsoft.PowerShell.EditorServices.Utility;
78
using System;
89
using System.Diagnostics;
@@ -67,8 +68,20 @@ static void Main(string[] args)
6768

6869
Logger.Write(LogLevel.Normal, "PowerShell Editor Services Host started!");
6970

70-
MessageLoop messageLoop = new MessageLoop(runDebugAdapter);
71-
messageLoop.Start();
71+
ProtocolServer server = null;
72+
if (runDebugAdapter)
73+
{
74+
server = new DebugAdapter();
75+
}
76+
else
77+
{
78+
server = new LanguageServer();
79+
}
80+
81+
server.Start();
82+
server.WaitForExit();
83+
84+
Logger.Write(LogLevel.Normal, "PowerShell Editor Services Host exited normally.");
7285
}
7386

7487
static void CurrentDomain_UnhandledException(

0 commit comments

Comments
 (0)