/// <summary> /// Handles the Help event of the task control. /// </summary> /// <param name="sender">The Task to parse for a guidance link.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> void task_Help(object sender, EventArgs e) { Microsoft.VisualStudio.Shell.Task task = sender as Microsoft.VisualStudio.Shell.Task; if (task == null) { throw new ArgumentException("sender"); } string url = null; Match urlMatches = Regex.Match(task.Text, @"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)"); if (urlMatches.Success) { url = urlMatches.Captures[0].Value; } if (url != null) { Window win = dte.Windows.Item(EnvDTE.Constants.vsWindowKindCommandWindow); CommandWindow comwin = (CommandWindow)win.Object; comwin.SendInput("nav \"" + url + "\"", true); } }
public void AddErrorToErrorListWindow(string error) { ErrorListProvider errorProvider = new ErrorListProvider(BabePackage.Current); Microsoft.VisualStudio.Shell.Task newError = new Microsoft.VisualStudio.Shell.Task(); newError.Category = TaskCategory.BuildCompile; newError.Text = error; errorProvider.Tasks.Add(newError); }
/// <summary> /// Resets error (if any) associated with current project reference /// </summary> public void CleanProjectReferenceErrorState() { Microsoft.VisualStudio.FSharp.LanguageService.UIThread.DoOnUIThread(() => { if (projectRefError != null) { ProjectMgr.ProjectErrorsTaskListProvider.Tasks.Remove(projectRefError); projectRefError = null; } } ); }
private void QuickFixHandler(object sender, EventArgs e) { Microsoft.VisualStudio.Shell.Task task = sender as Microsoft.VisualStudio.Shell.Task; if (task == null) { throw new ArgumentException("sender parm cannot be null"); } if (String.IsNullOrEmpty(task.Document)) { return; } }
public void ReportUnusedPrivileges(string p, int line, int column, string filename) { var warnTask = new Microsoft.VisualStudio.Shell.Task(); warnTask.CanDelete = true; warnTask.Category = TaskCategory.BuildCompile; warnTask.Document = filename; warnTask.Line = line; warnTask.Column = column; warnTask.Navigate += new EventHandler(NavigateHandler); warnTask.Text = p; warnTask.Priority = TaskPriority.Normal; taskProvider.Tasks.Add(warnTask); }
private void NavigateTo(object sender, EventArgs arguments) { Microsoft.VisualStudio.Shell.Task task = sender as Microsoft.VisualStudio.Shell.Task; if (task == null) throw new ArgumentException("sender"); // Get the doc data for the task's document if (String.IsNullOrEmpty(task.Document)) return; IVsUIShellOpenDocument openDoc = serviceProvider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) return; IVsWindowFrame frame; IOleServiceProvider sp; IVsUIHierarchy hier; uint itemid; Guid logicalView = VSConstants.LOGVIEWID_Code; if (Microsoft.VisualStudio.ErrorHandler.Failed(openDoc.OpenDocumentViaProject(task.Document, ref logicalView, out sp, out hier, out itemid, out frame)) || frame == null) return; object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); // Get the VsTextBuffer VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; Debug.Assert(buffer != null, "IVsTextLines does not implement IVsTextBuffer"); if (buffer == null) return; } } // Finally, perform the navigation. IVsTextManager mgr = serviceProvider.GetService(typeof(VsTextManagerClass)) as IVsTextManager; if (mgr == null) return; mgr.NavigateToLineAndColumn(buffer, ref logicalView, task.Line, task.Column, task.Line, task.Column); }
public static void AddOrOverrideError(string key, Microsoft.VisualStudio.Shell.Task task) { if (ListOfErrors.ContainsKey(key)) { ListOfErrors[key] = task; } else { ListOfErrors.Add(key, task); } if (task is ErrorTask) { WriteVisualStudioErrorList(task as ErrorTask); } }
/// <summary> /// Collect tasks from comments /// </summary> protected void HandleAssemblyTasks() { Package.TaskList.Clear(); foreach (var todo in Output.Tasks) { var task = new VsTask() { Category = TaskCategory.Comments, CanDelete = false, Document = todo.Filename, Line = todo.Line - 1, Column = 1, Text = todo.Description, }; task.Navigate += TodoTaskOnNavigate; Package.TaskList.AddTask(task); } }
/// <summary> /// Creates new error with given text and associates it with current project reference. /// Old error is removed /// </summary> /// <param name="text"></param> private void SetError(string text) { Microsoft.VisualStudio.FSharp.LanguageService.UIThread.DoOnUIThread(() => { // delete existing error if exists CleanProjectReferenceErrorState(); projectRefError = new ErrorTask { ErrorCategory = TaskErrorCategory.Warning, HierarchyItem = ProjectMgr.InteropSafeIVsHierarchy, Text = text }; ProjectMgr.ProjectErrorsTaskListProvider.Tasks.Add(projectRefError); } ); }
private void NavigateTo(object sender, EventArgs arguments) { try { Microsoft.VisualStudio.Shell.Task task = sender as Microsoft.VisualStudio.Shell.Task; if (task == null) { throw new ArgumentException("sender"); } // Get the doc data for the task's document if (String.IsNullOrEmpty(task.Document)) { return; } IVsUIShellOpenDocument openDoc = serviceProvider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) { return; } IVsWindowFrame frame; IOleServiceProvider sp; IVsUIHierarchy hier; uint itemid; Guid logicalView = VSConstants.LOGVIEWID_Code; if (Microsoft.VisualStudio.ErrorHandler.Failed(openDoc.OpenDocumentViaProject(task.Document, ref logicalView, out sp, out hier, out itemid, out frame)) || frame == null) { return; } object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); // Get the VsTextBuffer VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; Debug.Assert(buffer != null, "IVsTextLines does not implement IVsTextBuffer"); if (buffer == null) { return; } } } // Finally, perform the navigation. IVsTextManager mgr = serviceProvider.GetService(typeof(VsTextManagerClass)) as IVsTextManager; if (mgr == null) { return; } // We should use the full span information if we've been given a DocumentTask bool isDocumentTask = task is DocumentTask; int endLine = isDocumentTask ? ((DocumentTask)task).Span.iEndLine : task.Line; int endColumn = isDocumentTask ? ((DocumentTask)task).Span.iEndIndex : task.Column; mgr.NavigateToLineAndColumn(buffer, ref logicalView, task.Line, task.Column, endLine, endColumn); } catch (Exception e) { System.Diagnostics.Debug.Assert(false, "Error thrown from NavigateTo. " + e.ToString()); } }
private void PostTask(string iDocument, int iLine, string iMessage, TaskPriority iPriority) { Task task = new Task(); task.Document = iDocument; task.Line = iLine; task.Text = iMessage; task.Priority = iPriority; task.Navigate += new EventHandler(this.NavigateTo); mErrorListProvider.Tasks.Add(task); }
/// <summary> /// Navigates to the source code associated with the specified task /// </summary> /// <param name="task">Error task</param> public void Navigate(Microsoft.VisualStudio.Shell.Task task) { _taskProvider.Navigate(task, VSConstants.LOGVIEWID_Primary); }
public void AddErrorToErrorListWindow(string error) { ErrorListProvider errorProvider = new ErrorListProvider(BabePackage.Current); Microsoft.VisualStudio.Shell.Task newError = new Microsoft.VisualStudio.Shell.Task(); newError.Category = TaskCategory.BuildCompile; newError.Text = error; errorProvider.Tasks.Add(newError); }
private void NavigateHandler(object sender, EventArgs arguments) { Microsoft.VisualStudio.Shell.Task task = sender as Microsoft.VisualStudio.Shell.Task; if (task == null) { throw new ArgumentException("sender parm cannot be null"); } if (String.IsNullOrEmpty(task.Document)) { return; } IVsUIShellOpenDocument openDoc = GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) { return; } IVsWindowFrame frame; Microsoft.VisualStudio.OLE.Interop.IServiceProvider serviceProvider; IVsUIHierarchy hierarchy; uint itemId; Guid logicalView = VSConstants.LOGVIEWID_Code; if (ErrorHandler.Failed(openDoc.OpenDocumentViaProject( task.Document, ref logicalView, out serviceProvider, out hierarchy, out itemId, out frame)) || frame == null) { return; } object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; ErrorHandler.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; if (buffer == null) { return; } } } IVsTextManager mgr = GetService(typeof(VsTextManagerClass)) as IVsTextManager; if (mgr == null) { return; } mgr.NavigateToLineAndColumn(buffer, ref logicalView, task.Line, task.Column, task.Line, task.Column); }
/// <summary> /// Adds the specified error to the provider /// </summary> /// <param name="task"></param> public void AddTask(Microsoft.VisualStudio.Shell.Task task) { _taskProvider.Tasks.Add(task); }
/// <include file='doc\TaskProvider.uex' path='docs/doc[@for="TaskCollection.Contains"]/*' /> public bool Contains(Task task) { return list.Contains(task); }
/// <include file='doc\TaskProvider.uex' path='docs/doc[@for="TaskCollection.Insert"]/*' /> public void Insert(int index, Task task) { if (task == null) { throw new ArgumentNullException("task"); } list.Insert(index, task); task.Owner = owner; owner.TasksChanged(); }
public static async void Error_Task_Navigate_Handler(object sender, EventArgs arguments) { if (!ThreadHelper.CheckAccess()) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); } Microsoft.VisualStudio.Shell.Task task = sender as Microsoft.VisualStudio.Shell.Task; if (task == null) { throw new ArgumentException("sender parm cannot be null"); } if (string.IsNullOrEmpty(task.Document)) { Output_INFO("AsmDudeToolsStatic:Error_Task_Navigate_Handler: task.Document is empty"); return; } Output_INFO("AsmDudeToolsStatic: Error_Task_Navigate_Handler: task.Document=" + task.Document); IVsUIShellOpenDocument openDoc = Package.GetGlobalService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) { Output_INFO("AsmDudeToolsStatic:Error_Task_Navigate_Handler: openDoc is null"); return; } Guid logicalView = VSConstants.LOGVIEWID_Code; int hr = openDoc.OpenDocumentViaProject(task.Document, ref logicalView, out Microsoft.VisualStudio.OLE.Interop.IServiceProvider serviceProvider, out IVsUIHierarchy hierarchy, out uint itemId, out IVsWindowFrame frame); if (ErrorHandler.Failed(hr) || (frame == null)) { Output_INFO("AsmDudeToolsStatic:Error_Task_Navigate_Handler: OpenDocumentViaProject failed"); return; } frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out object docData); VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { if (docData is IVsTextBufferProvider bufferProvider) { ErrorHandler.ThrowOnFailure(bufferProvider.GetTextBuffer(out IVsTextLines lines)); buffer = lines as VsTextBuffer; if (buffer == null) { Output_INFO("INFO: AsmDudeToolsStatic:Error_Task_Navigate_Handler: buffer is null"); return; } } } IVsTextManager mgr = Package.GetGlobalService(typeof(SVsTextManager)) as IVsTextManager; if (mgr == null) { Output_INFO("AsmDudeToolsStatic:Error_Task_Navigate_Handler: IVsTextManager is null"); return; } //Output("INFO: AsmDudeToolsStatic:errorTaskNavigateHandler: navigating to row="+task.Line); int iStartIndex = task.Column & 0xFFFF; int iEndIndex = (task.Column >> 16) & 0xFFFF; mgr.NavigateToLineAndColumn(buffer, ref logicalView, task.Line, iStartIndex, task.Line, iEndIndex); }
/// <include file='doc\TaskProvider.uex' path='docs/doc[@for="Navigate"]/*' /> /// <devdoc> /// Navigates the document in the given task to the given logical view. /// </devdoc> public bool Navigate(Task task, Guid logicalView) { if (task == null) { throw new ArgumentNullException("task"); } // Get the doc data for the task's document if (task.Document == null || task.Document.Length == 0) { return false; } IVsUIShellOpenDocument openDoc = GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDoc == null) { return false; } IVsWindowFrame frame; IOleServiceProvider sp; IVsUIHierarchy hier; uint itemid; Guid logView = logicalView; if (NativeMethods.Failed(openDoc.OpenDocumentViaProject(task.Document, ref logView, out sp, out hier, out itemid, out frame)) || frame == null) { return false; } object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; NativeMethods.ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; Debug.Assert(buffer != null, "IVsTextLines does not implement IVsTextBuffer"); if (buffer == null) { return false; } } } // Finally, perform the navigation. IVsTextManager mgr = GetService(typeof(VsTextManagerClass)) as IVsTextManager; if (mgr == null) { return false; } int line = task.Line; // Buffer is zero based if (line > 0) line--; mgr.NavigateToLineAndColumn(buffer, ref logicalView, line, 0, line, 0); return true; }
private void NavigateToHandler(object sender, System.EventArgs args) { Microsoft.VisualStudio.Shell.Task task = sender as Microsoft.VisualStudio.Shell.Task; if (task == null) { throw new System.ArgumentException("sender"); } // Open the document. if (string.IsNullOrEmpty(task.Document)) { return; } IVsUIShellOpenDocument openDocument = m_serviceProvider.GetService(typeof(IVsUIShellOpenDocument)) as IVsUIShellOpenDocument; if (openDocument == null) { return; } IVsWindowFrame frame; IOleServiceProvider serviceProvider; IVsUIHierarchy hierarchy; uint itemId; System.Guid logicalView = VSConstants.LOGVIEWID_Code; if (Failed(openDocument.OpenDocumentViaProject(task.Document, ref logicalView, out serviceProvider, out hierarchy, out itemId, out frame)) || frame == null) { return; } // Get the text buffer. object docData; frame.GetProperty((int)__VSFPROPID.VSFPROPID_DocData, out docData); VsTextBuffer buffer = docData as VsTextBuffer; if (buffer == null) { IVsTextBufferProvider bufferProvider = docData as IVsTextBufferProvider; if (bufferProvider != null) { IVsTextLines lines; ThrowOnFailure(bufferProvider.GetTextBuffer(out lines)); buffer = lines as VsTextBuffer; if (buffer == null) { return; } } } // Perform the navigation. IVsTextManager manager = m_serviceProvider.GetService(typeof(VsTextManagerClass)) as IVsTextManager; if (manager == null) { return; } manager.NavigateToLineAndColumn(buffer, ref logicalView, task.Line, task.Column, task.Line, task.Column); }
public static void Add(Microsoft.VisualStudio.Shell.Task task) { errorListProvider.ReadLocked(elp => elp.Tasks.Add(task)); }
/// <summary> /// Creates new error with given text and associates it with current project reference. /// Old error is removed /// </summary> /// <param name="text"></param> private void SetError(string text) { Microsoft.VisualStudio.FSharp.LanguageService.UIThread.DoOnUIThread(() => { // delete existing error if exists CleanProjectReferenceErrorState(); projectRefError = new ErrorTask { ErrorCategory = TaskErrorCategory.Warning, HierarchyItem = ProjectMgr.InteropSafeIVsHierarchy, Text = text }; ProjectMgr.ProjectErrorsTaskListProvider.Tasks.Add(projectRefError); } ); }
/// <summary> /// Resets error (if any) associated with current project reference /// </summary> public void CleanProjectReferenceErrorState() { Microsoft.VisualStudio.FSharp.LanguageService.UIThread.DoOnUIThread(() => { if (projectRefError != null) { ProjectMgr.ProjectErrorsTaskListProvider.Tasks.Remove(projectRefError); projectRefError = null; } } ); }
private void AddStepToTaskList(FeatureResult featureResult, ScenarioResult scenarioResult, StepResult stepResult) { try { TaskProvider taskProvider = GetTaskListProvider(); Task task = new Task(); task.Category = TaskCategory.User; task.Text = string.Format("The step \"{0}\" is pending in scenario \"{1}\" for the feature \"{2}\"", stepResult.Name, scenarioResult.Name, featureResult.Name); taskProvider.Tasks.Add(task); } catch (InvalidOperationException) { } }
/// <include file='doc\TaskProvider.uex' path='docs/doc[@for="TaskCollection.Add"]/*' /> public int Add(Task task) { if (task == null) { throw new ArgumentNullException("task"); } int index = list.Add(task); task.Owner = owner; owner.TasksChanged(); return index; }
/// <summary> /// Handles the navigation from the error list item to the document in the /// project /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// private void warning_Navigate(object sender, EventArgs e) { Task task = sender as Task; if (task == null) return; Task navigateToTask = new Task() { Document = task.Document, // The document navigation is 1 base, so we have to add the 1 we subtracted // for the error list control, which is 0 base. Line = task.Line + 1, // Weird that the error and warning window have inconsistent definitions // for what column offsets mean... Column = task.Column + 2 }; _ErrorListProvider.Navigate(navigateToTask, new Guid()); _EventBus.Document.Navigate(navigateToTask.Line, navigateToTask.Column); }
/// <include file='doc\TaskProvider.uex' path='docs/doc[@for="TaskCollection.IndexOf"]/*' /> public int IndexOf(Task task) { return list.IndexOf(task); }
public void Add(Microsoft.VisualStudio.Shell.Task t) { this.taskProvider.Tasks.Add(t); }
/// <include file='doc\TaskProvider.uex' path='docs/doc[@for="TaskCollection.Remove"]/*' /> public void Remove(Task task) { if (task == null) { throw new ArgumentNullException("task"); } list.Remove(task); task.Owner = null; owner.TasksChanged(); }
public static bool Contains(Microsoft.VisualStudio.Shell.Task shellTask) { return(errorListProvider.ReadLocked(elp => elp.Tasks.Contains(shellTask))); }