提交 1243a1c3 编写于 作者: G Gen Lu

Let the helper also return whether there's any disallowed change

So the comsumer can use that to provide additional info to users. e.g. display a warning.
上级 77507a77
......@@ -691,7 +691,7 @@ private void CommitCore(IWaitContext waitContext, bool previewChanges)
var excludeChangesTask = newSolution.ExcludeDisallowedDocumentTextChangesAsync(_workspace.CurrentSolution, waitContext.CancellationToken);
excludeChangesTask.Wait(waitContext.CancellationToken);
newSolution = excludeChangesTask.Result;
newSolution = excludeChangesTask.Result.purgedSolution;
waitContext.AllowCancel = false;
......
......@@ -360,7 +360,8 @@ internal async Task<ChangeSignatureResult> ChangeSignatureWithContextAsync(Chang
updatedSolution = updatedSolution.WithDocumentSyntaxRoot(docId, updatedRoots[docId]);
}
return await updatedSolution.ExcludeDisallowedDocumentTextChangesAsync(originalSolution, cancellationToken).ConfigureAwait(false);
(_, updatedSolution) = await updatedSolution.ExcludeDisallowedDocumentTextChangesAsync(originalSolution, cancellationToken).ConfigureAwait(false);
return updatedSolution;
}
#nullable restore
......
......@@ -189,8 +189,9 @@ await ChangeNamespaceInSingleDocumentAsync(solutionAfterNamespaceChange, documen
cancellationToken).ConfigureAwait(false);
var mergedSolution = await MergeDiffAsync(solutionAfterFirstMerge, solutionAfterImportsRemoved, cancellationToken).ConfigureAwait(false);
(_, mergedSolution) = await mergedSolution.ExcludeDisallowedDocumentTextChangesAsync(solution, cancellationToken).ConfigureAwait(false);
return await mergedSolution.ExcludeDisallowedDocumentTextChangesAsync(solution, cancellationToken).ConfigureAwait(false);
return mergedSolution;
}
finally
{
......
......@@ -90,9 +90,10 @@ public static IEnumerable<DocumentId> FilterDocumentIdsByLanguage(this Solution
}
}
public static async Task<Solution> ExcludeDisallowedDocumentTextChangesAsync(this Solution newSolution, Solution oldSolution, CancellationToken cancellationToken)
public static async Task<(bool containsDisallowedChange, Solution purgedSolution)> ExcludeDisallowedDocumentTextChangesAsync(this Solution newSolution, Solution oldSolution, CancellationToken cancellationToken)
{
var solutionChanges = newSolution.GetChanges(oldSolution);
var containsDisallowedChange = false;
foreach (var projectChange in solutionChanges.GetProjectChanges())
{
......@@ -104,6 +105,8 @@ public static async Task<Solution> ExcludeDisallowedDocumentTextChangesAsync(thi
continue;
}
containsDisallowedChange = true;
var oldRoot = await oldDocument.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var newDocument = newSolution.GetDocument(changedDocumentId)!;
var revertedDocument = newDocument.WithSyntaxRoot(oldRoot);
......@@ -112,7 +115,7 @@ public static async Task<Solution> ExcludeDisallowedDocumentTextChangesAsync(thi
}
}
return newSolution;
return (containsDisallowedChange, newSolution);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册