当前位置: 首页>>代码示例>>C#>>正文


C# SyntaxTree.FindTokenOnLeftOfPosition方法代码示例

本文整理汇总了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);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:7,代码来源:PossibleTupleContextTests.cs

示例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;
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:24,代码来源:ObjectCreationCompletionProvider.cs

示例3: IsPossibleTupleContext

 public bool IsPossibleTupleContext(SyntaxTree syntaxTree, int position, CancellationToken cancellationToken)
 {
     var token = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken);
     return syntaxTree.IsPossibleTupleContext(token, position);
 }
开发者ID:genlu,项目名称:roslyn,代码行数:5,代码来源:CSharpSyntaxFactsService.cs

示例4: GetToken

 protected override SyntaxToken GetToken(CompletionItem completionItem, SyntaxTree tree, CancellationToken cancellationToken)
 {
     var tokenSpanEnd = MemberInsertionCompletionItem.GetTokenSpanEnd(completionItem);
     return tree.FindTokenOnLeftOfPosition(tokenSpanEnd, cancellationToken);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:5,代码来源:OverrideCompletionProvider.cs

示例5: FindStartingToken

 public override SyntaxToken FindStartingToken(SyntaxTree tree, int position, CancellationToken cancellationToken)
 {
     var token = tree.FindTokenOnLeftOfPosition(position, cancellationToken);
     return token.GetPreviousTokenIfTouchingWord(position);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:5,代码来源:OverrideCompletionProvider.cs


注:本文中的SyntaxTree.FindTokenOnLeftOfPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。