/// <summary> /// The issues list changed. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void IssuesListChanged(object sender, EventArgs e) { try { var document = VsEvents.GetPropertyFromBuffer <ITextDocument>(this.SourceBuffer); Resource resource = SonarQubeViewModelFactory.SQViewModel.ResourceInEditor; if (resource == null || document == null) { return; } if (!document.FilePath.Replace('\\', '/').EndsWith(resource.Lname, StringComparison.OrdinalIgnoreCase)) { return; } this.sonarTags.Clear(); List <Issue> issuesInEditor = SonarQubeViewModelFactory.SQViewModel.GetIssuesInEditor( resource, this.SourceBuffer.CurrentSnapshot.GetText()); if (issuesInEditor == null || issuesInEditor.Count == 0) { this.RefreshTags(); return; } var alreadyAddLine = new Dictionary <int, string>(); foreach (Issue issue in issuesInEditor) { if (issue.Status == IssueStatus.CLOSED || issue.Status == IssueStatus.RESOLVED) { continue; } if (alreadyAddLine.ContainsKey(issue.Line)) { continue; } alreadyAddLine.Add(issue.Line, string.Empty); this.sonarTags.AddRange(this.GetSonarTagsInSpanForLine(issuesInEditor, issue.Line)); } this.RefreshTags(); } catch (Exception ex) { Debug.WriteLine("Failed To Update Issues: " + ex.Message + " : " + ex.StackTrace); } }
/// <summary> /// Sets the coverage data. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void CoverageDataChanged(object sender, EventArgs e) { try { SonarQubeViewModelFactory.SQViewModel.Logger.WriteMessage("Coverage Changed Event Correctly Triggered"); var document = VsEvents.GetPropertyFromBuffer <ITextDocument>(this.SourceBuffer); Resource resource = SonarQubeViewModelFactory.SQViewModel.ResourceInEditor; if (resource == null || document == null) { return; } if (!document.FilePath.Replace('\\', '/').EndsWith(resource.Lname, StringComparison.OrdinalIgnoreCase)) { return; } SonarQubeViewModelFactory.SQViewModel.Logger.WriteMessage("Getting Coverage"); Dictionary <int, CoverageElement> coverageLine = SonarQubeViewModelFactory.SQViewModel.GetCoverageInEditor(this.SourceBuffer.CurrentSnapshot.GetText()); SonarQubeViewModelFactory.SQViewModel.Logger.WriteMessage("Got Cov Measures: " + coverageLine.Count); this.coverageTags.Clear(); if (coverageLine.Count == 0) { this.RefreshTags(); return; } foreach (var hit in coverageLine) { this.coverageTags.AddRange(this.GetCoverageTagsInSpanForLine(coverageLine, hit.Key)); } this.RefreshTags(); } catch (Exception ex) { SonarQubeViewModelFactory.SQViewModel.Logger.WriteMessage("Failed To Update Issues: " + ex.Message + " : " + ex.StackTrace); } }