示例#1
0
        private void OnEventSourceChanged(object?sender, TaggerEventArgs args)
        {
            // First, notify anyone listening to us that something definitely changed.
            this.Changed?.Invoke(this, args);

            var document = _subjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();

            if (document == null)
            {
                return;
            }

            if (!document.SupportsSemanticModel)
            {
                return;
            }

            // Now, attempt to cancel any existing work to get the compilation for this project, and kick off a new
            // piece of work in the future to do so.  Do this after a delay so we can appropriately throttle ourselves
            // if we hear about a flurry of notifications.
            _workQueue.CancelCurrentWork();
            _workQueue.EnqueueBackgroundTask(async c =>
            {
                await document.Project.GetCompilationAsync(c).ConfigureAwait(false);
                this.Changed?.Invoke(this, new TaggerEventArgs());
            },
                                             $"{nameof(CompilationAvailableTaggerEventSource)}.{nameof(OnEventSourceChanged)}",
                                             500,
                                             _workQueue.CancellationToken);
        }
 private void button4_Click(object sender, EventArgs e)
 {
     if (fastSituationView.SelectedIndex != -1)
     {
         foreach (var item in fastSituationView.SelectedObjects)
         {
             TaggerEventArgs args = new TaggerEventArgs();
             var             arr  = item.ToString().Split();
             args.Id  = int.Parse(arr[1]);
             args.Tag = arr[0];
             if ((sender as Button).Text == "Delete")
             {
                 DeleteSituation?.Invoke(this, args);
             }
             else
             {
                 if (tagsetView.SelectedItems.Count > 0)
                 {
                     args.AdditionalInfo = new Dictionary <string, object>();
                     args.AdditionalInfo.Add("Change", tagsetView.SelectedItems[0].Text);
                     EditSituation?.Invoke(this, args);
                 }
             }
         }
     }
 }
 private void OnEventSourceChanged(object sender, TaggerEventArgs e)
 {
     _owner._notificationService.RegisterNotification(
         OnEventSourceChanged_OnForeground,
         _owner._asyncListener.BeginAsyncOperation("SemanticClassificationBufferTaggerProvider"),
         _cancellationTokenSource.Token);
 }
示例#4
0
        private void _tagger_AddTag(object sender, TaggerEventArgs e)
        {
            //Stopwatch.StartNew();
            if (SituationIndex.TagsetCounter.Count != 0)
            {
                SituationIndex.AddSituationToIndex(e.messages, e.Id, e.Tag);

                foreach (var id in e.messages)
                {
                    if (!MessageContainer.Messages[id].Situations.ContainsKey(e.Tag))
                    {
                        MessageContainer.Messages[id].Situations.Add(e.Tag, SituationIndex.TagsetCounter[e.Tag]);
                    }
                    else
                    {
                        //MessageContainer.Messages[id].Situations[e.Tag]
                        _tagger.DisplayTagErrorMessage();
                    }
                }
                _tagger.AddSituationIndexItem(e.Tag + " " + SituationIndex.TagsetCounter[e.Tag].ToString());
                var count = SituationIndex.Index[e.Tag].Count;
                SituationIndex.TagsetCounter[e.Tag]++;
            }
            else
            {
                foreach (var str in TagsetIndex.Index[_service.ProjectTagset])
                {
                    SituationIndex.TagsetCounter.Add(str, 0);
                    _tagger.AddSituationIndexItem(e.Tag + " " + SituationIndex.TagsetCounter[e.Tag].ToString());
                }
            }
            _tagger.UpdateSituationCount(SituationIndex.SituationCount());
        }
示例#5
0
        private void addTagButton_Click(object sender, EventArgs e)
        {
            if (tagsetView.SelectedItems.Count != 0 && chatTable.SelectedObjects.Count != 0)
            {
                TaggerEventArgs args = new TaggerEventArgs();
                args.Id = IndexEngine.SituationIndex.TagsetCounter[tagsetView.SelectedItems[0].Text];

                args.Tag = tagsetView.SelectedItems[0].Text;

                args.messages = new List <int>();

                foreach (var obj in chatTable.SelectedObjects)
                {
                    DynamicMessage msg = (DynamicMessage)obj;
                    args.messages.Add(msg.Id);
                }

                AddTag?.Invoke(this, args);

                //fastSituationView.Items.Add(args.Tag + " " + args.Id);
                chatTable.UpdateObjects(MessageContainer.Messages.FindAll(x => args.messages.Contains(x.Id)));
            }
            else
            {
                MessageBox.Show("Select a tag and messages first");
            }
        }
