Example #1
0
        public SimpleLine(SimpleSnapshot snapshot, int lineNumber, int start, string text)
        {
            this.Snapshot = snapshot;
            this.text = text;

            this.LineNumber = lineNumber;

            this.LengthIncludingLineBreak = this.text.Length;
            this.Length = this.LengthIncludingLineBreak;
            this.LineBreakLength = 0;

            if (this.Length >= 1 && text[this.Length - 1] == '\n')
            {
                this.Length--;
                this.LineBreakLength++;
            }

            if (this.Length >= 1 + this.LineBreakLength && text[this.Length - 1 - this.LineBreakLength] == '\r')
            {
                this.Length--;
                this.LineBreakLength++;
            }

            this.Start = new SnapshotPoint(this.Snapshot, start);
            this.EndIncludingLineBreak = new SnapshotPoint(this.Snapshot, start + this.LengthIncludingLineBreak);
            this.End = new SnapshotPoint(this.Snapshot, start + this.Length);
            this.Extent = new SnapshotSpan(this.Start, this.End);
            this.ExtentIncludingLineBreak = new SnapshotSpan(this.Start, this.EndIncludingLineBreak);
        }
Example #2
0
        public void LineCommentInfo_LeadingEightSpaceTabIsEightSpaces()
        {
            var snapshot = new SimpleSnapshot(
                "\t// this is a comment");

            var eightSpaceTab = new SimpleEditorOptions();
            eightSpaceTab.Parent = this.defaultOptions;
            eightSpaceTab.SetOptionValue("Tabs/TabSize", 8);

            var info = LineCommentInfo.FromLine(
                snapshot.GetLineFromLineNumber(0),
                eightSpaceTab,
                this.wholeLineCommentClassifier);

            Assert.IsNotNull(info);
            Assert.IsTrue(info.CommentOnly);
            Assert.AreEqual(1, info.CommentSpan.Start.Position);
            Assert.AreEqual(1, info.MarkerSpan.Start.Position);
            Assert.AreEqual(8, info.MarkerColumnStart);
            Assert.AreEqual(4, info.ContentSpan.Start.Position);
            Assert.AreEqual(11, info.ContentColumnStart);
        }
Example #3
0
 public SimpleBuffer(SimpleSnapshot snapshot, bool editable = true)
     : this(editable: editable)
 {
     this.snapshot = snapshot;
 }
Example #4
0
        public void LineCommentInfo_LeadingTabIsFourSpaces()
        {
            var snapshot = new SimpleSnapshot(
                "\t// this is a comment");

            var info = LineCommentInfo.FromLine(
                snapshot.GetLineFromLineNumber(0),
                this.defaultOptions,
                this.wholeLineCommentClassifier);

            Assert.IsNotNull(info);
            Assert.IsTrue(info.CommentOnly);
            Assert.AreEqual(1, info.CommentSpan.Start.Position);
            Assert.AreEqual(1, info.MarkerSpan.Start.Position);
            Assert.AreEqual(4, info.MarkerColumnStart);
            Assert.AreEqual(4, info.ContentSpan.Start.Position);
            Assert.AreEqual(7, info.ContentColumnStart);
        }
Example #5
0
        public void LineCommentInfo_SimpleSingleLineCommentsMatch()
        {
            var snapshot = new SimpleSnapshot(
                "// this is a comment",
                "// that continues to a second line");

            var info0 = LineCommentInfo.FromLine(
                snapshot.GetLineFromLineNumber(0),
                this.defaultOptions,
                this.wholeLineCommentClassifier);

            var info1 = LineCommentInfo.FromLine(
                snapshot.GetLineFromLineNumber(1),
                this.defaultOptions,
                this.wholeLineCommentClassifier);

            Assert.IsNotNull(info0);
            Assert.IsNotNull(info1);
            Assert.IsTrue(info0.Matches(info1));
        }
Example #6
0
        public void LineCommentInfo_SimpleSingleLineComment()
        {
            var snapshot = new SimpleSnapshot(
                "// this is a comment");

            var info = LineCommentInfo.FromLine(
                snapshot.GetLineFromLineNumber(0),
                this.defaultOptions,
                this.wholeLineCommentClassifier);

            Assert.IsNotNull(info);
            Assert.IsTrue(info.CommentOnly);
            Assert.AreEqual(info.Line.Extent, info.CommentSpan);
            Assert.AreEqual(0, info.MarkerSpan.Start.Position);
            Assert.AreEqual(2, info.MarkerSpan.End.Position);
            Assert.AreEqual(2, info.MarkerSpan.Length);
            Assert.AreEqual(0, info.MarkerColumnStart);
            Assert.AreEqual(CommentStyle.SingleLine, info.Style);
            Assert.AreEqual(3, info.ContentSpan.Start.Position);
            Assert.AreEqual(3, info.ContentColumnStart);
            Assert.AreEqual(info.Line.End.Position, info.ContentSpan.End.Position);
        }