Skip to content

Bump the omnisharp group with 4 updates #2083

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 4 commits into from
Sep 27, 2023
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
5 changes: 0 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,6 @@ dotnet_diagnostic.VSTHRD114.severity = error
# VSTHRD200: Use "Async" suffix for awaitable methods
dotnet_diagnostic.VSTHRD200.severity = silent

# xUnit2013: Do not use equality check to check for collection size
dotnet_diagnostic.xUnit2013.severity = error
# xUnit1004: Test methods should not be skipped
dotnet_diagnostic.xUnit1004.severity = suggestion

# IDE0001: Simplify name
dotnet_diagnostic.IDE0001.severity = error
# IDE0002: Simplify member access
Expand Down
4 changes: 2 additions & 2 deletions src/PowerShellEditorServices/PowerShellEditorServices.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.19.7" />
<PackageReference Include="OmniSharp.Extensions.DebugAdapter.Server" Version="0.19.7" />
<PackageReference Include="OmniSharp.Extensions.LanguageServer" Version="0.19.9" />
<PackageReference Include="OmniSharp.Extensions.DebugAdapter.Server" Version="0.19.9" />
</ItemGroup>
</Otherwise>
</Choose>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,18 @@ public int CompareTo(FoldingReference that)
if (EndCharacter > that.EndCharacter) { return 1; }

// They're the same range, but what about kind
if (Kind == null)
if (Kind == that.Kind)
{
if (that.Kind == null)
{
return 0;
}
// that has a kind but this doesn't.
return 1;
return 0;
}

if (that.Kind != null)
// That has a kind but this doesn't.
if (Kind is null && that.Kind is not null)
{
return that.Kind.Value - Kind.Value;
return 1;
}

// this has a kind but that doesn't.
// This has a kind but that doesn't.
return -1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
// Licensed under the MIT License.

