internal PersistentSpan(Span span, SpanTrackingMode trackingMode, PersistentSpanSet spanSet) { _useLineIndex = false; _originalSpan = span; _trackingMode = trackingMode; this.SpanSet = spanSet; }
internal void SetSpanSet(PersistentSpanSet spanSet) { if (this.SpanSet == null) { throw new ObjectDisposedException("PersistentSpan"); } this.SpanSet = spanSet; }
public void Dispose() { if (this.SpanSet != null) { this.SpanSet.Delete(this); this.SpanSet = null; _originalVersion = null; _span = null; } }
internal PersistentSpan(int startLine, int startIndex, int endLine, int endIndex, SpanTrackingMode trackingMode, PersistentSpanSet spanSet) { _useLineIndex = true; _startLine = startLine; _startIndex = startIndex; _endLine = endLine; _endIndex = endIndex; _trackingMode = trackingMode; this.SpanSet = spanSet; }
internal void Delete(PersistentSpanSet spanSet, PersistentSpan span) { lock (_spansOnDocuments) { if (spanSet.Spans.Remove(span) && (spanSet.Spans.Count == 0)) { _spansOnDocuments.Remove(((object)(spanSet.Document)) ?? spanSet.FileKey); spanSet.Dispose(); } } }
internal PersistentSpan(SnapshotSpan span, SpanTrackingMode trackingMode, PersistentSpanSet spanSet) { _span = span.Snapshot.CreateTrackingSpan(span, trackingMode); _originalVersion = span.Snapshot.Version; _originalSpan = span; PersistentSpan.SnapshotPointToLineIndex(span.Start, out _startLine, out _startIndex); PersistentSpan.SnapshotPointToLineIndex(span.End, out _endLine, out _endIndex); _trackingMode = trackingMode; this.SpanSet = spanSet; }
} //For unit tests private PersistentSpanSet GetOrCreateSpanSet(FileNameKey filePath, ITextDocument document) { object key = ((object)document) ?? filePath; if (!_spansOnDocuments.TryGetValue(key, out PersistentSpanSet spanSet)) { if (!_eventsHooked) { _eventsHooked = true; this.TextDocumentFactoryService.TextDocumentCreated += OnTextDocumentCreated; this.TextDocumentFactoryService.TextDocumentDisposed += OnTextDocumentDisposed; } spanSet = new PersistentSpanSet(filePath, document, this); _spansOnDocuments.Add(key, spanSet); } return(spanSet); }
internal void DocumentRenamed(PersistentSpanSet spanSet) { lock (_spansOnDocuments) { if (_spansOnDocuments.TryGetValue(spanSet.FileKey, out PersistentSpanSet existingSpansOnPath)) { // There were spans on a closed document with the same name as this one. Move all of those spans to this one // and "open" them (note that this will probably do bad things to their positions but it is the best we // can do). foreach (var s in existingSpansOnPath.Spans) { s.SetSpanSet(spanSet); spanSet.Spans.Add(s); s.DocumentReopened(); } existingSpansOnPath.Spans.Clear(); existingSpansOnPath.Dispose(); } } }