提交 b4f3e30c 编写于 作者: C Cyrus Najmabadi

Rename method

上级 c86bde90
......@@ -38,7 +38,7 @@ protected override async Task TestWorkerAsync(Document document, TextSpan textSp
}
else
{
inferredType = typeInference.InferType(await document.GetSemanticModelForSpanAsync(node?.Span ?? textSpan, CancellationToken.None), node, objectAsDefault: true, cancellationToken: CancellationToken.None);
inferredType = typeInference.InferType(await document.ReuseExistingSpeculativeModelAsync(node?.Span ?? textSpan, CancellationToken.None), node, objectAsDefault: true, cancellationToken: CancellationToken.None);
}
var typeSyntax = inferredType.GenerateTypeSyntax().NormalizeWhitespace();
......
......@@ -27,9 +27,9 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.TypeInferrer
Dim inferredType As ITypeSymbol
If testMode = TestMode.Position Then
inferredType = typeInference.InferType(Await document.GetSemanticModelForSpanAsync(New TextSpan(node.SpanStart, 0), CancellationToken.None), node.SpanStart, objectAsDefault:=True, cancellationToken:=CancellationToken.None)
inferredType = typeInference.InferType(Await document.ReuseExistingSpeculativeModelAsync(New TextSpan(node.SpanStart, 0), CancellationToken.None), node.SpanStart, objectAsDefault:=True, cancellationToken:=CancellationToken.None)
Else
inferredType = typeInference.InferType(Await document.GetSemanticModelForSpanAsync(node.Span, CancellationToken.None), node, objectAsDefault:=True, cancellationToken:=CancellationToken.None)
inferredType = typeInference.InferType(Await document.ReuseExistingSpeculativeModelAsync(node.Span, CancellationToken.None), node, objectAsDefault:=True, cancellationToken:=CancellationToken.None)
End If
Dim typeSyntax = inferredType.GenerateTypeSyntax().NormalizeWhitespace()
......
......@@ -61,7 +61,7 @@ public override async Task<string> GetHelpTermAsync(Document document, TextSpan
if (IsValid(token, span))
{
var semanticModel = await document.GetSemanticModelForSpanAsync(span, cancellationToken).ConfigureAwait(false);
var semanticModel = await document.ReuseExistingSpeculativeModelAsync(span, cancellationToken).ConfigureAwait(false);
var result = TryGetText(token, semanticModel, document, syntaxFacts, cancellationToken);
if (string.IsNullOrEmpty(result))
......
......@@ -34,7 +34,7 @@ public async Task<Document> CaseCorrectAsync(Document document, ImmutableArray<T
throw new NotSupportedException(WorkspacesResources.Document_does_not_support_syntax_trees);
}
var semanticModel = await document.GetSemanticModelForSpanAsync(spans.Collapse(), cancellationToken).ConfigureAwait(false);
var semanticModel = await document.ReuseExistingSpeculativeModelAsync(spans.Collapse(), cancellationToken).ConfigureAwait(false);
var newRoot = CaseCorrect(semanticModel, root, spans, document.Project.Solution.Workspace, cancellationToken);
return (root == newRoot) ? document : document.WithSyntaxRoot(newRoot);
......
......@@ -24,7 +24,7 @@ public static class Classifier
TextSpan textSpan,
CancellationToken cancellationToken = default)
{
var semanticModel = await document.GetSemanticModelForSpanAsync(textSpan, cancellationToken).ConfigureAwait(false);
var semanticModel = await document.ReuseExistingSpeculativeModelAsync(textSpan, cancellationToken).ConfigureAwait(false);
return GetClassifiedSpans(semanticModel, textSpan, document.Project.Solution.Workspace, cancellationToken);
}
......
......@@ -37,7 +37,7 @@ protected AbstractSyntaxClassificationService()
{
try
{
var semanticModel = await document.GetSemanticModelForSpanAsync(textSpan, cancellationToken).ConfigureAwait(false);
var semanticModel = await document.ReuseExistingSpeculativeModelAsync(textSpan, cancellationToken).ConfigureAwait(false);
AddSemanticClassifications(semanticModel, textSpan, document.Project.Solution.Workspace, getNodeClassifiers, getTokenClassifiers, result, cancellationToken);
}
catch (Exception e) when (FatalError.ReportUnlessCanceled(e))
......
......@@ -75,7 +75,7 @@ public static bool IsOpen(this Document document)
/// As a speculative semantic model may be returned, location based information provided by it may be innacurate.
/// </summary>
public static Task<SemanticModel> ReuseExistingSpeculativeModelAsync(this Document document, int position, CancellationToken cancellationToken)
=> GetSemanticModelForSpanAsync(document, new TextSpan(position, 0), cancellationToken);
=> ReuseExistingSpeculativeModelAsync(document, new TextSpan(position, 0), cancellationToken);
/// <summary>
/// This will return either regular semantic model or speculative semantic based on context. any feature that is
......@@ -87,7 +87,7 @@ public static Task<SemanticModel> ReuseExistingSpeculativeModelAsync(this Docume
/// <para/>
/// As a speculative semantic model may be returned, location based information provided by it may be innacurate.
/// </summary>
public static async Task<SemanticModel> GetSemanticModelForSpanAsync(this Document document, TextSpan span, CancellationToken cancellationToken)
public static async Task<SemanticModel> ReuseExistingSpeculativeModelAsync(this Document document, TextSpan span, CancellationToken cancellationToken)
{
Contract.ThrowIfFalse(document.SupportsSemanticModel);
......
......@@ -44,7 +44,7 @@ Namespace Microsoft.CodeAnalysis.CodeCleanup.Providers
Public Shared Async Function CreateAsync(document As Document, spans As ImmutableArray(Of TextSpan), cancellationToken As CancellationToken) As Task(Of AddMissingTokensRewriter)
Dim modifiedSpan = spans.Collapse()
Dim semanticModel = If(document Is Nothing, Nothing,
Await document.GetSemanticModelForSpanAsync(modifiedSpan, cancellationToken).ConfigureAwait(False))
Await document.ReuseExistingSpeculativeModelAsync(modifiedSpan, cancellationToken).ConfigureAwait(False))
Return New AddMissingTokensRewriter(semanticModel, spans, cancellationToken)
End Function
......
......@@ -56,7 +56,7 @@ Namespace Microsoft.CodeAnalysis.CodeCleanup.Providers
Dim modifiedSpan = spans.Collapse()
Dim semanticModel = If(document Is Nothing,
Nothing,
Await document.GetSemanticModelForSpanAsync(modifiedSpan, cancellationToken).ConfigureAwait(False))
Await document.ReuseExistingSpeculativeModelAsync(modifiedSpan, cancellationToken).ConfigureAwait(False))
Return New FixIncorrectTokensRewriter(semanticModel, spans, cancellationToken)
End Function
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册