Update get code action changes
This commit is contained in:
@@ -616,21 +616,15 @@ public class RoslynAnalysis
|
|||||||
await _solutionLoadedTcs.Task;
|
await _solutionLoadedTcs.Task;
|
||||||
var cancellationToken = CancellationToken.None;
|
var cancellationToken = CancellationToken.None;
|
||||||
var operations = await codeAction.GetOperationsAsync(cancellationToken);
|
var operations = await codeAction.GetOperationsAsync(cancellationToken);
|
||||||
var changedDocumentIds = new List<DocumentId>();
|
|
||||||
var originalSolution = _workspace!.CurrentSolution;
|
var originalSolution = _workspace!.CurrentSolution;
|
||||||
|
var updatedSolution = originalSolution;
|
||||||
foreach (var operation in operations)
|
foreach (var operation in operations)
|
||||||
{
|
{
|
||||||
if (operation is ApplyChangesOperation applyChangesOperation)
|
if (operation is ApplyChangesOperation applyChangesOperation)
|
||||||
{
|
{
|
||||||
// TODO: Handle added and removed documents
|
var changes = applyChangesOperation.ChangedSolution.GetChanges(updatedSolution);
|
||||||
var newSolution = applyChangesOperation.ChangedSolution;
|
// TODO: What does this actually do
|
||||||
var changedDocIds = newSolution
|
updatedSolution = await applyChangesOperation.ChangedSolution.WithMergedLinkedFileChangesAsync(updatedSolution, changes, cancellationToken).ConfigureAwait(false);
|
||||||
.GetChanges(_workspace!.CurrentSolution)
|
|
||||||
.GetProjectChanges()
|
|
||||||
.SelectMany(s => s.GetChangedDocuments().Concat(s.GetChangedAdditionalDocuments()));
|
|
||||||
changedDocumentIds.AddRange(changedDocIds);
|
|
||||||
|
|
||||||
_workspace.TryApplyChanges(newSolution);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -638,9 +632,17 @@ public class RoslynAnalysis
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var changedFilesWithText = await changedDocumentIds
|
var allChanges = updatedSolution.GetChanges(originalSolution);
|
||||||
.DistinctBy(s => s.Id)
|
// TODO: Handle added and removed documents
|
||||||
.Select(id => _workspace!.CurrentSolution.GetDocument(id))
|
var changedDocIds = allChanges
|
||||||
|
.GetExplicitlyChangedSourceGeneratedDocuments().Union(allChanges
|
||||||
|
.GetProjectChanges()
|
||||||
|
.SelectMany(s => s.GetChangedDocuments().Union(s.GetChangedAdditionalDocuments()))).ToHashSet();
|
||||||
|
|
||||||
|
var changedFilesWithText = await changedDocIds
|
||||||
|
.DistinctBy(s => s.Id) // probably not necessary
|
||||||
|
.Select(id => updatedSolution.GetDocument(id))
|
||||||
|
//.Select(id => updatedSolution.GetDocument(id) ?? await _workspace.CurrentSolution.GetSourceGeneratedDocumentAsync(id, cancellationToken))
|
||||||
.Where(d => d is not null)
|
.Where(d => d is not null)
|
||||||
.OfType<Document>() // ensures non-null
|
.OfType<Document>() // ensures non-null
|
||||||
.ToAsyncEnumerable()
|
.ToAsyncEnumerable()
|
||||||
@@ -652,8 +654,6 @@ public class RoslynAnalysis
|
|||||||
})
|
})
|
||||||
.ToListAsync(cancellationToken);
|
.ToListAsync(cancellationToken);
|
||||||
|
|
||||||
_workspace.TryApplyChanges(originalSolution);
|
|
||||||
|
|
||||||
return changedFilesWithText;
|
return changedFilesWithText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user