Skip to content

Add new client/server API for the host process #64

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
merged 3 commits into from
Dec 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PowerShellEditorServices.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Revert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like the solution opens in VS 2013 with no complaints, will leave it like this.

MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F594E7FD-1E72-4E51-A496-B019C2BA3180}"
EndProject
Expand Down
8 changes: 8 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ branches:
only:
- master

# NOTE: If you need to debug a problem with the AppVeyor build, uncomment the
# following two lines and push them to your PR branch. Once the next
# build starts you will see RDP connection details written out to the
# build console. **DON'T FORGET TO REMOVE THIS COMMIT BEFORE MERGING!**

#init:
#- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

assembly_info:
patch: true
file: '**\AssemblyInfo.*'
Expand Down
32 changes: 19 additions & 13 deletions scripts/AddCopyrightHeaders.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,30 @@ $copyrightHeaderString =
//
'@

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

$updateCount = 0;
$allSourceFiles = Get-ChildItem $srcPath -Recurse -Filter *.cs | ?{ $_.FullName -notmatch "\\obj\\?" }

foreach ($sourceFile in $allSourceFiles)
function Add-CopyrightHeaders($basePath)
{
$fileContent = (Get-Content $sourceFile.FullName -Raw).TrimStart()
Push-Location $basePath
$allSourceFiles = Get-ChildItem $basePath -Recurse -Filter *.cs | ?{ $_.FullName -notmatch "\\obj\\?" }

if ($fileContent.StartsWith($copyrightHeaderString) -eq $false)
foreach ($sourceFile in $allSourceFiles)
{
# Add the copyright header to the file
Set-Content $sourceFile.FullName ($copyrightHeaderString + "`r`n`r`n" + $fileContent)
Write-Output ("Updated {0}" -f (Resolve-Path $sourceFile.FullName -Relative))
$fileContent = (Get-Content $sourceFile.FullName -Raw).TrimStart()

if ($fileContent.StartsWith($copyrightHeaderString) -eq $false)
{
# Add the copyright header to the file
Set-Content $sourceFile.FullName ($copyrightHeaderString + "`r`n`r`n" + $fileContent)
Write-Output ("Updated {0}" -f (Resolve-Path $sourceFile.FullName -Relative))
$global:updateCount++
}
}

Pop-Location
}

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

Pop-Location
Write-Output "`r`nDone, $global:updateCount file(s) updated."
27 changes: 0 additions & 27 deletions src/PowerShellEditorServices.Host/IMessageProcessor.cs

This file was deleted.

207 changes: 0 additions & 207 deletions src/PowerShellEditorServices.Host/MessageLoop.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,8 @@
<Reference Include="System.Management.Automation" />
</ItemGroup>
<ItemGroup>
<Compile Include="DebugAdapter.cs" />
<Compile Include="IMessageProcessor.cs" />
<Compile Include="LanguageServer.cs" />
<Compile Include="LanguageServerSettings.cs" />
<Compile Include="MessageLoop.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StdioConsoleHost.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
Expand Down
41 changes: 31 additions & 10 deletions src/PowerShellEditorServices.Host/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using Microsoft.PowerShell.EditorServices.Protocol.Server;
using Microsoft.PowerShell.EditorServices.Utility;
using System;
using System.Diagnostics;
Expand Down Expand Up @@ -39,6 +40,19 @@ static void Main(string[] args)
}
#endif

string logPath = null;
string logPathArgument =
args.FirstOrDefault(
arg =>
arg.StartsWith(
"/logPath:",
StringComparison.InvariantCultureIgnoreCase));

if (!string.IsNullOrEmpty(logPathArgument))
{
logPath = logPathArgument.Substring(9).Trim('"');
}

bool runDebugAdapter =
args.Any(
arg =>
Expand All @@ -50,25 +64,32 @@ static void Main(string[] args)
// Catch unhandled exceptions for logging purposes
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

ProtocolServer server = null;
if (runDebugAdapter)
{
// TODO: Remove this behavior in the near future --
// Create the debug service log in a separate file
// so that there isn't a conflict with the default
// log file.
Logger.Initialize("DebugAdapter.log", LogLevel.Verbose);
logPath = logPath ?? "DebugAdapter.log";
server = new DebugAdapter();
}
else
{
// Initialize the logger
// TODO: Set the level based on command line parameter
Logger.Initialize(minimumLogLevel: LogLevel.Verbose);
logPath = logPath ?? "EditorServices.log";
server = new LanguageServer();
}

// Start the logger with the specified log path
// TODO: Set the level based on command line parameter
Logger.Initialize(logPath, LogLevel.Verbose);

Logger.Write(LogLevel.Normal, "PowerShell Editor Services Host starting...");

// Start the server
server.Start();
Logger.Write(LogLevel.Normal, "PowerShell Editor Services Host started!");

MessageLoop messageLoop = new MessageLoop(runDebugAdapter);
messageLoop.Start();
// Wait for the server to finish
server.WaitForExit();

Logger.Write(LogLevel.Normal, "PowerShell Editor Services Host exited normally.");
}

static void CurrentDomain_UnhandledException(
Expand Down
Loading