using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.PowerShell.EditorServices.Services;
using Microsoft.PowerShell.EditorServices.Services.Symbols;
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
using Microsoft.PowerShell.EditorServices.Utility;
using OmniSharp.Extensions.LanguageServer.Protocol;
using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
using OmniSharp.Extensions.LanguageServer.Protocol.Document;
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
Expand Down Expand Up @@ -48,7 +46,6 @@ public override async Task<SymbolInformationOrDocumentSymbolContainer> Handle(Do
_logger.LogDebug($"Handling document symbols for {request.TextDocument.Uri}");

ScriptFile scriptFile = _workspaceService.GetFile(request.TextDocument.Uri);
string containerName = Path.GetFileNameWithoutExtension(scriptFile.FilePath);
List<SymbolInformationOrDocumentSymbol> symbols = new();

foreach (SymbolReference r in ProvideDocumentSymbols(scriptFile))
Expand All @@ -70,27 +67,15 @@ public override async Task<SymbolInformationOrDocumentSymbolContainer> Handle(Do
continue;
}

// TODO: This should be a DocumentSymbol now as SymbolInformation is deprecated. But
// this requires figuring out how to populate `children`. Once we do that, the range
// can be NameRegion.
//
// symbols.Add(new SymbolInformationOrDocumentSymbol(new DocumentSymbol
// {
// Name = SymbolTypeUtils.GetDecoratedSymbolName(r),
// Kind = SymbolTypeUtils.GetSymbolKind(r.SymbolType),
// Range = r.ScriptRegion.ToRange(),
// SelectionRange = r.NameRegion.ToRange()
// }));
symbols.Add(new SymbolInformationOrDocumentSymbol(new SymbolInformation
// TODO: This now needs the Children property filled out to support hierarchical
// symbols, and we don't have the information nor algorithm to do that currently.
// OmniSharp was previously doing this for us based on the range, perhaps we can
// find that logic and reuse it.
symbols.Add(new SymbolInformationOrDocumentSymbol(new DocumentSymbol
{
ContainerName = containerName,
Kind = SymbolTypeUtils.GetSymbolKind(r.Type),
Location = new Location
{
Uri = DocumentUri.From(r.FilePath),
// Jump to name start, but keep whole range to support symbol tree in outline
Range = new Range(r.NameRegion.ToRange().Start, r.ScriptRegion.ToRange().End)
},
Range = r.ScriptRegion.ToRange(),
SelectionRange = r.NameRegion.ToRange(),
Name = r.Name
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public override Task<Unit> Handle(DidChangeTextDocumentParams notification, Canc
return Unit.Task;
}

protected override TextDocumentSyncRegistrationOptions CreateRegistrationOptions(SynchronizationCapability capability, ClientCapabilities clientCapabilities)
protected override TextDocumentSyncRegistrationOptions CreateRegistrationOptions(TextSynchronizationCapability capability, ClientCapabilities clientCapabilities)
{
_isFileWatcherSupported = clientCapabilities.Workspace.DidChangeWatchedFiles.IsSupported;
return new TextDocumentSyncRegistrationOptions()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Microsoft.PowerShell.EditorServices.Handlers
{
internal class PsesWorkspaceSymbolsHandler : WorkspaceSymbolsHandlerBase
{
private static readonly Container<SymbolInformation> s_emptySymbolInformationContainer = new();
private static readonly Container<WorkspaceSymbol> s_emptySymbolInformationContainer = new();
private readonly ILogger _logger;
private readonly SymbolsService _symbolsService;
private readonly WorkspaceService _workspaceService;
Expand All @@ -33,12 +33,12 @@ public PsesWorkspaceSymbolsHandler(ILoggerFactory loggerFactory, SymbolsService

protected override WorkspaceSymbolRegistrationOptions CreateRegistrationOptions(WorkspaceSymbolCapability capability, ClientCapabilities clientCapabilities) => new() { };

public override async Task<Container<SymbolInformation>> Handle(WorkspaceSymbolParams request, CancellationToken cancellationToken)
public override async Task<Container<WorkspaceSymbol>> Handle(WorkspaceSymbolParams request, CancellationToken cancellationToken)
{
_logger.LogDebug($"Handling workspace symbols request for query {request.Query}");

await _symbolsService.ScanWorkspacePSFiles(cancellationToken).ConfigureAwait(false);
List<SymbolInformation> symbols = new();
List<WorkspaceSymbol> symbols = new();

foreach (ScriptFile scriptFile in _workspaceService.GetOpenedFiles())
{
Expand Down Expand Up @@ -84,8 +84,7 @@ public override async Task<Container<SymbolInformation>> Handle(WorkspaceSymbolP
Range = symbol.NameRegion.ToRange()
};

// TODO: This should be a WorkplaceSymbol now as SymbolInformation is deprecated.
symbols.Add(new SymbolInformation
symbols.Add(new WorkspaceSymbol
{
ContainerName = containerName,
Kind = SymbolTypeUtils.GetSymbolKind(symbol.Type),
Expand Down
14 changes: 7 additions & 7 deletions src/PowerShellEditorServices/Utility/LspUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ namespace Microsoft.PowerShell.EditorServices.Utility
{
internal static class LspUtils
{
public static DocumentSelector PowerShellDocumentSelector => new(
DocumentFilter.ForLanguage("powershell"),
DocumentFilter.ForLanguage("pwsh"),
public static TextDocumentSelector PowerShellDocumentSelector => new(
TextDocumentFilter.ForLanguage("powershell"),
TextDocumentFilter.ForLanguage("pwsh"),

// The vim extension sets all PowerShell files as language "ps1" so this
// makes sure we track those.
DocumentFilter.ForLanguage("ps1"),
DocumentFilter.ForLanguage("psm1"),
DocumentFilter.ForLanguage("psd1"),
TextDocumentFilter.ForLanguage("ps1"),
TextDocumentFilter.ForLanguage("psm1"),
TextDocumentFilter.ForLanguage("psd1"),

// Also specify the file extensions to be thorough
// This won't handle untitled files which is why we have to do the ones above.
DocumentFilter.ForPattern("**/*.ps*1")
TextDocumentFilter.ForPattern("**/*.ps*1")
);
}
}
15 changes: 15 additions & 0 deletions test/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig is awesome: http://EditorConfig.org

# not the top-most EditorConfig file
root = false

[*.{cs}]
# CA2007: Do not directly await a Task
dotnet_diagnostic.CA2007.severity = none

# xUnit1004: Test methods should not be skipped
dotnet_diagnostic.xUnit1004.severity = suggestion
# xUnit1030: Do not call ConfigureAwait in test method
dotnet_diagnostic.xUnit1030.severity = error
# xUnit2013: Do not use equality check to check for collection size
dotnet_diagnostic.xUnit2013.severity = error
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public static async Task LaunchScript(this DebugAdapterClient debugAdapterClient
Script = script,
Cwd = "",
CreateTemporaryIntegratedConsole = false
}).ConfigureAwait(true);
});

if (launchResponse is null)
{
throw new Exception("Launch response was null.");
}

// This will check to see if we received the Initialized event from the server.
await started.Task.ConfigureAwait(true);
await started.Task;
}
}
}
Loading