/// <summary>
        /// The update coverage DataCache.
        /// </summary>
        /// <param name="elem">
        /// The elem.
        /// </param>
        /// <param name="coverageData">
        /// The coverage DataCache.
        /// </param>
        private void UpdateCoverageData(EditorData elem, SourceCoverage coverageData)
        {
            if (coverageData == null)
            {
                return;
            }

            var tempCoverageLine = new Dictionary <int, CoverageElement>();

            foreach (LineCoverage linemeasure in coverageData.LinesHits)
            {
                int line = linemeasure.Id - 1;

                tempCoverageLine.Add(line, linemeasure.Hits > 0 ? CoverageElement.LineCovered : CoverageElement.LineNotCovered);
            }

            foreach (BranchCoverage branchmeasure in coverageData.BranchHits)
            {
                int line = branchmeasure.Id - 1;

                if (tempCoverageLine.ContainsKey(line))
                {
                    if (branchmeasure.CoveredConditions == branchmeasure.TotalConditions)
                    {
                        tempCoverageLine[line] = CoverageElement.LineCovered;
                    }
                    else if (branchmeasure.CoveredConditions == 0)
                    {
                        tempCoverageLine[line] = CoverageElement.LineNotCovered;
                    }
                    else
                    {
                        tempCoverageLine[line] = CoverageElement.LinePartialCovered;
                    }
                }
                else
                {
                    if (branchmeasure.CoveredConditions == branchmeasure.TotalConditions)
                    {
                        tempCoverageLine.Add(line, CoverageElement.LineCovered);
                    }
                    else if (branchmeasure.CoveredConditions == 0)
                    {
                        tempCoverageLine.Add(line, CoverageElement.LineNotCovered);
                    }
                    else
                    {
                        tempCoverageLine.Add(line, CoverageElement.LinePartialCovered);
                    }
                }
            }

            elem.CoverageData = tempCoverageLine;
        }
        /// <summary>
        /// The update coverage DataCache.
        /// </summary>
        /// <param name="resource">
        /// The resource.
        /// </param>
        /// <param name="coverageData">
        /// The coverage DataCache.
        /// </param>
        /// <param name="issues">
        /// The issues.
        /// </param>
        /// <param name="serverSource">
        /// The server source.
        /// </param>
        public void UpdateResourceData(Resource resource, SourceCoverage coverageData, List <Issue> issues, string serverSource)
        {
            if (!DataCache.ContainsKey(resource.Key))
            {
                DataCache.Add(resource.Key, new EditorData(resource));
            }

            EditorData elem = DataCache[resource.Key];

            elem.ServerSource = serverSource;
            this.UpdateCoverageData(elem, coverageData);
            this.UpdateIssuesData(elem, issues);
        }
        /// <summary>
        /// The update issues.
        /// </summary>
        /// <param name="issues">
        /// The issues.
        /// </param>
        internal void UpdateIssues(List <Issue> issues)
        {
            this.ClearData();

            if (issues == null)
            {
                return;
            }

            foreach (Issue issue in issues)
            {
                if (!DataCache.ContainsKey(issue.Component))
                {
                    var resource = new Resource();
                    resource.Key = issue.Component;
                    DataCache.Add(issue.Component, new EditorData(new Resource()));
                }

                EditorData elem = DataCache[issue.Component];
                elem.Issues.Add(issue);
            }
        }
        /// <summary>
        /// The get issues for resource.
        /// </summary>
        /// <param name="resource">
        /// The resource.
        /// </param>
        /// <param name="currentSource">
        /// The current source.
        /// </param>
        /// <returns>
        /// The
        ///     <see>
        ///         <cref>List</cref>
        ///     </see>
        ///     .
        /// </returns>
        public List <Issue> GetIssuesForResource(Resource resource, string currentSource)
        {
            var issues = new List <Issue>();

            if (!DataCache.ContainsKey(resource.Key))
            {
                return(issues);
            }

            EditorData element = DataCache[resource.Key];

            if (element.ServerSource == null)
            {
                return(element.Issues);
            }

            try
            {
                ArrayList diffReport = VsSonarUtils.GetSourceDiffFromStrings(element.ServerSource, currentSource, DiffEngineLevel.FastImperfect);

                foreach (Issue issue in element.Issues)
                {
                    int line = VsSonarUtils.EstimateWhereSonarLineIsUsingSourceDifference(issue.Line, diffReport);

                    if (line >= 0)
                    {
                        issues.Add(issue);
                    }
                }

                return(issues);
            }
            catch (Exception)
            {
                return(element.Issues);
            }
        }
 /// <summary>
 /// The update issues DataCache.
 /// </summary>
 /// <param name="elem">
 /// The elem.
 /// </param>
 /// <param name="issues">
 /// The issues.
 /// </param>
 private void UpdateIssuesData(EditorData elem, IEnumerable<Issue> issues)
 {
     elem.Issues.Clear();
     if (issues != null)
     {
         elem.Issues.AddRange(issues);
     }
 }
        /// <summary>
        /// The update coverage DataCache.
        /// </summary>
        /// <param name="elem">
        /// The elem.
        /// </param>
        /// <param name="coverageData">
        /// The coverage DataCache.
        /// </param>
        private void UpdateCoverageData(EditorData elem, SourceCoverage coverageData)
        {
            if (coverageData == null)
            {
                return;
            }

            var tempCoverageLine = new Dictionary<int, CoverageElement>();

            foreach (LineCoverage linemeasure in coverageData.LinesHits)
            {
                int line = linemeasure.Id - 1;

                tempCoverageLine.Add(line, linemeasure.Hits > 0 ? CoverageElement.LineCovered : CoverageElement.LineNotCovered);
            }

            foreach (BranchCoverage branchmeasure in coverageData.BranchHits)
            {
                int line = branchmeasure.Id - 1;

                if (tempCoverageLine.ContainsKey(line))
                {
                    if (branchmeasure.CoveredConditions == branchmeasure.TotalConditions)
                    {
                        tempCoverageLine[line] = CoverageElement.LineCovered;
                    }
                    else if (branchmeasure.CoveredConditions == 0)
                    {
                        tempCoverageLine[line] = CoverageElement.LineNotCovered;
                    }
                    else
                    {
                        tempCoverageLine[line] = CoverageElement.LinePartialCovered;
                    }
                }
                else
                {
                    if (branchmeasure.CoveredConditions == branchmeasure.TotalConditions)
                    {
                        tempCoverageLine.Add(line, CoverageElement.LineCovered);
                    }
                    else if (branchmeasure.CoveredConditions == 0)
                    {
                        tempCoverageLine.Add(line, CoverageElement.LineNotCovered);
                    }
                    else
                    {
                        tempCoverageLine.Add(line, CoverageElement.LinePartialCovered);
                    }
                }
            }

            elem.CoverageData = tempCoverageLine;
        }