Skip to content
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

Close over public APIs not designed for exposure #1183

Merged
merged 34 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
10a0dd0
Close over public APIs not designed for exposure
Feb 10, 2020
9d4e9bd
Remove obsolete scriptfile APIs
Feb 10, 2020
f03ba96
Move public API to new location
Feb 10, 2020
f1dc006
Move and extend public API
Feb 11, 2020
339fb65
Fix VSCode module
Feb 11, 2020
b873a98
Remove unused language server dependency
Feb 11, 2020
8d67d6e
Make exception types public
Feb 11, 2020
d54e0ef
Use safe array conversion
Feb 11, 2020
17587f7
Add APIs to get and load through the PSES ALC
Feb 11, 2020
daeffd5
Fix unused GetType() call
Feb 11, 2020
526422c
Add first set of public APIs
Feb 13, 2020
85d2e2a
Hook up services
Feb 13, 2020
9182e63
Fix compilation errors
Feb 13, 2020
d3d803e
Address some codacy feedback
Feb 13, 2020
70b5fa8
Add API for UI prompts
Feb 13, 2020
2074f80
Fix a missing Async
Feb 13, 2020
174609a
Fix comment about the LSP server
Feb 13, 2020
1f0f6ee
Remove stray using statement
Feb 13, 2020
f3c3766
Fix UI property name
Feb 13, 2020
cc85fa3
Fix circular dependency injection issue
Feb 14, 2020
7f786da
Fix namespace
Feb 14, 2020
60ec26f
Fix namespaces
Feb 14, 2020
b0f71a3
Fix namespace of editorcommand
Feb 18, 2020
d39fa25
Add powerShell/showInputPrompt request API
Feb 18, 2020
d2b7008
Address @TylerLeonhardt's comments
Feb 18, 2020
64fd80f
Rename document symbol provider registration API
Feb 18, 2020
12b1e19
Use our own overload
Feb 18, 2020
98af1fc
Fix test API exposure
Feb 18, 2020
77b5b21
Remove DocumentSymbolsService API for now
Feb 18, 2020
34e9407
Add skeleton of tests
Feb 18, 2020
0242568
Increase delay
Feb 18, 2020
e3f4b71
Get rid of bad tests
Feb 18, 2020
acacde4
Disable bad hotkey test
Feb 18, 2020
7fccc46
Rename UI service APIs to have Async suffix
Feb 19, 2020
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
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.Services.PowerShellContext.EditorCommand -ArgumentList $commandArgs
$editorCommand = New-Object Microsoft.PowerShell.EditorServices.Extensions.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 @@ -32,7 +32,7 @@ public enum PsesLogLevel
/// A logging front-end for host startup allowing handover to the backend
/// and decoupling from the host's particular logging sink.
/// </summary>
public class HostLogger :
public sealed class HostLogger :
IObservable<(PsesLogLevel logLevel, string message)>,
IObservable<(int logLevel, string message)>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public interface ISessionFileWriter
/// <summary>
/// The default session file writer, which uses PowerShell to write a session file.
/// </summary>
public class SessionFileWriter : ISessionFileWriter
public sealed class SessionFileWriter : ISessionFileWriter
{
// Use BOM-less UTF-8 for session file
private static readonly Encoding s_sessionFileEncoding = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public interface ITransportConfig
/// <summary>
/// Configuration for the standard input/output transport.
/// </summary>
public class StdioTransportConfig : ITransportConfig
public sealed class StdioTransportConfig : ITransportConfig
{
public string EndpointDetails => "<stdio>";

Expand All @@ -58,7 +58,7 @@ public class StdioTransportConfig : ITransportConfig
/// <summary>
/// Configuration for a full duplex named pipe.
/// </summary>
public class DuplexNamedPipeTransportConfig : ITransportConfig
public sealed class DuplexNamedPipeTransportConfig : ITransportConfig
{
/// <summary>
/// Create a duplex named pipe transport config with an automatically generated pipe name.
Expand Down Expand Up @@ -108,7 +108,7 @@ private DuplexNamedPipeTransportConfig(string pipeName)
/// <summary>
/// Configuration for two simplex named pipes.
/// </summary>
public class SimplexNamedPipeTransportConfig : ITransportConfig
public sealed class SimplexNamedPipeTransportConfig : ITransportConfig
{
private const string InPipePrefix = "in";
private const string OutPipePrefix = "out";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Management.Automation;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.PowerShell.EditorServices.Services.PowerShellContext;
using Microsoft.PowerShell.EditorServices.Extensions;
using Microsoft.PowerShell.EditorServices.VSCode.CustomViews;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;

Expand All @@ -20,8 +20,6 @@ public class NewVSCodeHtmlContentViewCommand : PSCmdlet
{
private HtmlContentViewsFeature _htmlContentViewsFeature;

private ILogger _logger;

private ViewColumn? _showInColumn;

///
Expand All @@ -44,13 +42,8 @@ protected override void BeginProcessing()
{
if (GetVariableValue("psEditor") is EditorObject psEditor)
{
_logger = psEditor.Components.GetService<ILoggerFactory>().CreateLogger("PowerShellEditorServices.VSCode");

_htmlContentViewsFeature = new HtmlContentViewsFeature(
psEditor.Components.GetService<ILanguageServer>(),
_logger);

_logger.LogInformation("PowerShell Editor Services VS Code module loaded.");
psEditor.GetExtensionServiceProvider().LanguageServer);
}
else
{
Expand Down
17 changes: 6 additions & 11 deletions src/PowerShellEditorServices.VSCode/CustomViews/CustomViewBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@

using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using Microsoft.PowerShell.EditorServices.Extensions.Services;

namespace Microsoft.PowerShell.EditorServices.VSCode.CustomViews
{
internal abstract class CustomViewBase : ICustomView
{
protected ILanguageServer languageServer;

protected ILogger logger;
protected ILanguageServerService languageServer;

public Guid Id { get; private set; }

Expand All @@ -25,19 +22,17 @@ internal abstract class CustomViewBase : ICustomView
public CustomViewBase(
string viewTitle,
CustomViewType viewType,
ILanguageServer languageServer,
ILogger logger)
ILanguageServerService languageServer)
{
this.Id = Guid.NewGuid();
this.Title = viewTitle;
this.ViewType = viewType;
this.languageServer = languageServer;
this.logger = logger;
}

internal async Task CreateAsync()
{
await languageServer.SendRequest(
await languageServer.SendRequestAsync(
NewCustomViewRequest.Method,
new NewCustomViewRequest
{
Expand All @@ -50,7 +45,7 @@ await languageServer.SendRequest(

public async Task Show(ViewColumn viewColumn)
{
await languageServer.SendRequest(
await languageServer.SendRequestAsync(
ShowCustomViewRequest.Method,
new ShowCustomViewRequest
{
Expand All @@ -62,7 +57,7 @@ await languageServer.SendRequest(

public async Task Close()
{
await languageServer.SendRequest(
await languageServer.SendRequestAsync(
CloseCustomViewRequest.Method,
new CloseCustomViewRequest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,22 @@

using System;
using System.Collections.Generic;
using Microsoft.Extensions.Logging;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using Microsoft.PowerShell.EditorServices.Extensions.Services;

namespace Microsoft.PowerShell.EditorServices.VSCode.CustomViews
{
internal abstract class CustomViewFeatureBase<TView>
where TView : ICustomView
{
protected ILanguageServer languageServer;
protected ILanguageServerService languageServer;

protected ILogger logger;
private readonly Dictionary<Guid, TView> viewIndex;

public CustomViewFeatureBase(
ILanguageServer languageServer,
ILogger logger)
ILanguageServerService languageServer)
{
this.viewIndex = new Dictionary<Guid, TView>();
this.languageServer = languageServer;
this.logger = logger;
}

protected void AddView(TView view)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,25 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using Microsoft.PowerShell.EditorServices.Extensions.Services;

namespace Microsoft.PowerShell.EditorServices.VSCode.CustomViews
{
internal class HtmlContentView : CustomViewBase, IHtmlContentView
{
public HtmlContentView(
string viewTitle,
ILanguageServer languageServer,
ILogger logger)
ILanguageServerService languageServer)
: base(
viewTitle,
CustomViewType.HtmlContent,
languageServer,
logger)
languageServer)
{
}

public async Task SetContentAsync(string htmlBodyContent)
{
await languageServer.SendRequest(
await languageServer.SendRequestAsync(
SetHtmlContentViewRequest.Method,
new SetHtmlContentViewRequest
{
Expand All @@ -48,7 +45,7 @@ public async Task SetContentAsync(HtmlContent htmlContent)
StyleSheetPaths = this.GetUriPaths(htmlContent.StyleSheetPaths)
};

await languageServer.SendRequest(
await languageServer.SendRequestAsync(
SetHtmlContentViewRequest.Method,
new SetHtmlContentViewRequest
{
Expand All @@ -60,7 +57,7 @@ await languageServer.SendRequest(

public async Task AppendContentAsync(string appendedHtmlBodyContent)
{
await languageServer.SendRequest(
await languageServer.SendRequestAsync(
AppendHtmlContentViewRequest.Method,
new AppendHtmlContentViewRequest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
//

using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using OmniSharp.Extensions.LanguageServer.Protocol.Server;
using Microsoft.PowerShell.EditorServices.Extensions.Services;

namespace Microsoft.PowerShell.EditorServices.VSCode.CustomViews
{
internal class HtmlContentViewsFeature : CustomViewFeatureBase<IHtmlContentView>, IHtmlContentViews
{
public HtmlContentViewsFeature(
ILanguageServer languageServer,
ILogger logger)
: base(languageServer, logger)
ILanguageServerService languageServer)
: base(languageServer)
{
}

Expand All @@ -23,8 +21,7 @@ public async Task<IHtmlContentView> CreateHtmlContentViewAsync(string viewTitle)
HtmlContentView htmlView =
new HtmlContentView(
viewTitle,
this.languageServer,
this.logger);
languageServer);

await htmlView.CreateAsync();
this.AddView(htmlView);
Expand Down
Loading