提交 34a43dde 编写于 作者: C CyrusNajmabadi

Remove more blocking on async calls.

上级 e133ca42
......@@ -109,7 +109,7 @@ protected override string GetEndingString(Document document, int position, Cance
// prepare expansive information from document
var tree = document.GetSyntaxTreeSynchronously(cancellationToken);
var root = tree.GetRoot(cancellationToken);
var text = tree.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken);
var text = tree.GetText(cancellationToken);
var semicolon = SyntaxFacts.GetText(SyntaxKind.SemicolonToken);
// Go through the set of owning nodes in leaf to root chain.
......
......@@ -140,7 +140,7 @@ public void ExecuteCommand(AutomaticLineEnderCommandArgs args, Action nextHandle
private int? GetInsertionPoint(Document document, ITextSnapshotLine line, CancellationToken cancellationToken)
{
var root = document.GetSyntaxRootSynchronously(cancellationToken);
var text = document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken);
var text = root.SyntaxTree.GetText(cancellationToken);
var syntaxFacts = document.GetLanguageService<ISyntaxFactsService>();
......
......@@ -447,8 +447,8 @@ private void AddLineBreaks(SourceText text, IList<string> lines)
return false;
}
var text = document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken);
var syntaxTree = document.GetSyntaxTreeSynchronously(cancellationToken);
var text = syntaxTree.GetText(cancellationToken);
return insertAction(syntaxTree, text, caretPosition, originalCaretPosition, subjectBuffer, textView, cancellationToken);
}
......@@ -552,8 +552,8 @@ public CommandState GetCommandState(InsertCommentCommandArgs args, Func<CommandS
TMemberNode targetMember = null;
_waitIndicator.Wait("IntelliSense", allowCancel: true, action: c =>
{
var text = document.GetTextAsync(c.CancellationToken).WaitAndGetResult(c.CancellationToken);
var syntaxTree = document.GetSyntaxTreeSynchronously(c.CancellationToken);
var text = syntaxTree.GetText(c.CancellationToken);
targetMember = GetTargetMember(syntaxTree, text, caretPosition, c.CancellationToken);
});
......
......@@ -539,7 +539,8 @@ private ITextBuffer CreateNewBuffer(Document document, CancellationToken cancell
var contentTypeService = document.Project.LanguageServices.GetService<IContentTypeLanguageService>();
var contentType = contentTypeService.GetDefaultContentType();
return _textBufferFactoryService.CreateTextBuffer(document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken).ToString(), contentType);
return _textBufferFactoryService.CreateTextBuffer(
document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken).ToString(), contentType);
}
private ITextBuffer CreateNewPlainTextBuffer(TextDocument document, CancellationToken cancellationToken)
......@@ -548,7 +549,8 @@ private ITextBuffer CreateNewPlainTextBuffer(TextDocument document, Cancellation
var contentType = _textBufferFactoryService.TextContentType;
return _textBufferFactoryService.CreateTextBuffer(document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken).ToString(), contentType);
return _textBufferFactoryService.CreateTextBuffer(
document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken).ToString(), contentType);
}
private async Task<object> CreateNewDifferenceViewerAsync(PreviewWorkspace leftWorkspace, PreviewWorkspace rightWorkspace,
......
......@@ -44,7 +44,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.AutomaticCompletion
Protected Overrides Function GetEndingString(document As Document, position As Integer, cancellationToken As CancellationToken) As String
' prepare expansive information from document
Dim root = document.GetSyntaxRootSynchronously(cancellationToken)
Dim text = document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken)
Dim text = root.SyntaxTree.GetText(cancellationToken)
' get line where the caret is on
Dim line = text.Lines.GetLineFromPosition(position)
......
......@@ -47,8 +47,8 @@ private int FormatWorker(IVsTextLayer textLayer, TextSpan[] selections, Cancella
return VSConstants.E_FAIL;
}
var text = document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken);
var root = document.GetSyntaxRootSynchronously(cancellationToken);
var text = root.SyntaxTree.GetText(cancellationToken);
var ts = selections.Single();
int start = text.Lines[ts.iStartLine].Start + ts.iStartIndex;
......
......@@ -48,9 +48,9 @@ internal class FileChange : AbstractChange
_componentModel = componentModel;
var bufferFactory = componentModel.GetService<ITextBufferFactoryService>();
var bufferText = left != null ?
left.GetTextAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None) :
right.GetTextAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None);
var bufferText = left != null
? left.GetTextAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None)
: right.GetTextAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None);
_buffer = bufferFactory.CreateTextBuffer(bufferText.ToString(), bufferFactory.InertContentType);
_encoding = bufferText.Encoding;
......
......@@ -82,4 +82,4 @@ private bool TryGetDocumentWithFullyQualifiedTypeName(Document document, out Tex
return true;
}
}
}
}
\ No newline at end of file
......@@ -81,7 +81,7 @@ public IFormattingRule CreateRule(Document document, int position)
var spans = pooledObject.Object;
var root = document.GetSyntaxRootSynchronously(CancellationToken.None);
var text = document.GetTextAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None);
var text = root.SyntaxTree.GetText(CancellationToken.None);
spans.AddRange(containedDocument.GetEditorVisibleSpans());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册