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

Move the Omnisharp work into master #1056

Merged
merged 47 commits into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d5152c6
Add starting point
May 31, 2019
36a06c8
x
May 31, 2019
a363f07
More work
Jun 4, 2019
9ef8fe5
Make integration tests pass for omnisharp
Jun 11, 2019
91e5166
Changes
Jun 25, 2019
ea39097
add dummy workspace symbols handler
TylerLeonhardt Jul 4, 2019
0c83a43
use LoggerFactory
TylerLeonhardt Jul 8, 2019
5d744ba
A working WorkspaceSymbolsHandler
TylerLeonhardt Jul 9, 2019
9041219
working text document syncer
TylerLeonhardt Jul 10, 2019
da25a55
needed document selector and getVersion handler to work with vscode
TylerLeonhardt Jul 10, 2019
a5b04ba
Add diagnostics (#18)
TylerLeonhardt Jul 16, 2019
8f1bdc6
Add setting support (#19)
TylerLeonhardt Jul 26, 2019
32ef5b9
Folding support (#20)
TylerLeonhardt Jul 26, 2019
a48f56a
Added Diagnostics
TylerLeonhardt Jul 12, 2019
89904c8
didChangeConfiguration message and general settings support
TylerLeonhardt Jul 16, 2019
aa5d582
initial folding support
TylerLeonhardt Jul 16, 2019
6e0ecbc
added test for folding
TylerLeonhardt Jul 18, 2019
9a273f4
formatting support
TylerLeonhardt Jul 26, 2019
90c440e
remove merge conflict
TylerLeonhardt Jul 29, 2019
8e9ca8a
add formatting tests
TylerLeonhardt Jul 29, 2019
74f4f2f
DocumentSymbols and References support (#997)
TylerLeonhardt Jul 31, 2019
dda6258
[Omnisharp-LSP] textDocument/documentHighlight support (#999)
Aug 2, 2019
43128e6
codelens support (#1001)
TylerLeonhardt Aug 5, 2019
b6d3c9a
powerShell/getPSHostProcesses and powerShell/getRunspace (#1002)
TylerLeonhardt Aug 5, 2019
d622764
Test only pester for now (#1003)
TylerLeonhardt Aug 5, 2019
9e67baa
Implement textDocument/codeAction (#1004)
rjmholt Aug 9, 2019
a7057e3
Add powershellcontext (#1005)
TylerLeonhardt Aug 9, 2019
9d9f474
support $psEditor (#1006)
TylerLeonhardt Aug 12, 2019
95dc4ab
Re-add Stdio option and replace Pester tests with xunit tests. (#1008)
TylerLeonhardt Aug 19, 2019
b7e2531
Completion Support (#1007)
TylerLeonhardt Aug 21, 2019
b61952d
completionresolve support (#1009)
TylerLeonhardt Aug 21, 2019
53b79e6
hover support (#1010)
TylerLeonhardt Aug 22, 2019
930e978
Omni signaturehelp (#1011)
TylerLeonhardt Aug 22, 2019
cc67dae
Add definition handler (#1013)
TylerLeonhardt Aug 22, 2019
56bd5b7
Add Plaster messages (#1014)
TylerLeonhardt Aug 23, 2019
2b6b237
Comment Help and Evaluate (#1015)
TylerLeonhardt Aug 23, 2019
a2a986e
Last LSP messages (#1016)
TylerLeonhardt Aug 27, 2019
0e2f7b9
refactor server setup (#1018)
TylerLeonhardt Aug 28, 2019
5346056
rename namespaces (#1019)
TylerLeonhardt Sep 16, 2019
e7543d3
The entire Debug Adapter moved over... (#1043)
TylerLeonhardt Sep 29, 2019
998fc25
Delete projects we wont be keeping around and get pses.vscode working…
TylerLeonhardt Oct 1, 2019
96fb6c2
Remove engine from files and namespaces (#1048)
TylerLeonhardt Oct 1, 2019
0ed893a
apply apt state for PS7 (#1051)
TylerLeonhardt Oct 3, 2019
40aadf7
delete buildinfo
TylerLeonhardt Oct 3, 2019
1477dae
implement powerShell/startDebugger (#1049)
TylerLeonhardt Oct 3, 2019
4cccc96
Enable alias corrections (#1053)
rjmholt Oct 3, 2019
e9f9bcd
Codacy comments
TylerLeonhardt Oct 3, 2019
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
Prev Previous commit
Next Next commit
codelens support (#1001)
* codelens support

* address rob's feedback
  • Loading branch information
TylerLeonhardt committed Oct 3, 2019
commit 43128e68641acdc3e69030fc37a1952fc3355aa6
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ public async Task StartAsync()
.WithHandler<DocumentRangeFormattingHandler>()
.WithHandler<ReferencesHandler>()
.WithHandler<DocumentSymbolHandler>()
.WithHandler<DocumentHighlightHandler>();
.WithHandler<DocumentHighlightHandler>()
.WithHandler<CodeLensHandlers>();

logger.LogInformation("Handlers added");
logger.LogInformation("Handlers added");
});

_serverStart.SetResult(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

namespace Microsoft.PowerShell.EditorServices.CodeLenses
{
/// <summary>
/// Represents data expected back in an LSP CodeLens response.
/// </summary>
internal class CodeLensData
{
public string Uri { get; set; }

public string ProviderId { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using System.Threading;
using System.Threading.Tasks;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;

namespace Microsoft.PowerShell.EditorServices.CodeLenses
{
/// <summary>
/// Specifies the contract for a Code Lens provider.
/// </summary>
public interface ICodeLensProvider
{
/// <summary>
/// Specifies a unique identifier for the feature provider, typically a
/// fully-qualified name like "Microsoft.PowerShell.EditorServices.MyProvider"
/// </summary>
string ProviderId { get; }

/// <summary>
/// Provides a collection of CodeLenses for the given
/// document.
/// </summary>
/// <param name="scriptFile">
/// The document for which CodeLenses should be provided.
/// </param>
/// <returns>An array of CodeLenses.</returns>
CodeLens[] ProvideCodeLenses(ScriptFile scriptFile);

/// <summary>
/// Resolves a CodeLens that was created without a Command.
/// </summary>
/// <param name="codeLens">
/// The CodeLens to resolve.
/// </param>
/// <param name="scriptFile">
/// A CancellationToken which can be used to cancel the
/// request.
/// </param>
/// <returns>
/// A Task which returns the resolved CodeLens when completed.
/// </returns>
CodeLens ResolveCodeLens(
CodeLens codeLens,
ScriptFile scriptFile);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using System.Collections.Generic;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;

namespace Microsoft.PowerShell.EditorServices.CodeLenses
{
/// <summary>
/// Specifies the contract for an implementation of
/// the ICodeLenses component.
/// </summary>
public interface ICodeLenses
{
/// <summary>
/// Gets the collection of ICodeLensProvider implementations
/// that are registered with this component.
/// </summary>
List<ICodeLensProvider> Providers { get; }

/// <summary>
/// Provides a collection of CodeLenses for the given
/// document.
/// </summary>
/// <param name="scriptFile">
/// The document for which CodeLenses should be provided.
/// </param>
/// <returns>An array of CodeLenses.</returns>
CodeLens[] ProvideCodeLenses(ScriptFile scriptFile);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using System.Management.Automation.Language;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;

namespace Microsoft.PowerShell.EditorServices
{
internal static class IScriptExtentExtensions
{
public static Range ToRange(this IScriptExtent scriptExtent)
{
return new Range
{
Start = new Position
{
Line = scriptExtent.StartLineNumber - 1,
Character = scriptExtent.StartColumnNumber - 1
},
End = new Position
{
Line = scriptExtent.EndLineNumber - 1,
Character = scriptExtent.EndColumnNumber - 1
}
};
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.PowerShell.EditorServices.Symbols;
using Newtonsoft.Json.Linq;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;

namespace Microsoft.PowerShell.EditorServices.CodeLenses
{
internal class PesterCodeLensProvider : ICodeLensProvider
{

/// <summary>
/// The symbol provider to get symbols from to build code lenses with.
/// </summary>
private readonly IDocumentSymbolProvider _symbolProvider;

/// <summary>
/// Specifies a unique identifier for the feature provider, typically a
/// fully-qualified name like "Microsoft.PowerShell.EditorServices.MyProvider"
/// </summary>
public string ProviderId => nameof(PesterCodeLensProvider);

/// <summary>
/// Create a new Pester CodeLens provider for a given editor session.
/// </summary>
public PesterCodeLensProvider()
{
_symbolProvider = new PesterDocumentSymbolProvider();
}

/// <summary>
/// Get the Pester CodeLenses for a given Pester symbol.
/// </summary>
/// <param name="pesterSymbol">The Pester symbol to get CodeLenses for.</param>
/// <param name="scriptFile">The script file the Pester symbol comes from.</param>
/// <returns>All CodeLenses for the given Pester symbol.</returns>
private CodeLens[] GetPesterLens(PesterSymbolReference pesterSymbol, ScriptFile scriptFile)
{

var codeLensResults = new CodeLens[]
{
new CodeLens()
{
Range = pesterSymbol.ScriptRegion.ToRange(),
Data = JToken.FromObject(new {
Uri = scriptFile.DocumentUri,
ProviderId = nameof(PesterCodeLensProvider)
}),
Command = new Command()
{
Name = "PowerShell.RunPesterTests",
Title = "Run tests",
Arguments = JArray.FromObject(new object[] {
scriptFile.DocumentUri,
false /* No debug */,
pesterSymbol.TestName,
pesterSymbol.ScriptRegion?.StartLineNumber })
}
},

new CodeLens()
{
Range = pesterSymbol.ScriptRegion.ToRange(),
Data = JToken.FromObject(new {
Uri = scriptFile.DocumentUri,
ProviderId = nameof(PesterCodeLensProvider)
}),
Command = new Command()
{
Name = "PowerShell.RunPesterTests",
Title = "Debug tests",
Arguments = JArray.FromObject(new object[] {
scriptFile.DocumentUri,
true /* No debug */,
pesterSymbol.TestName,
pesterSymbol.ScriptRegion?.StartLineNumber })
}
}
};

return codeLensResults;
}

/// <summary>
/// Get all Pester CodeLenses for a given script file.
/// </summary>
/// <param name="scriptFile">The script file to get Pester CodeLenses for.</param>
/// <returns>All Pester CodeLenses for the given script file.</returns>
public CodeLens[] ProvideCodeLenses(ScriptFile scriptFile)
{
var lenses = new List<CodeLens>();
foreach (SymbolReference symbol in _symbolProvider.ProvideDocumentSymbols(scriptFile))
{
if (symbol is PesterSymbolReference pesterSymbol)
{
if (pesterSymbol.Command != PesterCommandType.Describe)
{
continue;
}

lenses.AddRange(GetPesterLens(pesterSymbol, scriptFile));
}
}

return lenses.ToArray();
}

/// <summary>
/// Resolve the CodeLens provision asynchronously -- just wraps the CodeLens argument in a task.
/// </summary>
/// <param name="codeLens">The code lens to resolve.</param>
/// <param name="scriptFile">The script file.</param>
/// <returns>The given CodeLens, wrapped in a task.</returns>
public CodeLens ResolveCodeLens(CodeLens codeLens, ScriptFile scriptFile)
{
// This provider has no specific behavior for
// resolving CodeLenses.
return codeLens;
}
}
}
Loading