예제 #1
0
        internal PersistentSpan(Span span, SpanTrackingMode trackingMode, PersistentSpanSet spanSet)
        {
            _useLineIndex = false;
            _originalSpan = span;

            _trackingMode = trackingMode;
            this.SpanSet  = spanSet;
        }
예제 #2
0
        internal void SetSpanSet(PersistentSpanSet spanSet)
        {
            if (this.SpanSet == null)
            {
                throw new ObjectDisposedException("PersistentSpan");
            }

            this.SpanSet = spanSet;
        }
예제 #3
0
 public void Dispose()
 {
     if (this.SpanSet != null)
     {
         this.SpanSet.Delete(this);
         this.SpanSet     = null;
         _originalVersion = null;
         _span            = null;
     }
 }
예제 #4
0
        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;
        }
예제 #5
0
 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();
         }
     }
 }
예제 #6
0
        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;
        }
예제 #7
0
        }                                                                      //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);
        }
예제 #8
0
        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();
                }
            }
        }