本文整理汇总了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);
}
}
示例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++;
}
}
}
示例3: TryGetEnclosingBreakpointSpan
protected override bool TryGetEnclosingBreakpointSpan(SyntaxNode root, int position, out TextSpan span)
{
return root.TryGetClosestBreakpointSpan(position, out span);
}