示例#6
0
        private void removeTagButton_Click(object sender, EventArgs e)
        {
            TaggerEventArgs args = new TaggerEventArgs();

            if (chatTable.SelectedObjects != null)
            {
                foreach (var obj in chatTable.SelectedObjects)
                {
                    DynamicMessage dyn = obj as DynamicMessage;
                    args.messages = new List <int>();
                    args.messages.Add(dyn.Id);
                    if (dyn.Situations.Count == 1)
                    {
                        args.Tag = dyn.Situations.FirstOrDefault().Key;
                        args.Id  = dyn.Situations.FirstOrDefault().Value;
                        RemoveTag?.Invoke(this, args);
                    }
                    if (dyn.Situations.Count > 1)
                    {
                        //todo
                    }
                    //MessageContainer.Messages[dyn.Id].Situations.Clear();
                }
            }
        }
示例#7
0
 private void VoidLastSolutionVersionIfCaretChanged(TaggerEventArgs e)
 {
     if (e.Kind == PredefinedChangedEventKinds.CaretPositionChanged)
     {
         _lastUpdateTagsSolutionVersion = VoidVersion;
     }
 }
示例#8
0
        private void deleteSituationButton_Click(object sender, EventArgs e)
        {
            TaggerEventArgs args = new TaggerEventArgs();

            args.Tag = fastSituationView.SelectedObject.ToString().Split(' ')[0];
            args.Id  = Int32.Parse(fastSituationView.SelectedObject.ToString().Split(' ')[1]);


            //DeleteSituation?.Invoke(this, args);
        }
示例#9
0
        private void _tagger_RemoveTag(object sender, TaggerEventArgs args)
        {
            SituationIndex.RemoveMessageFromSituation(args.Tag, args.Id, args.messages[0]);
            MessageContainer.Messages[args.messages[0]].Situations.Remove(args.Tag);


            if (SituationIndex.Index[args.Tag][args.Id].Count == 0)
            {
                DeleteOrEditTag(args, true);
            }
        }
示例#10
0
        private void DeleteOrEditTag(TaggerEventArgs args, bool type)
        {
            foreach (var id in SituationIndex.Index[args.Tag][args.Id])
            {
                MessageContainer.Messages[id].Situations.Remove(args.Tag);
            }

            if (type)
            {
                _tagger.UpdateSituationCount(SituationIndex.SituationCount());
            }
            else
            {
                var tag = args.AdditionalInfo["Change"].ToString();

                var count  = SituationIndex.TagsetCounter[tag];
                var count2 = SituationIndex.Index[tag].Count;
                var list   = SituationIndex.Index[args.Tag][args.Id];

                SituationIndex.TagsetCounter[tag]++;
                SituationIndex.AddSituationToIndex(list, count, tag);
                foreach (var id in list)
                {
                    MessageContainer.Messages[id].Situations.Add(tag, count);
                }
                _tagger.AddSituationIndexItem(tag + " " + count);
            }

            SituationIndex.RemoveSituationFromIndex(args.Id, args.Tag);
            SituationIndex.TagsetCounter[args.Tag]--;

            _tagger.DeleteSituationIndexItem(args.Tag + " " + args.Id.ToString());



            if (args.Id < SituationIndex.Index[args.Tag].Count + 1)
            {
                for (int i = args.Id + 1; i <= SituationIndex.Index[args.Tag].Count; i++)
                {
                    var list = SituationIndex.Index[args.Tag][i];
                    foreach (var id in list)
                    {
                        MessageContainer.Messages[id].Situations[args.Tag]--;
                    }

                    SituationIndex.RemoveSituationFromIndex(i, args.Tag);
                    SituationIndex.AddSituationToIndex(list, i - 1, args.Tag);

                    _tagger.DeleteSituationIndexItem(args.Tag + " " + i.ToString());
                    _tagger.AddSituationIndexItem(args.Tag + " " + (i - 1).ToString());
                }
            }
        }
示例#11
0
            private void OnEventSourceChanged(object?sender, TaggerEventArgs _)
            {
                lock (_gate)
                {
                    _cachedTags       = null;
                    _cachedTaggedSpan = null;
                }

                // Note: we explicitly do *not* call into TagsChanged here.  This type exists only for the copy/paste
                // scenario, and in the case the editor always calls into us for the span in question, ignoring
                // TagsChanged, as per DPugh:
                //
                //    For rich text copy, we always call the buffer classifier to get the classifications of the copied
                //    text. It ignores any tags changed events.
                //
                // It's important that we do not call TagsChanged here as the only thing we could do is notify that the
                // entire doc is changed, and that incurs a heavy cost for the editor reacting to that notification.
            }
