Skip to content

Commit a4e0fff

Browse files
CopilotJustinGrote
andauthored
Fix CS0103: add GetDocumentSymbols helper and make FindsSymbolsInFile async
Agent-Logs-Url: https://github.com/PowerShell/PowerShellEditorServices/sessions/1f70b303-b695-4522-916d-016544f441de Co-authored-by: JustinGrote <15258962+JustinGrote@users.noreply.github.com>
1 parent 5c13ef2 commit a4e0fff

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using Microsoft.PowerShell.EditorServices.Test.Shared.References;
2222
using Microsoft.PowerShell.EditorServices.Test.Shared.SymbolDetails;
2323
using Microsoft.PowerShell.EditorServices.Test.Shared.Symbols;
24+
using Microsoft.PowerShell.EditorServices.Handlers;
2425
using OmniSharp.Extensions.LanguageServer.Protocol;
2526
using OmniSharp.Extensions.LanguageServer.Protocol.Models;
2627
using Xunit;
@@ -140,6 +141,21 @@ private IEnumerable<SymbolReference> FindSymbolsInFile(ScriptRegion scriptRegion
140141
.OrderBy(symbol => symbol.ScriptRegion.ToRange().Start);
141142
}
142143

144+
private async Task<IEnumerable<DocumentSymbol>> GetDocumentSymbols(ScriptRegion scriptRegion)
145+
{
146+
string path = TestUtilities.GetSharedPath(scriptRegion.File);
147+
PsesDocumentSymbolHandler handler = new(NullLoggerFactory.Instance, workspace);
148+
SymbolInformationOrDocumentSymbolContainer result = await handler.Handle(
149+
new DocumentSymbolParams
150+
{
151+
TextDocument = new TextDocumentIdentifier { Uri = DocumentUri.FromFileSystemPath(path) }
152+
},
153+
CancellationToken.None);
154+
return result
155+
.Where(s => s.IsDocumentSymbol)
156+
.Select(s => s.DocumentSymbol);
157+
}
158+
143159
[Fact]
144160
public async Task FindsParameterHintsOnCommand()
145161
{
@@ -768,7 +784,7 @@ public async Task FindsDetailsForBuiltInCommand()
768784
}
769785

770786
[Fact]
771-
public void FindsSymbolsInFile()
787+
public async Task FindsSymbolsInFile()
772788
{
773789
IEnumerable<SymbolReference> symbols = FindSymbolsInFile(FindSymbolsInMultiSymbolFile.SourceDetails);
774790

@@ -795,8 +811,8 @@ public void FindsSymbolsInFile()
795811
Assert.True(symbol.IsDeclaration);
796812

797813
DocumentSymbol filterDocumentSymbol = Assert.Single(
798-
GetDocumentSymbols(FindSymbolsInMultiSymbolFile.SourceDetails),
799-
i => i.Name == "AFilter");
814+
await GetDocumentSymbols(FindSymbolsInMultiSymbolFile.SourceDetails),
815+
i => i.Name == "filter AFilter ()");
800816
DocumentSymbol filterVariableDocumentSymbol = Assert.Single(
801817
filterDocumentSymbol.Children,
802818
i => i.Name == "$FilterVar");

0 commit comments

Comments
 (0)