@@ -920,7 +920,8 @@ public async Task<ImmutableArray<ReferencedSymbol>> FindAllSymbolReferences(ISym
920920 return null ;
921921 }
922922
923- public async Task UpdateDocument ( SharpIdeFile fileModel , string newContent )
923+ // Returns true if the document was found and updated, otherwise false
924+ public async Task < bool > UpdateDocument ( SharpIdeFile fileModel , string newContent )
924925 {
925926 using var _ = SharpIdeOtel . Source . StartActivity ( $ "{ nameof ( RoslynAnalysis ) } .{ nameof ( UpdateDocument ) } ") ;
926927 await _solutionLoadedTcs . Task ;
@@ -937,7 +938,7 @@ public async Task UpdateDocument(SharpIdeFile fileModel, string newContent)
937938 if ( documentId is null )
938939 {
939940 _logger . LogWarning ( "UpdateDocument failed: Document '{DocumentPath}' not found in workspace" , fileModel . Path ) ;
940- return ;
941+ return false ;
941942 }
942943
943944 var newText = SourceText . From ( newContent , Encoding . UTF8 ) ;
@@ -957,6 +958,11 @@ public async Task UpdateDocument(SharpIdeFile fileModel, string newContent)
957958 {
958959 _workspace . OnAnalyzerConfigDocumentTextChanged ( documentId , newText , PreservationMode . PreserveIdentity ) ;
959960 }
961+ else
962+ {
963+ return false ;
964+ }
965+ return true ;
960966 }
961967
962968 public async Task AddDocument ( SharpIdeFile fileModel , string content )
@@ -1022,7 +1028,7 @@ public async Task AddDocument(SharpIdeFile fileModel, string content)
10221028 } , WorkspaceChangeKind . DocumentAdded , documentId : documentId ) ;
10231029 }
10241030
1025- public async Task RemoveDocument ( SharpIdeFile fileModel )
1031+ public async Task < bool > RemoveDocument ( SharpIdeFile fileModel )
10261032 {
10271033 using var _ = SharpIdeOtel . Source . StartActivity ( $ "{ nameof ( RoslynAnalysis ) } .{ nameof ( AddDocument ) } ") ;
10281034 await _solutionLoadedTcs . Task ;
@@ -1038,7 +1044,7 @@ public async Task RemoveDocument(SharpIdeFile fileModel)
10381044 if ( documentId is null )
10391045 {
10401046 _logger . LogWarning ( "RemoveDocument failed: Document '{DocumentPath}' not found in workspace" , fileModel . Path ) ;
1041- return ;
1047+ return false ;
10421048 }
10431049 var documentKind = _workspace . CurrentSolution . GetDocumentKind ( documentId ) ;
10441050 Guard . Against . Null ( documentKind ) ;
@@ -1050,6 +1056,7 @@ public async Task RemoveDocument(SharpIdeFile fileModel)
10501056 case TextDocumentKind . AnalyzerConfigDocument : _workspace . OnAnalyzerConfigDocumentRemoved ( documentId ) ; break ;
10511057 default : throw new ArgumentOutOfRangeException ( nameof ( documentKind ) ) ;
10521058 }
1059+ return true ;
10531060 }
10541061
10551062 public async Task MoveDocument ( SharpIdeFile sharpIdeFile , string oldFilePath )
0 commit comments