Skip to content

Commit bd920c3

Browse files
committed
Merge pull request #64 from PowerShell/daviwil/client-server-api
Add new client/server API for the host process
2 parents 580742c + 29a560f commit bd920c3

File tree

99 files changed

+2064
-1129
lines changed

Some content is hidden

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

99 files changed

+2064
-1129
lines changed

Diff for: PowerShellEditorServices.sln

+2-2
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

Diff for: appveyor.yml

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ branches:
77
only:
88
- master
99

10+
# NOTE: If you need to debug a problem with the AppVeyor build, uncomment the
11+
# following two lines and push them to your PR branch. Once the next
12+
# build starts you will see RDP connection details written out to the
13+
# build console. **DON'T FORGET TO REMOVE THIS COMMIT BEFORE MERGING!**
14+
15+
#init:
16+
#- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
17+
1018
assembly_info:
1119
patch: true
1220
file: '**\AssemblyInfo.*'

Diff for: scripts/AddCopyrightHeaders.ps1

+19-13
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."

Diff for: src/PowerShellEditorServices.Host/IMessageProcessor.cs

-27
This file was deleted.

Diff for: src/PowerShellEditorServices.Host/MessageLoop.cs

-207
This file was deleted.

Diff for: src/PowerShellEditorServices.Host/PowerShellEditorServices.Host.csproj

-6
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" />

Diff for: src/PowerShellEditorServices.Host/Program.cs

+31-10
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;
@@ -39,6 +40,19 @@ static void Main(string[] args)
3940
}
4041
#endif
4142

43+
string logPath = null;
44+
string logPathArgument =
45+
args.FirstOrDefault(
46+
arg =>
47+
arg.StartsWith(
48+
"/logPath:",
49+
StringComparison.InvariantCultureIgnoreCase));
50+
51+
if (!string.IsNullOrEmpty(logPathArgument))
52+
{
53+
logPath = logPathArgument.Substring(9).Trim('"');
54+
}
55+
4256
bool runDebugAdapter =
4357
args.Any(
4458
arg =>
@@ -50,25 +64,32 @@ static void Main(string[] args)
5064
// Catch unhandled exceptions for logging purposes
5165
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
5266

67+
ProtocolServer server = null;
5368
if (runDebugAdapter)
5469
{
55-
// TODO: Remove this behavior in the near future --
56-
// Create the debug service log in a separate file
57-
// so that there isn't a conflict with the default
58-
// log file.
59-
Logger.Initialize("DebugAdapter.log", LogLevel.Verbose);
70+
logPath = logPath ?? "DebugAdapter.log";
71+
server = new DebugAdapter();
6072
}
6173
else
6274
{
63-
// Initialize the logger
64-
// TODO: Set the level based on command line parameter
65-
Logger.Initialize(minimumLogLevel: LogLevel.Verbose);
75+
logPath = logPath ?? "EditorServices.log";
76+
server = new LanguageServer();
6677
}
6778

79+
// Start the logger with the specified log path
80+
// TODO: Set the level based on command line parameter
81+
Logger.Initialize(logPath, LogLevel.Verbose);
82+
83+
Logger.Write(LogLevel.Normal, "PowerShell Editor Services Host starting...");
84+
85+
// Start the server
86+
server.Start();
6887
Logger.Write(LogLevel.Normal, "PowerShell Editor Services Host started!");
6988

70-
MessageLoop messageLoop = new MessageLoop(runDebugAdapter);
71-
messageLoop.Start();
89+
// Wait for the server to finish
90+
server.WaitForExit();
91+
92+
Logger.Write(LogLevel.Normal, "PowerShell Editor Services Host exited normally.");
7293
}
7394

7495
static void CurrentDomain_UnhandledException(

0 commit comments

Comments
 (0)