public void TextRangeCollection_ItemsInRangeTest()
        {
            TextRangeCollection <TextRange> target = MakeCollection();

            IReadOnlyList <TextRange> list = target.ItemsInRange(TextRange.EmptyRange);

            list.Should().BeEmpty();

            list = target.ItemsInRange(TextRange.FromBounds(-10, -1));
            list.Should().BeEmpty();

            list = target.ItemsInRange(TextRange.FromBounds(0, Int32.MaxValue));
            list.Should().HaveCount(3);

            list = target.ItemsInRange(TextRange.FromBounds(Int32.MinValue / 2, Int32.MaxValue / 2));
            list.Should().HaveCount(3);

            list = target.ItemsInRange(TextRange.FromBounds(1, 7));
            list.Should().HaveCount(3);

            list = target.ItemsInRange(TextRange.FromBounds(0, 8));
            list.Should().HaveCount(3);

            list = target.ItemsInRange(TextRange.FromBounds(1, 1));
            list.Should().BeEmpty(); // Zero-length ranges can't contain anything

            list = target.ItemsInRange(TextRange.FromBounds(1, 2));
            list.Should().HaveCount(1);

            list = target.ItemsInRange(TextRange.FromBounds(1, 3));
            list.Should().HaveCount(1);

            list = target.ItemsInRange(TextRange.FromBounds(1, 4));
            list.Should().HaveCount(2);
        }
Beispiel #2
0
        public IReadOnlyList <EditorErrorTag> ItemsInRange(ITextRange range)
        {
            IReadOnlyList <EditorErrorTag> list;

            lock (_lockObj) {
                list = _tags.ItemsInRange(range);
            }

            return(list);
        }
Beispiel #3
0
        /// <summary>
        /// Determines if a given range is inside a comment and
        /// returns range of the comment block.
        /// </summary>
        /// <param name="range">Text range to check</param>
        /// <returns>Text range of the found comment block or empty range if not found.</returns>
        public ITextRange GetCommentBlockContainingRange(ITextRange range)
        {
            TextRangeCollection <RToken> comments = this.AstRoot.Comments;

            var commentsInRange = comments.ItemsInRange(range);

            if (commentsInRange.Count == 1)
            {
                return(commentsInRange[0]);
            }

            return(TextRange.EmptyRange);
        }