public LineCommentInfoTest() { this.commentClass = new StubIClassificationType(); this.commentClass.ClassificationGet = () => "comment"; this.commentClass.IsOfTypeString = s => string.Equals(s, "comment"); this.wholeLineCommentClassifier = new StubIClassifier(); this.wholeLineCommentClassifier.GetClassificationSpansSnapshotSpan = s => { // Find the "//"... Note: doesn't look for "''" (VB) or "/*" // (multi-line). That might need to change when we start // supporting more comment styles. var markerStart = s.GetText().IndexOf("//"); Assert.IsTrue(markerStart >= 0); var commentSpan = new SnapshotSpan(s.Start + markerStart, s.End); var span = new ClassificationSpan(commentSpan, this.commentClass); var list = new List<ClassificationSpan>(); list.Add(span); return list; }; this.defaultOptions = new SimpleEditorOptions(); this.defaultOptions.SetOptionValue("Tabs/ConvertTabsToSpaces", true); this.defaultOptions.SetOptionValue("Tabs/TabSize", 4); }
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); }