示例#12
0
        private void _tagger_LoadTagset(object sender, TaggerEventArgs e)
        {
            _service.CheckTagset();
            if (_service.TagsetSet)
            {
                _service.ProjectTagset = File.ReadAllText(ProjectInfo.TagsetPath);
                string   line  = File.ReadAllText(ProjectInfo.TagCountsPath);
                string[] lines = line.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item in lines)
                {
                    var temp = item.Split(' ');
                    SituationIndex.TagsetCounter.Add(temp[0], int.Parse(temp[1]));
                }

                _tagger.DisplayTagset(TagsetIndex.Index[_service.ProjectTagset]);
                _main.SetTagsetLabel(_service.ProjectTagset);
                _tagger.DisplayTagsetColors(TagsetIndex.ColorIndex[_service.ProjectTagset]);
            }
        }
        protected override void RecalculateTagsOnChanged(TaggerEventArgs e)
        {
            if (e.Kind == PredefinedChangedEventKinds.CaretPositionChanged)
            {
                var caret = GetCaretPoint();

                if (caret.HasValue)
                {
                    // If it changed position and we're still in a tag, there's nothing more to do
                    var currentTags = GetTagIntervalTreeForBuffer(caret.Value.Snapshot.TextBuffer);
                    if (currentTags != null && currentTags.GetIntersectingSpans(new SnapshotSpan(caret.Value, 0)).Any())
                    {
                        return;
                    }
                }
            }

            base.RecalculateTagsOnChanged(e);
        }
示例#14
0
        protected override void RecalculateTagsOnChanged(TaggerEventArgs e)
        {
            var cancellationToken = this.WorkQueue.CancellationToken;

            VoidLastSolutionVersionIfCaretChanged(e);

            RegisterNotification(() =>
            {
                this.WorkQueue.AssertIsForeground();

                var caret = GetCaretPoint();
                if (!caret.HasValue)
                {
                    ClearTags(cancellationToken);
                    return;
                }

                // called because of caret change
                if (e.Kind == PredefinedChangedEventKinds.CaretPositionChanged)
                {
                    var currentTags = GetTagIntervalTreeForBuffer(caret.Value.Snapshot.TextBuffer);
                    if (currentTags != null && currentTags.GetIntersectingSpans(new SnapshotSpan(caret.Value, 0)).Any())
                    {
                        // we are already inside of a tag. nothing to do.
                        return;
                    }
                }

                var spansToTag = TryGetSpansAndDocumentsToTag(e.Kind);
                if (spansToTag != null)
                {
                    // we will eagarly remove tags except for semantic change case.
                    // in semantic change case, we don't actually know whether it will affect highlight we currently
                    // have, so we will wait until we get new tags before removing them.
                    if (e.Kind != PredefinedChangedEventKinds.SemanticsChanged)
                    {
                        ClearTags(spansToTag, cancellationToken);
                    }

                    base.RecalculateTagsOnChanged(e);
                }
            }, delay: TaggerConstants.NearImmediateDelay, cancellationToken: cancellationToken);
        }
        private void OnChanged(object sender, TaggerEventArgs e)
        {
            using (var token = this.Listener.BeginAsyncOperation("OnChanged"))
            {
                // First, cancel any previous requests (either still queued, or started).  We no longer
                // want to continue it if new changes have come in.
                this.WorkQueue.CancelCurrentWork();

                // We don't currently have a request issued to re-compute our tags. Issue it for some
                // time in the future

                // If we had a text buffer change, we might be able to do something smarter with the
                // tags
                if (e.TextChangeEventArgs != null)
                {
                    UpdateTagsForTextChange(e.TextChangeEventArgs);
                    AccumulateTextChanges(e.TextChangeEventArgs);
                }

                RecalculateTagsOnChanged(e);
            }
        }
示例#16
0
 /// <summary>
 /// Called by derived types to enqueue tags re-calculation request
 /// </summary>
 protected virtual void RecalculateTagsOnChanged(TaggerEventArgs e)
 {
     RegisterNotification(RecomputeTagsForeground, e.Delay.ComputeTimeDelay(this.SubjectBuffer), this.WorkQueue.CancellationToken);
 }
示例#17
0
 private void _tagger_EditSituation(object sender, TaggerEventArgs e)
 {
     DeleteOrEditTag(e, false);
 }
示例#18
0
 private void _tagger_DeleteSituation(object sender, TaggerEventArgs args)
 {
     DeleteOrEditTag(args, true);
 }
示例#19
0
 private void _tagger_MergeSituations(object sender, TaggerEventArgs args)
 {
     throw new NotImplementedException();
 }