Beispiel #1
0
        private void GetRegions()
        {
            ITextSnapshot textSnapShot = this.textBuffer.CurrentSnapshot;
            List <Region> tempRegions  = new List <Region>();

            foreach (var line in textSnapShot.Lines)
            {
                string lineText   = line.GetText();
                int    startIndex = lineText.IndexOf('{');

                // if we see start region symbol in non-comment line
                //
                if (!Utilities.IsCommentLine(lineText) && startIndex != -1)
                {
                    Region r = new Region();
                    r.Start = line.LineNumber;

                    SnapshotPoint?matchedPoint = FindMatchEndRegion(line.Start + startIndex);
                    if (matchedPoint.HasValue)
                    {
                        r.End = matchedPoint.Value.GetContainingLine().LineNumber;
                        tempRegions.Add(r);
                    }
                }
            }

            this.regions.Clear();
            this.regions.AddRange(tempRegions);

            if (TagsChanged != null)
            {
                TagsChanged.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(textSnapShot, 0, textSnapShot.Length)));
            }
        }
Beispiel #2
0
 private void UpdateEvents(object sender, TokenParserEventArgs e)
 {
     if (e.Event.GherkinTokenType == GherkinTokenType.SyntaxError)
     {
         TagsChanged.Invoke(this, new SnapshotSpanEventArgs(e.SnapshotSpan));
     }
 }
Beispiel #3
0
 public void Update()
 {
     if (TagsChanged != null)
     {
         TagsChanged.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(buffer.CurrentSnapshot, 0,
                                                                             buffer.CurrentSnapshot.Length)));
     }
 }
Beispiel #4
0
        private void NotifyTagChanged(ITextSnapshot snapshot)
        {
            IMappingSpan t = tagsChanged.Dequeue();
            NormalizedSnapshotSpanCollection sp = t.GetSpans(snapshot);

            if (TagsChanged != null)
            {
                TagsChanged.Invoke(this, new SnapshotSpanEventArgs(sp.First()));
            }
        }
 void SynchronousUpdate()
 {
     lock (ts_LockObject)
     {
         var t = TagsChanged;
         if (t != null)
         {
             TagsChanged.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(m_Snapshot, 0, m_Snapshot.Length)));
         }
     }
 }
Beispiel #6
0
        private void UpdateAtCaretPosition(CaretPosition caretPos)
        {
            currentCharSnapPoint = caretPos.Point.GetPoint(this.textBuffer, caretPos.Affinity);

            if (currentCharSnapPoint.HasValue)
            {
                if (TagsChanged != null)
                {
                    ITextSnapshot currentSnapshot = this.textBuffer.CurrentSnapshot;
                    TagsChanged.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(currentSnapshot, 0, currentSnapshot.Length)));
                }
            }
        }
 private void Storage_OnStoreChange(object sender, StoreChangeEventArgs e)
 {
     if (e.ChangedFileType.IsSet(ChangedFileTypeFlag.CSharp))
     {
         if (TagsChanged != null)
         {
             var span = new SnapshotSpan(_buffer.CurrentSnapshot, 0, _buffer.CurrentSnapshot.Length);
             _validator.OnChange(span);
             _validator.AddToErrorList();
             TagsChanged.Invoke(sender, new SnapshotSpanEventArgs(span));
         }
     }
 }
 private void Update(string currentWord)
 {
     _currentWord = currentWord;
     TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(_sourceBuffer.CurrentSnapshot, 0, _sourceBuffer.CurrentSnapshot.Length)));
 }
Beispiel #9
0
 void Classifier_ClassificationChanged(object sender, ClassificationChangedEventArgs e) =>
 TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(e.ChangeSpan));
Beispiel #10
0
 public void Disable(ITextSnapshot snapshot)
 {
     Enabled = false;
     TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(snapshot, new Span(0, snapshot.Length))));
 }
 private void RefreshTags()
 {
     CreateTrackingSpans();
     TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(_buffer.CurrentSnapshot, new Span(0, _buffer.CurrentSnapshot.Length - 1))));
 }
