private async void UpdateTags()
        {
            var document      = _workspace.CurrentDocument;
            var semanticModel = await document.GetSemanticModelAsync();

            var codeIssues = semanticModel.GetIssues();

            using (CreateBatch())
            {
                Clear();

                foreach (var codeIssue in codeIssues)
                {
                    var classificationType = codeIssue.Kind == CodeIssueKind.Error
                        ? ClassificationTypes.CompilerError
                        : codeIssue.Kind == CodeIssueKind.Warning
                            ? ClassificationTypes.Warning
                            : null;

                    if (classificationType == null)
                    {
                        continue;
                    }

                    var snapshotRange = document.Text.ToSnapshotRange(codeIssue.Span);
                    var tag           = new SquiggleTag(classificationType, new DirectContentProvider(codeIssue.Description));
                    var tagRange      = new TagVersionRange <ISquiggleTag>(snapshotRange, TextRangeTrackingModes.Default, tag);
                    Add(tagRange);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Occurs when a menu item is clicked.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs"/> that contains data related to this event.</param>
        private void OnRemoveNote(object sender, RoutedEventArgs e)
        {
            MenuItem item = (MenuItem)sender;

            // Get the tag range
            TagSnapshotRange <IntraTextNoteTag> tagRange = (TagSnapshotRange <IntraTextNoteTag>)item.Tag;

            // Get the tagger from the code document
            ICodeDocument document = tagRange.SnapshotRange.Snapshot.Document as ICodeDocument;

            if (document != null)
            {
                IntraTextNoteTagger tagger = null;
                if (document.Properties.TryGetValue(typeof(IntraTextNoteTagger), out tagger))
                {
                    // Try and find the tag version range that contains the tag
                    TagVersionRange <IIntraTextSpacerTag> tagVersionRange = tagger[tagRange.Tag];
                    if (tagVersionRange != null)
                    {
                        // Remove the tag version range from the tagger
                        tagger.Remove(tagVersionRange);
                    }
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>BreakpointIndicatorTagContentProvider</c> class.
        /// </summary>
        /// <param name="tagRange">The tag range.</param>
        public BreakpointIndicatorTagContentProvider(TagVersionRange <BreakpointIndicatorTag> tagRange)
        {
            if (tagRange == null)
            {
                throw new ArgumentNullException("tagRange");
            }

            // Initialize
            this.tagRange = tagRange;
        }
        protected async void UpdateTags()
        {
            var versionAndDiagnostics = await GetDiagnosticsAync();

            var text        = versionAndDiagnostics.Item1;
            var diagnostics = versionAndDiagnostics.Item2;

            using (CreateBatch())
            {
                Clear();

                foreach (var diagnostic in diagnostics)
                {
                    var snapshotRange = text.ToSnapshotRange(diagnostic.Span);
                    var tag           = new SquiggleTag(_classificationType, new DirectContentProvider(diagnostic.Message));
                    var tagRange      = new TagVersionRange <ISquiggleTag>(snapshotRange, TextRangeTrackingModes.Default, tag);
                    Add(tagRange);
                }
            }
        }
 public BreakpointIndicatorTagContentProvider(TagVersionRange<BreakpointIndicatorTag> tagRange)
 {
     if (tagRange == null)
         throw new ArgumentNullException("tagRange");
     this.tagRange = tagRange;
 }