提交 8c624b21 编写于 作者: C Cyrus Najmabadi

Remove redundant helper.

上级 558d04b3
......@@ -145,7 +145,7 @@ public sealed override Task RegisterCodeFixesAsync(CodeFixContext context)
if (switchNode == null)
return;
var model = await document.RequireSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var model = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false);
// https://github.com/dotnet/roslyn/issues/40505
var switchStatement = (TSwitchOperation)model.GetOperation(switchNode, cancellationToken)!;
......
......@@ -54,7 +54,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
Document document, ImmutableArray<Diagnostic> diagnostics,
SyntaxEditor editor, CancellationToken cancellationToken)
{
var semanticModel = await document.RequireSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var semanticModel = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var generator = editor.Generator;
var generatorInternal = document.GetRequiredLanguageService<SyntaxGeneratorInternal>();
foreach (var diagnostic in diagnostics)
......
......@@ -58,7 +58,7 @@ public override Task RegisterCodeFixesAsync(CodeFixContext context)
return;
}
var semanticModel = await document.RequireSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var semanticModel = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false);
if (!Analyzer.TryGetAnalyzer(semanticModel.Compilation, out var analyzer))
{
Debug.Fail("Could not get analyzer");
......
......@@ -67,7 +67,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
if (MatchesIncrementPattern(variable, condition, after, out var start, out var equals, out var end) ||
MatchesDecrementPattern(variable, condition, after, out end, out start))
{
var semanticModel = await document.RequireSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var semanticModel = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false);
if (IsUnsignedBoundary(semanticModel, variable, start, end, cancellationToken))
{
// Don't allow reversing when you have unsigned types and are on the start/end
......
......@@ -184,12 +184,6 @@ public static async Task<bool> IsGeneratedCodeAsync(this Document document, Canc
await generatedCodeRecognitionService.IsGeneratedCodeAsync(document, cancellationToken).ConfigureAwait(false);
}
public static async Task<SemanticModel> RequireSemanticModelAsync(this Document document, CancellationToken cancellationToken)
{
var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
return model ?? throw new InvalidOperationException();
}
public static IEnumerable<Document> GetLinkedDocuments(this Document document)
{
var solution = document.Project.Solution;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册