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


C# SyntaxNode.TryGetClosestBreakpointSpan方法代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.SyntaxNode.TryGetClosestBreakpointSpan方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxNode.TryGetClosestBreakpointSpan方法的具体用法?C# SyntaxNode.TryGetClosestBreakpointSpan怎么用?C# SyntaxNode.TryGetClosestBreakpointSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.CodeAnalysis.SyntaxNode的用法示例。


在下文中一共展示了SyntaxNode.TryGetClosestBreakpointSpan方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryGetActiveSpan

        protected override bool TryGetActiveSpan(SyntaxNode node, int statementPart, out TextSpan span)
        {
            switch (node.Kind())
            {
                case SyntaxKind.Block:
                    span = GetActiveSpan((BlockSyntax)node, (BlockPart)statementPart);
                    return true;

                case SyntaxKind.ForEachStatement:
                    span = GetActiveSpan((ForEachStatementSyntax)node, (ForEachPart)statementPart);
                    return true;

                case SyntaxKind.DoStatement:
                    // The active statement of DoStatement node is the while condition,
                    // which is lexically not the closest breakpoint span (the body is).
                    // do { ... } [|while (condition);|]
                    var doStatement = (DoStatementSyntax)node;
                    return node.TryGetClosestBreakpointSpan(doStatement.WhileKeyword.SpanStart, out span);

                case SyntaxKind.PropertyDeclaration:
                    // The active span corresponding to a property declaration is the span corresponding to its initializer (if any),
                    // not the span correspoding to the accessor.
                    // int P { [|get;|] } = [|<initializer>|];
                    var propertyDeclaration = (PropertyDeclarationSyntax)node;

                    if (propertyDeclaration.Initializer != null &&
                        node.TryGetClosestBreakpointSpan(propertyDeclaration.Initializer.SpanStart, out span))
                    {
                        return true;
                    }
                    else
                    {
                        span = default(TextSpan);
                        return false;
                    }

                default:
                    return node.TryGetClosestBreakpointSpan(node.SpanStart, out span);
            }
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:40,代码来源:CSharpEditAndContinueAnalyzer.cs

示例2: GetBreakpointSequence

 public static IEnumerable<TextSpan> GetBreakpointSequence(SyntaxNode root, int position)
 {
     int endPosition = root.Span.End;
     int lastSpanEnd = 0;
     while (position < endPosition)
     {
         TextSpan span;
         if (root.TryGetClosestBreakpointSpan(position, out span) && span.End > lastSpanEnd)
         {
             position = lastSpanEnd = span.End;
             yield return span;
         }
         else
         {
             position++;
         }
     }
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:18,代码来源:BreakpointLocationValidatorTests.cs

示例3: TryGetEnclosingBreakpointSpan

 protected override bool TryGetEnclosingBreakpointSpan(SyntaxNode root, int position, out TextSpan span)
 {
     return root.TryGetClosestBreakpointSpan(position, out span);
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:4,代码来源:CSharpEditAndContinueAnalyzer.cs


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