private async Task <SnapshotSpan> GetChangedSpanAsync( Document currentDocument, ITextSnapshot currentSnapshot, CancellationToken cancellationToken) { // We don't need to grab _lastProcessedDocument in a lock. We don't care which version of the previous // doc we grab, just that we grab some prior version. This is only used to narrow down the changed range we // specify, so it's ok if it's slightly larger because we read in a change from a couple of edits ago. var previousDocument = _lastProcessedDocument; if (previousDocument != null) { var service = TryGetClassificationService(currentSnapshot); if (service != null) { var changeRange = await service.ComputeSyntacticChangeRangeAsync( previousDocument, currentDocument, _diffTimeout, cancellationToken).ConfigureAwait(false); if (changeRange != null) { return(currentSnapshot.GetSpan(changeRange.Value.Span.Start, changeRange.Value.NewLength)); } } } // Couldn't compute a narrower range. Just the mark the entire file as changed. return(currentSnapshot.GetFullSpan()); }
private ClassificationSpan ClassificationSpanFor(Token token, ITextSnapshot textBuffer, int offset) { var textSpan = textBuffer.GetSpan(offset + token.Begin, token.End - token.Begin); return(new ClassificationSpan(ClassificationFor(token, textSpan), textSpan)); }
public static TextSpan GetSpan(this ITextSnapshot snapshot, Span span) { return(snapshot.GetSpan(span.Start, span.Length)); }
public static SnapshotSpan GetFullSpan(this ITextSnapshot snapshot) { return(snapshot.GetSpan(0, snapshot.Length)); }
private ClassificationSpan ClassificationSpanFor(Token token, ITextSnapshot textBuffer, int offset) { var textSpan = textBuffer.GetSpan(offset + token.Begin, token.End - token.Begin); return new ClassificationSpan(ClassificationFor(token, textSpan), textSpan); }