本文整理汇总了C#中Microsoft.CodeAnalysis.SyntaxTree.GetRootAsync方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxTree.GetRootAsync方法的具体用法?C# SyntaxTree.GetRootAsync怎么用?C# SyntaxTree.GetRootAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.SyntaxTree
的用法示例。
在下文中一共展示了SyntaxTree.GetRootAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindToken
internal static SyntaxToken FindToken (SyntaxTree snapshot, int position, CancellationToken cancellationToken)
{
var root = snapshot.GetRootAsync(cancellationToken).WaitAndGetResult(CancellationToken.None);
return root.FindToken(position, findInsideTrivia: true);
}
示例2: BuildRecoverableTreeTextAsync
private static async Task<SourceText> BuildRecoverableTreeTextAsync(SyntaxTree tree, Encoding encoding, CancellationToken cancellationToken)
{
// build text from root, so recoverable tree won't cycle.
var root = await tree.GetRootAsync(cancellationToken).ConfigureAwait(false);
return root.GetText(encoding);
}
示例3: FindMethodSyntaxAsync
public static async Task<Tuple<BaseMethodDeclarationSyntax, IMethodSymbol>> FindMethodSyntaxAsync(
SemanticModel model, SyntaxTree tree, MethodDescriptor method)
{
var root = await tree.GetRootAsync();
var visitor = new MethodFinder(method, model);
visitor.Visit(root);
if (visitor.Result != null)
{
return new Tuple<BaseMethodDeclarationSyntax, IMethodSymbol>(
visitor.Result,
(IMethodSymbol)model.GetDeclaredSymbol(visitor.Result)
);
}
else
{
return null;
}
}