public static void disableMessage(string msg, string filename, ErrorListProvider errorListProvider) { AsmDudeToolsStatic.Output(string.Format("WARNING: " + msg)); for (int i = 0; i < errorListProvider.Tasks.Count; ++i) { Task t = errorListProvider.Tasks[i]; if (t.Text.Equals(msg)) { return; } } ErrorTask errorTask = new ErrorTask(); errorTask.SubcategoryIndex = (int)AsmErrorEnum.OTHER; errorTask.Text = msg; errorTask.ErrorCategory = TaskErrorCategory.Message; errorTask.Document = filename; errorTask.Navigate += AsmDudeToolsStatic.errorTaskNavigateHandler; errorListProvider.Tasks.Add(errorTask); errorListProvider.Show(); // do not use BringToFront since that will select the error window. errorListProvider.Refresh(); }
public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag { if (errorListProvider == null) { dte = (DTE)ServiceProvider.GetService(typeof(DTE)); events = dte.Events; docEvents = events.DocumentEvents; errorListProvider = new ErrorListProvider(ServiceProvider); docEvents.DocumentSaved += doc => { if (saveEvent != null) { saveEvent.Invoke(doc.FullName); } }; } var document = (ITextDocument)buffer.Properties[typeof(ITextDocument)]; if (!filesStartedFor.Contains(document.FilePath)) { IVsUIHierarchy hierarchy; uint itemId; IVsWindowFrame frame; if (VsShellUtilities.IsDocumentOpen(ServiceProvider, document.FilePath, Guid.Empty, out hierarchy, out itemId, out frame)) { var tv = VsShellUtilities.GetTextView(frame); IOleCommandTarget nextCommandTarget; var cmdHandler = new CommandHandler(tv); tv.AddCommandFilter(cmdHandler, out nextCommandTarget); cmdHandler.NextCommandTarget = nextCommandTarget; } filesStartedFor.Add(document.FilePath); Action <string> handler = doc => { var lastMod = new FileInfo(doc).LastWriteTime; if (lastDiagnosticSignature != lastMod) { lastDiagnosticSignature = lastMod; errorListProvider.Tasks.Clear(); errorListProvider.Refresh(); aggregator.Clear(); if (MyControl.CurrentInstance != null) { MyControl.CurrentInstance.RestartInstance(doc); } } var errors = Diagnostics.GetErrors(buffer, document); foreach (var error in errors) { bool skip = aggregator.Any(entry => entry.Line == error.Line && entry.Column == error.Column && entry.FileName == error.FileName && entry.Message == error.Message ); if (skip) { continue; } var errorTask = new ErrorTask { ErrorCategory = error.Severity, Category = TaskCategory.BuildCompile, Text = error.Message, Document = error.FileName, Line = error.Line, Column = error.Column, }; errorTask.Navigate += (sender, args) => { errorTask.Line++; errorListProvider.Navigate(errorTask, new Guid("{7651A701-06E5-11D1-8EBD-00A0C90F26EA}") /* EnvDTE.Constants.vsViewKindCode */); errorTask.Line--; }; errorListProvider.Tasks.Add(errorTask); aggregator.Add(error); } errorListProvider.Refresh(); errorListProvider.Show(); }; saveEvent += handler; saveEvent.Invoke(document.FilePath); } return(new ErrorTagger() as ITagger <T>); }