Beispiel #12
0
 public void RaiseTagsChanged(SnapshotSpanEventArgs snapshotSpanEventArgs)
 {
     TagsChanged?.Invoke(this, snapshotSpanEventArgs);
 }
Beispiel #13
0
 protected void InvokeTagsChanged(object sender, SnapshotSpanEventArgs args)
 {
     TagsChanged?.Invoke(sender, args);
 }
Beispiel #14
0
 private void OnTagsChanged(object sender, SnapshotSpanEventArgs e)
 {
     TagsChanged?.Invoke(this, e);
 }
 public void RefreshSpans(HexBufferSpanEventArgs e) => TagsChanged?.Invoke(this, e);
Beispiel #16
0
 private void ReportChangedSpan(SnapshotSpan changeSpan)
 {
     _batchChangeNotifier.AssertIsForeground();
     TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(changeSpan));
 }
Beispiel #17
0
 public void RaiseTagsChanged(SnapshotSpan span) => TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(span));
 private void SendTagsChangedEvent()
 {
     TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(
                             new SnapshotSpan(_sourceBuffer.CurrentSnapshot, 0, _sourceBuffer.CurrentSnapshot.Length)));
 }
 public void RefreshSpans(SnapshotSpanEventArgs e) => TagsChanged?.Invoke(this, e);
Beispiel #20
0
 public void RaiseTagsChanged(object?sender, HexTagsChangedEventArgs e) => TagsChanged?.Invoke(sender, e);
Beispiel #21
0
        void NotifyTagsChanged()
        {
            var entireFile = new SnapshotSpan(buffer.CurrentSnapshot, 0, buffer.CurrentSnapshot.Length);

            TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(entireFile));
        }
Beispiel #22
0
 public void ReloadTags()
 {
     TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(_buffer.CurrentSnapshot, 0, _buffer.CurrentSnapshot.Length)));
 }
 internal void Update()
 {
     TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(_textBuffer.CurrentSnapshot, 0, _textBuffer.CurrentSnapshot.Length)));
 }
Beispiel #24
0
 private void OnLayoutChanged(object sender, TextViewLayoutChangedEventArgs e)
 {
     TagsChanged?.Invoke(this,
                         new SnapshotSpanEventArgs(new SnapshotSpan(_sourceBuffer.CurrentSnapshot, 0,
                                                                    _sourceBuffer.CurrentSnapshot.Length)));
 }
