本文整理汇总了C#中SyntaxTree.FindTokenOnLeftOfPosition方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxTree.FindTokenOnLeftOfPosition方法的具体用法?C# SyntaxTree.FindTokenOnLeftOfPosition怎么用?C# SyntaxTree.FindTokenOnLeftOfPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SyntaxTree
的用法示例。
在下文中一共展示了SyntaxTree.FindTokenOnLeftOfPosition方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckResult
protected override void CheckResult(bool validLocation, int position, SyntaxTree syntaxTree)
{
var leftToken = syntaxTree.FindTokenOnLeftOfPosition(position, CancellationToken.None);
var isPossibleTupleContext = syntaxTree.IsPossibleTupleContext(leftToken, position);
Assert.Equal(validLocation, isPossibleTupleContext);
}
示例2: GetObjectCreationNewExpression
protected override SyntaxNode GetObjectCreationNewExpression(SyntaxTree tree, int position, CancellationToken cancellationToken)
{
if (tree != null)
{
if (!tree.IsInNonUserCode(position, cancellationToken))
{
var tokenOnLeftOfPosition = tree.FindTokenOnLeftOfPosition(position, cancellationToken);
var newToken = tokenOnLeftOfPosition.GetPreviousTokenIfTouchingWord(position);
// Only after 'new'.
if (newToken.Kind() == SyntaxKind.NewKeyword)
{
// Only if the 'new' belongs to an object creation expression (and isn't a 'new'
// modifier on a member).
if (tree.IsObjectCreationTypeContext(position, tokenOnLeftOfPosition, cancellationToken))
{
return newToken.Parent as ExpressionSyntax;
}
}
}
}
return null;
}
示例3: IsPossibleTupleContext
public bool IsPossibleTupleContext(SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
{
var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
return syntaxTree.IsPossibleTupleContext(token, position);
}
示例4: GetToken
protected override SyntaxToken GetToken(CompletionItem completionItem, SyntaxTree tree, CancellationToken cancellationToken)
{
var tokenSpanEnd = MemberInsertionCompletionItem.GetTokenSpanEnd(completionItem);
return tree.FindTokenOnLeftOfPosition(tokenSpanEnd, cancellationToken);
}
示例5: FindStartingToken
public override SyntaxToken FindStartingToken(SyntaxTree tree, int position, CancellationToken cancellationToken)
{
var token = tree.FindTokenOnLeftOfPosition(position, cancellationToken);
return token.GetPreviousTokenIfTouchingWord(position);
}