internal static IEnumerator <ClassificationSpan> ForwardClassificationSpanEnumerator(PythonClassifier classifier, SnapshotPoint startPoint) { var startLine = startPoint.GetContainingLine(); int curLine = startLine.LineNumber; if (startPoint > startLine.End) { // May occur if startPoint is between \r and \n startPoint = startLine.End; } var tokens = classifier.GetClassificationSpans(new SnapshotSpan(startPoint, startLine.End)); for (; ;) { for (int i = 0; i < tokens.Count; ++i) { yield return(tokens[i]); } // indicate the line break yield return(null); ++curLine; if (curLine < startPoint.Snapshot.LineCount) { var nextLine = startPoint.Snapshot.GetLineFromLineNumber(curLine); tokens = classifier.GetClassificationSpans(nextLine.Extent); } else { break; } } }
internal static IEnumerator <ClassificationSpan> ReverseClassificationSpanEnumerator(PythonClassifier classifier, SnapshotPoint startPoint) { var startLine = startPoint.GetContainingLine(); int curLine = startLine.LineNumber; var tokens = classifier.GetClassificationSpans(new SnapshotSpan(startLine.Start, startPoint)); for (; ;) { for (int i = tokens.Count - 1; i >= 0; i--) { yield return(tokens[i]); } // indicate the line break yield return(null); curLine--; if (curLine >= 0) { var prevLine = startPoint.Snapshot.GetLineFromLineNumber(curLine); tokens = classifier.GetClassificationSpans(prevLine.Extent); } else { break; } } }
private static bool IsCommentChar(SnapshotPoint prevPoint, PythonClassifier classifier) { IList <ClassificationSpan> spans; spans = classifier.GetClassificationSpans(new SnapshotSpan(prevPoint, 1)); if (spans.Count == 1 && spans[0].ClassificationType.IsOfType(PredefinedClassificationTypeNames.Comment)) { return(true); } return(false); }
private static bool IsCommentChar(SnapshotPoint prevPoint, PythonClassifier classifier) { IList<ClassificationSpan> spans; spans = classifier.GetClassificationSpans(new SnapshotSpan(prevPoint, 1)); if (spans.Count == 1 && spans[0].ClassificationType.IsOfType(PredefinedClassificationTypeNames.Comment)) { return true; } return false; }