本文整理汇总了C#中TextSpan.OverlapsWith方法的典型用法代码示例。如果您正苦于以下问题:C# TextSpan.OverlapsWith方法的具体用法?C# TextSpan.OverlapsWith怎么用?C# TextSpan.OverlapsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextSpan
的用法示例。
在下文中一共展示了TextSpan.OverlapsWith方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddClassification
private void AddClassification(TextSpan textSpan, string type)
{
if (textSpan.Length > 0 && textSpan.OverlapsWith(_textSpan))
{
var tuple = new ClassifiedSpan(type, textSpan);
if (!_set.Contains(tuple))
{
_list.Add(tuple);
_set.Add(tuple);
}
}
}
示例2: GetMembersInSpan
private static List<MemberDeclarationSyntax> GetMembersInSpan(
TextSpan textSpan,
TypeDeclarationSyntax containingType,
MemberDeclarationSyntax firstMember)
{
List<MemberDeclarationSyntax> selectedMembers = null;
var members = containingType.Members;
var fieldIndex = members.IndexOf(firstMember);
if (fieldIndex < 0)
{
return null;
}
for (var i = fieldIndex; i < members.Count; i++)
{
var member = members[i];
if (textSpan.Contains(member.Span))
{
selectedMembers = selectedMembers ?? new List<MemberDeclarationSyntax>();
selectedMembers.Add(member);
}
else if (textSpan.OverlapsWith(member.Span))
{
return null;
}
else
{
break;
}
}
return selectedMembers;
}
示例3: TextSpanOverlap04
public void TextSpanOverlap04()
{
TextSpan span1 = new TextSpan(10, 0); // [10, 10)
TextSpan span2 = new TextSpan(5, 10); // [5, 15)
Assert.False(span1.OverlapsWith(span2));
Assert.False(span2.OverlapsWith(span1));
Assert.Null(span1.Overlap(span2));
Assert.Null(span2.Overlap(span1));
}
示例4: TextSpanOverlap02
public void TextSpanOverlap02()
{
TextSpan span1 = new TextSpan(10, 10); // 10..20
TextSpan span2 = new TextSpan(5, 10); // 5..15
Assert.True(span1.OverlapsWith(span2));
Assert.True(span2.OverlapsWith(span1));
Assert.Equal(span1.Overlap(span2), new TextSpan(10, 5));
Assert.Equal(span2.Overlap(span1), new TextSpan(10, 5));
}
示例5: TextSpanOverlap01
public void TextSpanOverlap01()
{
TextSpan span1 = new TextSpan(10, 10); // 10..20
TextSpan span2 = new TextSpan(5, 2); // 5..7
Assert.False(span1.OverlapsWith(span2));
Assert.False(span2.OverlapsWith(span1));
Assert.Null(span1.Overlap(span2));
Assert.Null(span2.Overlap(span1));
}
示例6: TextSpan_DoesNotOverlapWithEmpty
public void TextSpan_DoesNotOverlapWithEmpty()
{
var empty = new TextSpan(SourceText.From(""), 1, 0);
Assert.False(empty.OverlapsWith(empty));
}
示例7: TextSpan_OverlapsWithSelf
public void TextSpan_OverlapsWithSelf()
{
var textSpan = new TextSpan(SourceText.From(""), 1, 2);
Assert.True(textSpan.OverlapsWith(textSpan));
}
示例8: IsInSpan
private static bool IsInSpan(ref TextSpan span, TextSpan childSpan)
{
return span.OverlapsWith(childSpan)
// special case for zero-width tokens (OverlapsWith never returns true for these)
|| (childSpan.Length == 0 && span.IntersectsWith(childSpan));
}
示例9: TextSpan_DoesNotOverlapWithEmpty
public void TextSpan_DoesNotOverlapWithEmpty()
{
var empty = new TextSpan(null, 1, 0);
Assert.False(empty.OverlapsWith(empty));
}
示例10: TextSpan_OverlapsWithSelf
public void TextSpan_OverlapsWithSelf()
{
var textSpan = new TextSpan(null, 1, 2);
Assert.True(textSpan.OverlapsWith(textSpan));
}