public void SetValues(int errors, AdornmentData adornmentData)
 {
     if (errors != 0) return;
     SetValue(_classes, adornmentData.ClassText, adornmentData.ClassTextTooltip);
     SetValue(_methods, adornmentData.MethodText, adornmentData.MethodTextTooltip);
     SetValue(_properties, adornmentData.PropertyText);
     SetValue(_fields, adornmentData.FieldText);
 }
        private async void UpdateAdornment(bool highlight)
        {
            var errors = 0;

            foreach (var item in GetErrorListItems())
            {
                string file;
                item.Document(out file);
                if (string.IsNullOrEmpty(file) || file != _document.FilePath)
                    continue;

                var errorItem = item as IVsErrorItem;
                uint errorCategory = 0;
                if (errorItem != null) errorItem.GetCategory(out errorCategory);
                if (errorCategory == (uint)__VSERRORCATEGORY.EC_ERROR) errors++;
            }

            if (errors > 0)
            {
                _text.SetErrors(errors.Pluralize("error"));
                return;
            }

            var analysisData = _document.FilePath.AnalyzeFile();
            AdornmentData adornmentData = null;
            var overallCount = analysisData.Interfaces != null && analysisData.Interfaces.Count > 0 ? 2 : 1;
            if (_displayMode == 0)
            {
                _log.LogEntry((uint)__ACTIVITYLOG_ENTRYTYPE.ALE_INFORMATION, "RoslynCodeAnalysisExtension",
                              "Initial adornment data displayed");
                adornmentData = new AdornmentData
                {
                    ClassText = analysisData.Classes.Count.Pluralize("class"),
                    MethodText = analysisData.Classes.SelectMany(a => a.MethodInfos).Count().Pluralize("method"),
                    PropertyText = analysisData.Classes.SelectMany(a => a.PropertyInfos).Count().Pluralize("property"),
                    FieldText = analysisData.Classes.SelectMany(a => a.FieldInfos).Count().Pluralize("field")
                };
                _timer.Interval = 15000;
            }
            else if (overallCount > 1 && _displayMode == 1 && analysisData.Interfaces != null)
            {
                adornmentData = new AdornmentData
                {
                    ClassText = analysisData.Interfaces.Count.Pluralize("interface"),
                    MethodText = analysisData.Interfaces.SelectMany(a => a.MethodInfos).Count().Pluralize("method"),
                    PropertyText = analysisData.Interfaces.SelectMany(a => a.PropertyInfos).Count().Pluralize("property"),
                    FieldText = string.Empty
                };
            }
            else
            {
                var requiredClass = analysisData.Classes[(_displayMode - overallCount)];
                adornmentData = new AdornmentData
                {
                    ClassText = requiredClass.Name,
                    MethodText = requiredClass.MethodInfos.Count.Pluralize("method"),
                    PropertyText = requiredClass.PropertyInfos.Count.Pluralize("property"),
                    FieldText = requiredClass.FieldInfos.Count.Pluralize("field"),
                    MethodTextTooltip = requiredClass.MethodInfos != null && requiredClass.MethodInfos.Count > 0 && requiredClass.MethodInfos.Any(m => m.LineCount > Constants.Method.IdealLineCount)
                                                ? string.Format("{0} method has {1} lines, consider refactoring!",
                                                        requiredClass.MethodInfos.First(m => m.LineCount > Constants.Method.IdealLineCount).Name,
                                                        requiredClass.MethodInfos.First(m => m.LineCount > Constants.Method.IdealLineCount).LineCount)
                                                : string.Empty,
                    ClassTextTooltip = requiredClass.MethodInfos != null && requiredClass.MethodInfos.Count > Constants.Class.IdealMethodCount 
                                                ? string.Format("{0} has {1} methods, consider splitting this class up", requiredClass.Name, requiredClass.MethodInfos.Count) 
                                                : string.Empty
                };
            }

            _text.SetValues(errors, adornmentData);
            var maxCount = overallCount + analysisData.Classes.Count;
            _displayMode = _displayMode.Cycle(maxCount);

            if (highlight)
                await _text.Highlight();
        }