Пример #1
0
        private void UpdateIssues(IEnumerable <IssueMarker> issueMarkers)
        {
            var oldSnapshot = this.Factory.CurrentSnapshot;
            var newSnapshot = new IssuesSnapshot(this.ProjectItem.ContainingProject.Name, this.FilePath, oldSnapshot.VersionNumber + 1, issueMarkers);

            SnapToNewSnapshot(newSnapshot);
        }
        public IssueTagger(IIssueTracker issueTracker)
        {
            this.IssueTracker = issueTracker;
            this.issues       = issueTracker.LastIssues;

            issueTracker.AddTagger(this);
        }
Пример #3
0
        private SnapshotSpan?CalculateAffectedSpan(IssuesSnapshot oldIssues, IssuesSnapshot newIssues)
        {
            // Calculate the whole span affected by the all of the issues, old and new
            int start = int.MaxValue;
            int end   = int.MinValue;

            if (oldIssues != null && oldIssues.Count > 0)
            {
                start = oldIssues.IssueMarkers.Select(i => i.Span.Start.TranslateTo(currentSnapshot, PointTrackingMode.Negative)).Min();
                end   = oldIssues.IssueMarkers.Select(i => i.Span.End.TranslateTo(currentSnapshot, PointTrackingMode.Positive)).Max();
            }

            if (newIssues != null && newIssues.Count > 0)
            {
                start = Math.Min(start, newIssues.IssueMarkers.Select(i => i.Span.Start.Position).Min());
                end   = Math.Max(end, newIssues.IssueMarkers.Select(i => i.Span.End.Position).Max());
            }

            if (start < end)
            {
                return(new SnapshotSpan(currentSnapshot, Span.FromBounds(start, end)));
            }

            return(null);
        }
        private void UpdateMarkers(ITextSnapshot currentSnapshot, IssuesSnapshot snapshot)
        {
            var oldSnapshot = this.Snapshot;

            var handler = this.TagsChanged;

            if (handler == null)
            {
                return;
            }

            // Raise a single tags changed event over the entire affected span.
            int start = int.MaxValue;
            int end   = int.MinValue;

            if (oldSnapshot != null && oldSnapshot.Count > 0)
            {
                start = oldSnapshot.IssueMarkers.Select(i => i.Span.Start.TranslateTo(currentSnapshot, PointTrackingMode.Negative)).Min();
                end   = oldSnapshot.IssueMarkers.Select(i => i.Span.End.TranslateTo(currentSnapshot, PointTrackingMode.Positive)).Max();
            }

            if (snapshot.Count > 0)
            {
                start = Math.Min(start, snapshot.IssueMarkers.Select(i => i.Span.Start.Position).Min());
                end   = Math.Max(end, snapshot.IssueMarkers.Select(i => i.Span.End.Position).Max());
            }

            if (start < end)
            {
                handler(this, new SnapshotSpanEventArgs(new SnapshotSpan(currentSnapshot, Span.FromBounds(start, end))));
            }
        }
        internal void UpdateIssues(IEnumerable <Issue> issues)
        {
            var oldSnapshot = this.Factory.CurrentSnapshot;
            var newMarkers  = issues.Where(IsValidIssueTextRange).Select(CreateIssueMarker);
            var newSnapshot = new IssuesSnapshot(this.ProjectItem.ContainingProject.Name, this.FilePath, oldSnapshot.VersionNumber + 1, newMarkers);

            SnapToNewSnapshot(newSnapshot);
        }
        private void SnapToNewSnapshot(IssuesSnapshot snapshot)
        {
            this.Factory.UpdateMarkers(snapshot);

            provider.UpdateAllSinks();

            UpdateMarkers(currentSnapshot, snapshot);

            this.Snapshot = snapshot;
        }
        public void UpdateMarkers(IssuesSnapshot newIssues, SnapshotSpan?affectedSpan)
        {
            this.issues = newIssues;

            var handler = this.TagsChanged;

            if (handler != null && affectedSpan.HasValue)
            {
                handler(this, new SnapshotSpanEventArgs(affectedSpan.Value));
            }
        }
        internal /* for testing */ void HandleNewIssues(IEnumerable <IAnalysisIssueVisualization> issues)
        {
            var filteredIssues = RemoveSuppressedIssues(issues);

            // The text buffer might have changed since the analysis was triggered, so translate
            // all issues to the current snapshot.
            // See bug #1487: https://github.com/SonarSource/sonarlint-visualstudio/issues/1487
            var translatedIssues = TranslateSpans(filteredIssues, textBuffer.CurrentSnapshot);

            var newSnapshot = new IssuesSnapshot(GetProjectName(), GetProjectGuid(), FilePath, translatedIssues);

            SnapToNewSnapshot(newSnapshot);
        }
Пример #9
0
        private void SnapToNewSnapshot(IssuesSnapshot newIssues)
        {
            // Tell our factory to snap to a new snapshot.
            this.Factory.UpdateSnapshot(newIssues);

            // Tell the provider to mark all the sinks dirty (so, as a side-effect, they will start an update pass that will get the new snapshot
            // from the factory).
            Provider.UpdateAllSinks();

            // Work out which part of the document has been affected by the changes, and tell
            // the taggers about the changes
            SnapshotSpan?affectedSpan = CalculateAffectedSpan(LastIssues, newIssues);

            foreach (var tagger in activeTaggers)
            {
                tagger.UpdateMarkers(newIssues, affectedSpan);
            }

            this.LastIssues = newIssues;
        }
 internal void UpdateMarkers(IssuesSnapshot snapshot)
 {
     this.CurrentSnapshot = snapshot;
 }
 public SnapshotFactory(IssuesSnapshot snapshot)
 {
     this.CurrentSnapshot = snapshot;
 }
 public void UpdateSnapshot(IssuesSnapshot snapshot)
 {
     this.CurrentSnapshot = snapshot;
 }