private static void AddTask(Message message, TaskErrorCategory category, string docName) { if (ErrorListProvider == null) { return; } var error = new ErrorTask { Category = TaskCategory.CodeSense, ErrorCategory = category, Text = message.From.MessageCodeToString(message.Code) + ((!string.IsNullOrWhiteSpace(message.Text)) ? "\"" + message.Text + "\"" : string.Empty) + ((message.AssociatedException != null) ? message.AssociatedException.ToMessageWithType() : string.Empty), Column = message.Position.ColNumber - 1, Line = message.Position.LineNumber - 1, Document = docName }; if (message.Token != null) { error.Column = message.Token.StartPosition.ColNumber - 1; error.Line = message.Token.StartPosition.LineNumber - 1; } if (docName.IsNotNullOrEmpty()) { error.Navigate += NavigateDocument; } ErrorListProvider.Tasks.Add(error); ErrorListProvider.Show(); }
public override void WriteLine(string s) { var errorCategory = TaskErrorCategory.Error; foreach (var regex in new[] { _errorRegex, _warningRegex }) { if (regex != null) { var m = regex.Match(s); if (m.Success) { int line, column; int.TryParse(m.Groups[LineGroupKey].ToString(), out line); int.TryParse(m.Groups[ColumnGroupKey].ToString(), out column); string document = m.Groups[FileNameGroupKey].ToString(); var task = new ErrorTask { Document = document, HierarchyItem = _hierarchy, Line = line - 1, Column = column - 1, ErrorCategory = errorCategory, Text = m.Groups[MessageGroupKey].ToString() }; task.Navigate += OnNavigate; _errorListProvider.Tasks.Add(task); } } errorCategory = TaskErrorCategory.Warning; } }
public void Write( TaskCategory category, TaskErrorCategory errorCategory, string context, //used as an indicator when removing string text, string document, int line, int column) { ErrorTask task = new ErrorTask(); task.Text = text; task.ErrorCategory = errorCategory; //The task list does +1 before showing this numbers task.Line = line - 1; task.Column = column - 1; task.Document = document; task.Category = category; if (!string.IsNullOrEmpty(document)) { //attach to the navigate event task.Navigate += NavigateDocument; } //add it to the errorlistprovider errorListProvider.Tasks.Add(task); errorListProvider.BringToFront(); }
private void ReportQueuedTasks() { // NOTE: This may run on a background thread! // We need to output this on the main thread. We must use BeginInvoke because the main thread may not be pumping events yet. BeginInvokeWithErrorMessage(this.serviceProvider, this.dispatcher, () => { this.taskProvider.SuspendRefresh(); try { Func <ErrorTask> taskFunc; while (this.taskQueue.TryDequeue(out taskFunc)) { // Create the error task ErrorTask task = taskFunc(); // Log the task this.taskProvider.Tasks.Add(task); } } finally { this.taskProvider.ResumeRefresh(); } }); }
public void Write( TaskCategory category, TaskErrorCategory errorCategory, string text, string document, int line, int column) { _errorsSinceSuspend++; ErrorTask task = new ErrorTask(); task.Text = text; task.ErrorCategory = errorCategory; //The task list does +1 before showing this numbers task.Line = line - 1; task.Column = column - 1; task.Document = document; task.Category = category; if (!string.IsNullOrEmpty(document)) { //attach to the navigate event task.Navigate += NavigateDocument; } _errorProvider.Tasks.Add(task); }
/// <summary> /// Collect errors /// </summary> protected void DisplayAssemblyErrors() { HostPackage.ErrorList.Clear(); if (Output.ErrorCount == 0) { return; } GetCodeItem(out var hierarchy, out _); foreach (var error in Output.Errors) { var errorTask = new ErrorTask { Category = TaskCategory.User, ErrorCategory = TaskErrorCategory.Error, HierarchyItem = hierarchy, Document = error.Filename ?? ItemPath, Line = error.Line - 1, Column = error.Column, Text = error.ErrorCode == null ? error.Message : $"{error.ErrorCode}: {error.Message}", CanDelete = true }; errorTask.Navigate += ErrorTaskOnNavigate; HostPackage.ErrorList.AddErrorTask(errorTask); } HostPackage.ApplicationObject.ExecuteCommand("View.ErrorList"); }
private void AddTask(ITextSnapshot snapshot, ErrorListProvider errorListProvider, CompilerMessage msg) { var startPos = msg.Location.Span.StartPos; if (startPos > snapshot.Length) { return; } var line = snapshot.GetLineFromPosition(startPos); var col = startPos - line.Start.Position; var text = VsUtils.ToText(msg.Text); var task = new ErrorTask() { Text = text, Category = TaskCategory.CodeSense, ErrorCategory = VsUtils.ConvertMessageType(msg.Type), Priority = TaskPriority.High, HierarchyItem = Hierarchy, Line = line.LineNumber, Column = col, Document = FullPath, }; task.Navigate += Task_Navigate; errorListProvider.Tasks.Add(task); foreach (var nested in msg.NestedMessages) { AddTask(snapshot, errorListProvider, nested); } }
public static void AddError(Package package, string errorText) { var ivsSolution = (IVsSolution)Package.GetGlobalService(typeof(IVsSolution)); var errorListProvider = new ErrorListProvider(package); var errorCategory = TaskErrorCategory.Error; IVsHierarchy hierarchyItem; var proj = GetActiveProject(); var projectUniqueName = proj.FileName; var firstFileInProject = GetSelectedItemPaths(EditProjectPackage.DTE).FirstOrDefault(); ivsSolution.GetProjectOfUniqueName(projectUniqueName, out hierarchyItem); var newError = new ErrorTask() { ErrorCategory = errorCategory, Category = TaskCategory.BuildCompile, Text = errorText, Document = firstFileInProject, Line = 1, Column = 1, HierarchyItem = hierarchyItem }; newError.Navigate += (sender, e) => { //there are two Bugs in the errorListProvider.Navigate method: // Line number needs adjusting // Column is not shown newError.Line++; errorListProvider.Navigate(newError, new Guid(EnvDTE.Constants.vsViewKindCode)); newError.Line--; }; errorListProvider.Tasks.Clear(); // clear previously created errorListProvider.Tasks.Add(newError); // add item errorListProvider.Show(); // make sure it is visible }
internal static void Add(TsLintTag tag) { var error = new ErrorTask() { ErrorCategory = tag.ErrorType == PredefinedErrorTypeNames.SyntaxError ? TaskErrorCategory.Error : TaskErrorCategory.Warning, Document = tag.DocumentName, Line = tag.Line, Column = tag.Column, Text = tag.ToolTipContent.ToString(), }; error.Navigate += (s, e) => { var task = new Task() { Document = error.Document, Line = error.Line + 1, Column = error.Column + 1 }; ErrorListHelper._provider.Navigate(task, new Guid()); }; ErrorListHelper._provider.Tasks.Add(error); }
public void AddErrors(IEnumerable <TaskErrorModel> aErrors) { UIUpdater.Invoke(() => { SuspendRefresh(); foreach (TaskErrorModel error in aErrors) { ErrorTask errorTask = new ErrorTask { ErrorCategory = error.Category, Document = error.FilePath, Text = error.Description, Line = error.Line - 1, Column = error.Column, Category = TaskCategory.BuildCompile, Priority = TaskPriority.High, HierarchyItem = error.HierarchyItem }; errorTask.Navigate += ErrorTaskNavigate; Tasks.Add(errorTask); } BringToFront(); ResumeRefresh(); }); }
// This has to live in the compiler, not in the error tagger, because we // don't want to update the list multiple times when we get to having more // than one file in a Swix project opened. Also, having it here allows for // multiple sets to be handled concurrently, which we need since we // *don't* have Swix projects yet! private void UpdateErrorList() { SourceFileCompiler.Instance.ErrorListProvider.Tasks.Clear(); foreach (SourceFileSet sourceFileSet in this.sourceFileSets) { foreach (CompilerMessageEventArgs message in sourceFileSet.Messages) { ErrorTask task = new ErrorTask(); task.Category = TaskCategoryFromCompilerMessage(message.Message); task.Document = message.FileName; task.Line = message.LineNumber - 1; task.Column = message.LinePosition - 1; task.ErrorCategory = TaskErrorCategoryFromCompilerMessage(message.Message); task.Text = message.Message.Message; if (!string.IsNullOrWhiteSpace(message.FileName)) { ////CompilerMessageEventArgs messageCurried = message; task.Navigate += Task_Navigate; } SourceFileCompiler.Instance.ErrorListProvider.Tasks.Add(task); } } }
public static void AddHierarchyItem(this ErrorTask task) { IVsHierarchy hierarchyItem = null; IVsSolution solution = EditorExtensionsPackage.GetGlobalService <IVsSolution>(typeof(SVsSolution)); Project project = ProjectHelpers.GetActiveProject(); if (solution != null && project != null) { int flag = -1; try { flag = solution.GetProjectOfUniqueName(project.FullName, out hierarchyItem); } catch (COMException ex) { if ((uint)ex.ErrorCode != DISP_E_MEMBERNOTFOUND) { throw; } } if (0 == flag) { task.HierarchyItem = hierarchyItem; } } }
private void SetupServices() { var componentModel = GetService <SComponentModel, IComponentModel>(); var outputWindowService = componentModel.DefaultExportProvider.GetExportedValueOrDefault <IOutputWindowService>(); IOutputWindowPane gitHubPane = null; // Warn users if dependencies aren't installed. vsbaseWarningProvider = new ErrorListProvider(this); if (outputWindowService != null) { gitHubPane = outputWindowService.TryGetPane(OutputWriter.GitHubOutputWindowPaneName); } else { var task = new ErrorTask { Category = TaskCategory.Misc, ErrorCategory = TaskErrorCategory.Error, Text = "The required VSBase Services debugging support extension is not installed; output window messages will not be shown. Click here for more information." }; task.Navigate += HandleNavigateToVsBaseServicesExtension; vsbaseWarningProvider.Tasks.Add(task); vsbaseWarningProvider.Show(); } // This code is a bit of a hack to bridge MEF created components and Ninject managed components Factory.Rebind <IOutputWindowPane>().ToConstant(gitHubPane); Factory.Rebind <ICache>().ToConstant(componentModel.DefaultExportProvider.GetExportedValue <Cache>()); Factory.Rebind <IOptionsProvider>().ToConstant(this); }
private async void AddErrorTask_Usage_Undefined_Async(int lineNumber, string keyword, string message) { await System.Threading.Tasks.Task.Run(() => { try { string lineContent = this._sourceBuffer.CurrentSnapshot.GetLineFromLineNumber(lineNumber).GetText().ToUpper(); ErrorTask errorTask = new ErrorTask() { SubcategoryIndex = (int)AsmMessageEnum.USAGE_OF_UNDEFINED, Line = lineNumber, Column = Get_Keyword_Begin_End(lineContent, keyword), Text = "Semantic Warning: " + message, ErrorCategory = TaskErrorCategory.Warning, Document = AsmDudeToolsStatic.GetFileName(this._sourceBuffer) }; errorTask.Navigate += AsmDudeToolsStatic.Error_Task_Navigate_Handler; this._errorListProvider.Tasks.Add(errorTask); } catch (Exception e) { AsmDudeToolsStatic.Output_ERROR(string.Format("{0}:AddErrorTask_Usage_Undefined_Async; e={1}", ToString(), e.ToString())); } }); }
protected void QueueTaskEvent(BuildEventArgs errorEvent) { this.taskQueue.Enqueue(() => { ErrorTask task = new ErrorTask(); if (errorEvent is BuildErrorEventArgs) { BuildErrorEventArgs errorArgs = (BuildErrorEventArgs)errorEvent; task.Document = errorArgs.File; task.ErrorCategory = TaskErrorCategory.Error; task.Line = errorArgs.LineNumber - 1; // The task list does +1 before showing this number. task.Column = errorArgs.ColumnNumber; task.Priority = TaskPriority.High; } else if (errorEvent is BuildWarningEventArgs) { BuildWarningEventArgs warningArgs = (BuildWarningEventArgs)errorEvent; task.Document = warningArgs.File; task.ErrorCategory = TaskErrorCategory.Warning; task.Line = warningArgs.LineNumber - 1; // The task list does +1 before showing this number. task.Column = warningArgs.ColumnNumber; task.Priority = TaskPriority.Normal; } task.Text = errorEvent.Message; task.Category = TaskCategory.BuildCompile; task.HierarchyItem = hierarchy; return(task); }); // NOTE: Unlike output we dont want to interactively report the tasks. So we never queue // call ReportQueuedTasks here. We do this when the build finishes. }
///////////////////////////////////////////////////////////////////////////// // Overridden Package Implementation #region Package Members /// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString())); base.Initialize(); // Add our command handlers for menu (commands must exist in the .vsct file) var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null != mcs) { // Create the command for the menu item. var menuCommandID = new CommandID(GuidList.guidGitHubExtensionCmdSet, (int)PkgCmdIDList.cmdidNewIssue); var menuItem = new MenuCommand(MenuItemCallback, menuCommandID); mcs.AddCommand(menuItem); // Create the commands for the tool windows var issueListWndCommandID = new CommandID(GuidList.guidGitHubExtensionCmdSet, (int)PkgCmdIDList.cmdidIssues); var menuIssueListWin = new MenuCommand(ShowIssueListToolWindow, issueListWndCommandID); mcs.AddCommand(menuIssueListWin); var issueWndCommandID = new CommandID(GuidList.guidGitHubExtensionCmdSet, (int)PkgCmdIDList.cmdidIssueWindow); var menuIssueWin = new MenuCommand(ShowIssueToolWindow, issueWndCommandID); mcs.AddCommand(menuIssueWin); var tfsIssueListWndCommandID = new CommandID(GuidList.guidGitHubExtensionCmdSet, (int)PkgCmdIDList.cmdidTfsIssues); var menuTfsIssueListWin = new MenuCommand(ShowTfsIssueListToolWindow, tfsIssueListWndCommandID); mcs.AddCommand(menuTfsIssueListWin); //var tfsIssueWndCommandID = new CommandID(GuidList.guidGitHubExtensionCmdSet, (int)PkgCmdIDList.cmdidTfsIssueWindow); //var menuTfsIssueWin = new MenuCommand(ShowTfsIssueToolWindow, tfsIssueWndCommandID); //mcs.AddCommand(menuTfsIssueWin); } IComponentModel componentModel = (IComponentModel)GetService(typeof(SComponentModel)); IOutputWindowService outputWindowService = componentModel.DefaultExportProvider.GetExportedValueOrDefault <IOutputWindowService>(); IOutputWindowPane gitHubPane = null; // Warn users if dependencies aren't installed. vsbaseWarningProvider = new ErrorListProvider(this); if (outputWindowService != null) { gitHubPane = outputWindowService.TryGetPane(View.OutputWriter.GitHubOutputWindowPaneName); } else { ErrorTask task = new ErrorTask { Category = TaskCategory.Misc, ErrorCategory = TaskErrorCategory.Error, Text = "The required VSBase Services debugging support extension is not installed; output window messages will not be shown. Click here for more information." }; task.Navigate += HandleNavigateToVsBaseServicesExtension; vsbaseWarningProvider.Tasks.Add(task); vsbaseWarningProvider.Show(); } // This code is a bit of a hack to bridge MEF created components and Ninject managed components Factory.Rebind <IOutputWindowPane>().ToConstant(gitHubPane); Factory.Rebind <ICache>().ToConstant(componentModel.DefaultExportProvider.GetExportedValue <Cache>()); }
/// <summary> /// Removes the file's messages, if any /// </summary> void ClearMessage() { if (message != null) { messageList.Tasks.Remove(message); } message = null; }
public void LogError(Exception ex) { ErrorTask task = new ErrorTask(ex); task.ErrorCategory = TaskErrorCategory.Error; task.Category = TaskCategory.Misc; m_errorListPrivider.Tasks.Add(task); }
/// <summary> /// Removes the file's messages, if any /// </summary> private void ClearMessage() { if (_message != null) { _messageList.Tasks.Remove(_message); } _message = null; }
internal SettingsManager(IWpfTextView view, ITextDocument document, ErrorListProvider messageList) { _view = view; _messageList = messageList; _message = null; LoadSettings(document.FilePath); }
public void Hide(Action <ErrorTask> remover) { if (task != null) { remover(task); } task = null; }
// adds the mappings between errors in the generated parser-file and their corresponding position in the grammar file (semantic actions). private void OnBuildDone(vsBuildScope Scope, vsBuildAction Action) { DTE2 dte = (DTE2)GetService(typeof(DTE)); ErrorItems errors = dte.ToolWindows.ErrorList.ErrorItems; Hashtable mapCache = new Hashtable(); bool grammarErrorFound = false; for (uint i = 1; i <= errors.Count; i++) { ErrorItem error = errors.Item(i); string fn = Path.GetFileName(error.FileName); string dir = Path.GetDirectoryName(error.FileName); if (fn.ToLower() == "parser.cs") { string atgmap = Path.Combine(dir, "parser.atgmap"); Mapping map = null; if (mapCache.ContainsKey(atgmap)) { map = (Mapping)mapCache[atgmap]; } else { if (File.Exists(atgmap)) { map = new Mapping(); map.Read(atgmap); mapCache[atgmap] = map; } } if (map != null) { int line, column; if (map.Get(error.Line - 1, error.Column - 1, out line, out column)) { ErrorTask task = new ErrorTask(); task.ErrorCategory = TaskErrorCategory.Error; task.Priority = TaskPriority.Normal; task.Text = error.Description; task.Column = column; task.Line = line; task.Document = map.Grammar; task.Navigate += NavigateDocument; errorListProvider.Tasks.Add(task); grammarErrorFound = true; } } } } if (grammarErrorFound) { errorListProvider.Show(); } }
public void Navigate(object sender, EventArgs e) { ErrorTask task = (ErrorTask)sender; if (MessageBox.Show(Question, "Web Essentials", MessageBoxButtons.YesNo) == DialogResult.Yes) { var process = Process.Start("http://www.seomoves.org/blog/build/html5-microdata-2711/"); } }
private void ErrorTaskNavigate(object sender, EventArgs e) { ErrorTask objErrorTask = (ErrorTask)sender; objErrorTask.Line += 1; bool bResult = Navigate(objErrorTask, new Guid(EnvDTE.Constants.vsViewKindCode)); objErrorTask.Line -= 1; }
public void UpdateErrorList(ITextSnapshot snapshot) { lock (this) { if (_errorProvider != null && !m_disposed) { _errorProvider.SuspendRefresh(); // reduce flickering _errorProvider.Tasks.Clear(); foreach (var err in AllErrors) { var lineNum = 0; var columnNum = 0; if (err.Span != null) { var span = err.Span.GetSpan(snapshot); lineNum = snapshot.GetLineNumberFromPosition(span.Start.Position); var line = snapshot.GetLineFromPosition(span.Start.Position); columnNum = span.Start - line.Start; } else { lineNum = err.Line; columnNum = err.Column; } ErrorTask task = new ErrorTask() { Category = TaskCategory.BuildCompile, ErrorCategory = CategoryConversion(err.Category), Text = err.Message, Line = lineNum, Column = columnNum }; if (err.Filename != null) { task.Document = err.Filename; } else if (_document != null) { task.Document = _document.FilePath; } if (err.Category != ErrorCategory.ProcessError && err.Category != ErrorCategory.InternalError) { task.Navigate += new EventHandler(NavigateHandler); } _errorProvider.Tasks.Add(task); } _errorProvider.ResumeRefresh(); } } var chng = TagsChanged; if (chng != null) { chng(this, new SnapshotSpanEventArgs(new SnapshotSpan(snapshot, 0, snapshot.Length))); } }
public void RemoveMessage(string key) { if (_errorCache.ContainsKey(key)) { ErrorTask error = _errorCache[key]; _errorlist.Tasks.Remove(error); _errorCache.Remove(key); } }
/// <summary> /// Called when the user double-clicks on an entry in the Error List /// </summary> private void OnTaskNavigate(object source, EventArgs e) { ErrorTask task = source as ErrorTask; if (task != null) { OpenDocumentAndNavigateTo(task.Document, task.Line, task.Column); } }
public void LogError(string message) { ErrorTask task = new ErrorTask(); task.ErrorCategory = TaskErrorCategory.Error; task.Text = message; task.Category = TaskCategory.Misc; m_errorListPrivider.Tasks.Add(task); }
private void task_Navigate(object sender, EventArgs e) { ErrorTask task = sender as ErrorTask; _provider.Navigate(task, new Guid(Constants.vsViewKindPrimary)); var doc = (TextDocument)WebEssentialsPackage.DTE.ActiveDocument.Object("textdocument"); doc.Selection.MoveToDisplayColumn(task.Line + 1, task.Column + 1); }
private TagSpan <ErrorTag> CreateError(ITextSnapshotLine line, ClassificationSpan cspan, string message) { ErrorTask task = CreateErrorTask(line, cspan, message); _errorlist.Tasks.Add(task); SnapshotSpan CheckTextSpan = new SnapshotSpan(cspan.Span.Snapshot, new Span(cspan.Span.Start, cspan.Span.Length)); return(new TagSpan <ErrorTag>(CheckTextSpan, new ErrorTag(message, message))); }