Beispiel #25
0
        public IEnumerable <ITagSpan <TTagType> > GetTags(NormalizedSnapshotSpanCollection spans)
        {
            if (spans.Count == 0)
            {
                return(Enumerable.Empty <ITagSpan <TTagType> >());
            }

            var snapshot = spans[0].Snapshot;

            // The common case is spans.Count == 1, so try to prevent extra allocations
            IEnumerable <ITagSpan <TTagType> >?singleResult    = null;
            List <ITagSpan <TTagType> >?       multipleResults = null;
            SnapshotSpan?       singleMissingSpan    = null;
            List <SnapshotSpan>?multipleMissingSpans = null;

            lock (lockObj) {
                if (lastSnapshotState?.Snapshot != snapshot)
                {
                    lastSnapshotState?.Cancel();
                    lastSnapshotState?.FreeRef();
                    cachedTags.Clear();

                    lastSnapshotState = new SnapshotState(snapshot);
                    lastSnapshotState.AddRef();
                }
                Debug.Assert(!(lastSnapshotState is null));

                foreach (var span in spans)
                {
                    if (cachedTags.TryGetValue(span.Start.Position, out var tags))
                    {
                        if (singleResult is null)
                        {
                            singleResult = tags;
                        }
                        else
                        {
                            if (multipleResults is null)
                            {
                                multipleResults = new List <ITagSpan <TTagType> >(singleResult);
                            }
                            multipleResults.AddRange(tags);
                        }
                    }
                    else
                    {
                        if (singleMissingSpan is null)
                        {
                            singleMissingSpan = span;
                        }
                        else
                        {
                            if (multipleMissingSpans is null)
                            {
                                multipleMissingSpans = new List <SnapshotSpan>()
                                {
                                    singleMissingSpan.Value
                                }
                            }
                            ;
                            multipleMissingSpans.Add(span);
                        }
                    }
                }
            }
            Debug.Assert(multipleResults is null || multipleResults.Count >= 2);
            Debug.Assert(multipleMissingSpans is null || multipleMissingSpans.Count >= 2);

            if (!(singleMissingSpan is null))
            {
                if (spans.Count != (multipleMissingSpans?.Count ?? 1))
                {
                    spans = !(multipleMissingSpans is null) ?
                            new NormalizedSnapshotSpanCollection(multipleMissingSpans) :
                            new NormalizedSnapshotSpanCollection(singleMissingSpan.Value);
                }

                lock (lockObj) {
                    var lastSnapshotStateTmp = lastSnapshotState;
                    lastSnapshotStateTmp.GetTagsStateImpl.AddJob(spans);
                    if (!lastSnapshotStateTmp.TaskStarted)
                    {
                        lastSnapshotStateTmp.TaskStarted = true;
                        lastSnapshotStateTmp.AddRef();
                        GetTagsAsync(lastSnapshotStateTmp)
                        .ContinueWith(t => {
                            lastSnapshotStateTmp.FreeRef();
                            var ex = t.Exception;
                            if (t.IsCompleted && !t.IsCanceled && !t.IsFaulted)
                            {
                                SaveResult(t.Result);
                            }
                        });
                    }
                }
            }

            return(multipleResults ?? singleResult ?? Enumerable.Empty <ITagSpan <TTagType> >());
        }

        void SaveResult(TagsResult[] tagsResultList)
        {
            if (tagsResultList.Length == 0)
            {
                return;
            }

            bool sameSnapshot;

            lock (lockObj) {
                sameSnapshot = tagsResultList[0].Span.Snapshot == lastSnapshotState?.Snapshot;
                if (sameSnapshot)
                {
                    foreach (var result in tagsResultList)
                    {
                        cachedTags[result.Span.Span.Start] = result.Tags;
                    }
                }
            }

            if (sameSnapshot)
            {
                foreach (var result in tagsResultList)
                {
                    TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(result.Span));
                }
            }
        }

        async Task <TagsResult[]> GetTagsAsync(SnapshotState snapshotState)
        {
            try {
                NormalizedSnapshotSpanCollection?spans;
                for (;;)
                {
                    lock (lockObj) {
                        spans = snapshotState.GetTagsStateImpl.TryGetJob();
                        if (spans is null)
                        {
                            snapshotState.TaskStarted = false;
                            return(snapshotState.GetTagsStateImpl.GetResult());
                        }
                    }

                    snapshotState.GetTagsStateImpl.OnStartNewJob(spans);
                    await GetTagsAsync(snapshotState.GetTagsStateImpl, spans).ConfigureAwait(false);

                    snapshotState.GetTagsStateImpl.OnEndNewJob(spans);
                }
            }
            catch (OperationCanceledException) {
                throw;
            }
            catch {
                return(Array.Empty <TagsResult>());
            }
        }
 void BreakpointManager_BreakpointsChanged(object sender, SnapshotSpanEventArgs e)
 {
     TagsChanged?.Invoke(this, e);
 }
Beispiel #27
0
        private void DocumentValidated(object sender, EventArgs e)
        {
            var span = new SnapshotSpan(_buffer.CurrentSnapshot, 0, _buffer.CurrentSnapshot.Length);

            TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(span));
        }
 /// <summary>
 /// Causes intra-text adornments to be updated synchronously.
 /// </summary>
 protected void RaiseTagsChanged(SnapshotSpan span)
 {
     TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(span));
 }
Beispiel #29
0
        void RefreshAllTags()
        {
            var snapshot = textView.TextSnapshot;

            TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(snapshot, 0, snapshot.Length)));
        }
Beispiel #30
0
 private void OnTagsChanged(SnapshotSpanEventArgs e)
 {
     TagsChanged?.Invoke(this, e);
 }