internal void UpdateErrorList(ITextSnapshot snapshot)
        {
            if (this.errorListProvider == null)
            {
                return;
            }

            try
            {
                this.errorListProvider.SuspendRefresh();
                this.ClearErrors();

                SourceText sourceText = this.singletons.SourceTextCache.Get(snapshot);
                var        errors     = this.singletons.FeatureContainer.DiagnosticsProvider.GetDiagnostics(sourceText);
                foreach (var error in errors)
                {
                    SnapshotSpan errorSnapshotSpan = EditorUtilities.CreateSnapshotSpan(snapshot, error.Span.endIndex, error.Span.Length);

                    string filePath = snapshot.TextBuffer.GetFilePath();
                    Debug.Assert(filePath != null, "We should always be able to get the moniker for a file opened in the editor (even if it hasn't been saved)");

                    if (!string.IsNullOrEmpty(filePath))
                    {
                        ErrorListItem errorListItem = this.CreateErrorListItem(errorSnapshotSpan, error, filePath);

                        this.errorListProvider.Tasks.Add(errorListItem);
                    }
                }
            }
            finally
            {
                this.errorListProvider.ResumeRefresh();
            }
        }
        private void ClearErrors()
        {
            foreach (object task in this.errorListProvider.Tasks)
            {
                ErrorListItem errorTask = task as ErrorListItem;

                if (errorTask != null)
                {
                    errorTask.Navigate -= this.OnErrorListItemNavigate;
                }
            }

            this.errorListProvider.Tasks.Clear();
        }
        private ErrorListItem CreateErrorListItem(SnapshotSpan span, Error error, string filePath)
        {
            ITextSnapshotLine line = span.Snapshot.GetLineFromPosition(span.Start);

            var errorListItem = new ErrorListItem(span);

            errorListItem.Category      = TaskCategory.All;
            errorListItem.Priority      = TaskPriority.Normal;
            errorListItem.Document      = filePath;
            errorListItem.ErrorCategory = TaskErrorCategory.Error;
            errorListItem.Text          = error.Message;
            errorListItem.Line          = line.LineNumber;
            errorListItem.Column        = Math.Min(line.End, span.Start) - line.Start;

            errorListItem.Navigate += this.OnErrorListItemNavigate;

            return(errorListItem);
        }