本文整理汇总了C#中SyntaxNode.GetAnnotatedTokens方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxNode.GetAnnotatedTokens方法的具体用法?C# SyntaxNode.GetAnnotatedTokens怎么用?C# SyntaxNode.GetAnnotatedTokens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxNode
的用法示例。
在下文中一共展示了SyntaxNode.GetAnnotatedTokens方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeDestinationSpan
private TextSpan ComputeDestinationSpan(SyntaxNode insertionRoot, string insertionText)
{
var targetToken = insertionRoot.GetAnnotatedTokens(_otherAnnotation).FirstOrNullable();
var text = insertionRoot.GetText();
var line = text.Lines.GetLineFromPosition(targetToken.Value.Span.End);
// DevDiv 958235:
//
// void foo()
// {
// }
// override $$
//
// If our text edit includes the trailing trivia of the close brace of foo(),
// that token will be reconstructed. The ensuing tree diff will then count
// the { } as replaced even though we didn't want it to. If the user
// has collapsed the outline for foo, that means we'll edit the outlined
// region and weird stuff will happen. Therefore, we'll start with the first
// token on the line in order to leave the token and its trivia alone.
var firstToken = insertionRoot.FindToken(line.GetFirstNonWhitespacePosition().Value);
return TextSpan.FromBounds(firstToken.SpanStart, line.End);
}
示例2: GetIdentifierTokenAtDeclaration
public SyntaxToken GetIdentifierTokenAtDeclaration(SyntaxNode node)
{
return node.GetAnnotatedTokens(_variableSymbol.IdentifierTokenAnnotation).SingleOrDefault();
}