2121using Microsoft . PowerShell . EditorServices . Test . Shared . References ;
2222using Microsoft . PowerShell . EditorServices . Test . Shared . SymbolDetails ;
2323using Microsoft . PowerShell . EditorServices . Test . Shared . Symbols ;
24+ using Microsoft . PowerShell . EditorServices . Handlers ;
2425using OmniSharp . Extensions . LanguageServer . Protocol ;
2526using OmniSharp . Extensions . LanguageServer . Protocol . Models ;
2627using 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