3131using Microsoft . CodeAnalysis . Text ;
3232using Microsoft . CommonLanguageServerProtocol . Framework ;
3333using Nerdbank . Streams ;
34+ using Roslyn . LanguageServer . Protocol ;
3435using Roslyn . Utilities ;
3536using StreamJsonRpc ;
3637using Xunit ;
@@ -74,7 +75,7 @@ internal class TestSpanMapper : ISpanMappingService
7475 internal static readonly LSP . Location MappedFileLocation = new LSP . Location
7576 {
7677 Range = ProtocolConversions . LinePositionToRange ( s_mappedLinePosition ) ,
77- Uri = ProtocolConversions . CreateAbsoluteUri ( s_mappedFilePath )
78+ Uri = ProtocolConversions . CreateAbsoluteDocumentUri ( s_mappedFilePath )
7879 } ;
7980
8081 /// <summary>
@@ -159,7 +160,7 @@ private protected static int CompareLocations(LSP.Location? l1, LSP.Location? l2
159160 if ( l2 is null )
160161 return 1 ;
161162
162- var compareDocument = l1 . Uri . AbsoluteUri . CompareTo ( l2 . Uri . AbsoluteUri ) ;
163+ var compareDocument = l1 . Uri . UriString . CompareTo ( l2 . Uri . UriString ) ;
163164 var compareRange = CompareRange ( l1 . Range , l2 . Range ) ;
164165 return compareDocument != 0 ? compareDocument : compareRange ;
165166 }
@@ -206,7 +207,7 @@ internal static LSP.SymbolInformation CreateSymbolInformation(LSP.SymbolKind kin
206207 return info ;
207208 }
208209
209- private protected static LSP . TextDocumentIdentifier CreateTextDocumentIdentifier ( Uri uri , ProjectId ? projectContext = null )
210+ private protected static LSP . TextDocumentIdentifier CreateTextDocumentIdentifier ( DocumentUri uri , ProjectId ? projectContext = null )
210211 {
211212 var documentIdentifier = new LSP . VSTextDocumentIdentifier { Uri = uri } ;
212213
@@ -474,7 +475,7 @@ protected static async Task RemoveGeneratorAsync(AnalyzerReference reference, Ed
474475
475476 return locations ;
476477
477- static LSP . Location ConvertTextSpanWithTextToLocation ( TextSpan span , SourceText text , Uri documentUri )
478+ static LSP . Location ConvertTextSpanWithTextToLocation ( TextSpan span , SourceText text , DocumentUri documentUri )
478479 {
479480 var location = new LSP . Location
480481 {
@@ -500,7 +501,7 @@ private static string GetDocumentFilePathFromName(string documentName)
500501 => "C:\\ " + documentName ;
501502
502503 private static LSP . DidChangeTextDocumentParams CreateDidChangeTextDocumentParams (
503- Uri documentUri ,
504+ DocumentUri documentUri ,
504505 ImmutableArray < ( LSP . Range Range , string Text ) > changes )
505506 {
506507 var changeEvents = changes . Select ( change => new LSP . TextDocumentContentChangeEvent
@@ -519,7 +520,7 @@ private static LSP.DidChangeTextDocumentParams CreateDidChangeTextDocumentParams
519520 } ;
520521 }
521522
522- private static LSP . DidOpenTextDocumentParams CreateDidOpenTextDocumentParams ( Uri uri , string source , string languageId = "" )
523+ private static LSP . DidOpenTextDocumentParams CreateDidOpenTextDocumentParams ( DocumentUri uri , string source , string languageId = "" )
523524 => new LSP . DidOpenTextDocumentParams
524525 {
525526 TextDocument = new LSP . TextDocumentItem
@@ -530,7 +531,7 @@ private static LSP.DidOpenTextDocumentParams CreateDidOpenTextDocumentParams(Uri
530531 }
531532 } ;
532533
533- private static LSP . DidCloseTextDocumentParams CreateDidCloseTextDocumentParams ( Uri uri )
534+ private static LSP . DidCloseTextDocumentParams CreateDidCloseTextDocumentParams ( DocumentUri uri )
534535 => new LSP . DidCloseTextDocumentParams ( )
535536 {
536537 TextDocument = new LSP . TextDocumentIdentifier
@@ -650,14 +651,14 @@ private static RoslynLanguageServer CreateLanguageServer(Stream inputStream, Str
650651 return languageServer ;
651652 }
652653
653- public async Task < Document > GetDocumentAsync ( Uri uri )
654+ public async Task < Document > GetDocumentAsync ( DocumentUri uri )
654655 {
655656 var document = await GetCurrentSolution ( ) . GetDocumentAsync ( new LSP . TextDocumentIdentifier { Uri = uri } , CancellationToken . None ) . ConfigureAwait ( false ) ;
656657 Contract . ThrowIfNull ( document , $ "Unable to find document with { uri } in solution") ;
657658 return document ;
658659 }
659660
660- public async Task < SourceText > GetDocumentTextAsync ( Uri uri )
661+ public async Task < SourceText > GetDocumentTextAsync ( DocumentUri uri )
661662 {
662663 var document = await GetDocumentAsync ( uri ) . ConfigureAwait ( false ) ;
663664 return await document . GetTextAsync ( CancellationToken . None ) . ConfigureAwait ( false ) ;
@@ -692,7 +693,7 @@ public Task ExecutePreSerializedRequestAsync(string methodName, JsonDocument ser
692693 return _clientRpc . InvokeWithParameterObjectAsync ( methodName , serializedRequest ) ;
693694 }
694695
695- public async Task OpenDocumentAsync ( Uri documentUri , string ? text = null , string languageId = "" )
696+ public async Task OpenDocumentAsync ( DocumentUri documentUri , string ? text = null , string languageId = "" )
696697 {
697698 if ( text == null )
698699 {
@@ -706,15 +707,15 @@ public async Task OpenDocumentAsync(Uri documentUri, string? text = null, string
706707 await ExecuteRequestAsync < LSP . DidOpenTextDocumentParams , object > ( LSP . Methods . TextDocumentDidOpenName , didOpenParams , CancellationToken . None ) ;
707708 }
708709
709- public Task ReplaceTextAsync ( Uri documentUri , params ( LSP . Range Range , string Text ) [ ] changes )
710+ public Task ReplaceTextAsync ( DocumentUri documentUri , params ( LSP . Range Range , string Text ) [ ] changes )
710711 {
711712 var didChangeParams = CreateDidChangeTextDocumentParams (
712713 documentUri ,
713714 [ .. changes ] ) ;
714715 return ExecuteRequestAsync < LSP . DidChangeTextDocumentParams , object > ( LSP . Methods . TextDocumentDidChangeName , didChangeParams , CancellationToken . None ) ;
715716 }
716717
717- public Task InsertTextAsync ( Uri documentUri , params ( int Line , int Column , string Text ) [ ] changes )
718+ public Task InsertTextAsync ( DocumentUri documentUri , params ( int Line , int Column , string Text ) [ ] changes )
718719 {
719720 return ReplaceTextAsync ( documentUri , [ .. changes . Select ( change => ( new LSP . Range
720721 {
@@ -723,7 +724,7 @@ public Task InsertTextAsync(Uri documentUri, params (int Line, int Column, strin
723724 } , change . Text ) ) ] ) ;
724725 }
725726
726- public Task DeleteTextAsync ( Uri documentUri , params ( int StartLine , int StartColumn , int EndLine , int EndColumn ) [ ] changes )
727+ public Task DeleteTextAsync ( DocumentUri documentUri , params ( int StartLine , int StartColumn , int EndLine , int EndColumn ) [ ] changes )
727728 {
728729 return ReplaceTextAsync ( documentUri , [ .. changes . Select ( change => ( new LSP . Range
729730 {
@@ -732,7 +733,7 @@ public Task DeleteTextAsync(Uri documentUri, params (int StartLine, int StartCol
732733 } , string . Empty ) ) ] ) ;
733734 }
734735
735- public Task CloseDocumentAsync ( Uri documentUri )
736+ public Task CloseDocumentAsync ( DocumentUri documentUri )
736737 {
737738 var didCloseParams = CreateDidCloseTextDocumentParams ( documentUri ) ;
738739 return ExecuteRequestAsync < LSP . DidCloseTextDocumentParams , object > ( LSP . Methods . TextDocumentDidCloseName , didCloseParams , CancellationToken . None ) ;
@@ -790,7 +791,7 @@ internal async Task WaitForDiagnosticsAsync()
790791
791792 internal T GetRequiredLspService < T > ( ) where T : class , ILspService => LanguageServer . GetTestAccessor ( ) . GetRequiredLspService < T > ( ) ;
792793
793- internal ImmutableArray < SourceText > GetTrackedTexts ( ) => [ .. GetManager ( ) . GetTrackedLspText ( ) . Values . Select ( v => v . Text ) ] ;
794+ internal ImmutableArray < SourceText > GetTrackedTexts ( ) => [ .. GetManager ( ) . GetTrackedLspText ( ) . Values . Select ( v => v . SourceText ) ] ;
794795
795796 internal Task RunCodeAnalysisAsync ( ProjectId ? projectId )
796797 => _codeAnalysisService . RunAnalysisAsync ( GetCurrentSolution ( ) , projectId , onAfterProjectAnalyzed : _ => { } , CancellationToken . None ) ;
0 commit comments