@@ -373,6 +373,56 @@ public async Task DocumentHighlights_Success()
373373 } ) ;
374374 }
375375
376+ /// <summary>
377+ /// Ensure that the language client can successfully request DocumentHighlight.
378+ /// </summary>
379+ [ Fact ( DisplayName = "Language client can successfully request document symbols" ) ]
380+ public async Task DocumentSymbols_DocumentSymbol_Success ( )
381+ {
382+ await Connect ( ) ;
383+
384+ const int line = 5 ;
385+ const int character = 6 ;
386+ var expectedDocumentPath = AbsoluteDocumentPath ;
387+ var expectedDocumentUri = DocumentUri . FromFileSystemPath ( expectedDocumentPath ) ;
388+ var detail = "some detail" ;
389+
390+ var documentSymbol = new DocumentSymbol {
391+ Detail = detail ,
392+ Kind = SymbolKind . Class ,
393+ Range = new Range ( new Position ( line , character ) , new Position ( line , character ) )
394+ } ;
395+ var expectedSymbols = new SymbolInformationOrDocumentSymbolContainer (
396+ new SymbolInformationOrDocumentSymbol ( documentSymbol ) ) ;
397+
398+ ServerDispatcher . HandleRequest < DocumentSymbolParams , SymbolInformationOrDocumentSymbolContainer > ( DocumentNames . DocumentSymbol , ( request , cancellationToken ) => {
399+ Assert . NotNull ( request . TextDocument ) ;
400+
401+ Assert . Equal ( expectedDocumentUri , request . TextDocument . Uri ) ;
402+
403+ return Task . FromResult ( expectedSymbols ) ;
404+ } ) ;
405+ var documentSymbolParams = new DocumentSymbolParams {
406+ TextDocument = new TextDocumentIdentifier ( expectedDocumentUri )
407+ } ;
408+ var symbols = await LanguageClient . SendRequest < SymbolInformationOrDocumentSymbolContainer > ( DocumentNames . DocumentSymbol , documentSymbolParams ) ;
409+
410+ var actualSymbols = symbols . ToArray ( ) ;
411+ Assert . Collection ( actualSymbols , actualSymbol => {
412+ var expectedSymbol = expectedSymbols . Single ( ) ;
413+
414+ Assert . True ( expectedSymbol . IsDocumentSymbol ) ;
415+
416+ Assert . NotNull ( actualSymbol . DocumentSymbol ) ;
417+ Assert . Equal ( expectedSymbol . DocumentSymbol . Detail , actualSymbol . DocumentSymbol . Detail ) ;
418+ Assert . Equal ( expectedSymbol . DocumentSymbol . Kind , actualSymbol . DocumentSymbol . Kind ) ;
419+ Assert . Equal ( expectedSymbol . DocumentSymbol . Range . Start . Line , actualSymbol . DocumentSymbol . Range . Start . Line ) ;
420+ Assert . Equal ( expectedSymbol . DocumentSymbol . Range . Start . Character , actualSymbol . DocumentSymbol . Range . Start . Character ) ;
421+ Assert . Equal ( expectedSymbol . DocumentSymbol . Range . End . Line , actualSymbol . DocumentSymbol . Range . End . Line ) ;
422+ Assert . Equal ( expectedSymbol . DocumentSymbol . Range . End . Character , actualSymbol . DocumentSymbol . Range . End . Character ) ;
423+ } ) ;
424+ }
425+
376426 /// <summary>
377427 /// Ensure that the language client can successfully request FoldingRanges.
378428 /// </summary>
0 commit comments