/// <summary> /// Navigate from a parsed stack frame to source code line. /// </summary> /// <param name="errorGroupItem">The error group item that will be shown in the source code tooltip.</param> /// <param name="stackFrame">The stack frame that contains the source file and source line number.</param> public static void ErrorFrameToSourceLine( ErrorGroupItem errorGroupItem, ErrorReporting.StackFrame stackFrame) { ThreadHelper.ThrowIfNotOnUIThread(); if (errorGroupItem == null || stackFrame == null || !stackFrame.IsWellParsed) { throw new ArgumentException("Invalid argument"); } ProjectSourceFile projectFile = null; SolutionHelper solution = SolutionHelper.CurrentSolution; if (solution != null) { var items = solution.FindMatchingSourceFile(stackFrame.SourceFile); if (items.Count > 1) { var index = PickFileDialog.PickFileWindow.PromptUser(items.Select(x => x.FullName)); if (index < 0) { return; } projectFile = items.ElementAt(index); } else { projectFile = items.FirstOrDefault(); } } if (projectFile == null) { SourceVersionUtils.FileItemNotFoundPrompt(stackFrame.SourceFile); return; } var window = ShellUtils.Default.Open(projectFile.FullName); if (window == null) { FailedToOpenFilePrompt(stackFrame.SourceFile); return; } ShowToolTip(errorGroupItem, stackFrame, window); }
/// <summary> /// Show the tooltip for an error group stack frame. /// </summary> /// <param name="errorGroupItem">The error group item that will be shown in the source code tooltip.</param> /// <param name="stackFrame">The stack frame that contains the source file and source line number.</param> /// <param name="window">The Visual Studio Document window that opens the source file.</param> public static void ShowToolTip( ErrorGroupItem errorGroupItem, ErrorReporting.StackFrame stackFrame, Window window) { GotoLine(window, (int)stackFrame.LineNumber); IVsTextView textView = GetIVsTextView(window.Document.FullName); var wpfView = GetWpfTextView(textView); if (wpfView == null) { return; } var control = new ErrorFrameTooltipControl(); control.DataContext = new ErrorFrameTooltipViewModel(errorGroupItem); ActiveTagData.SetCurrent( wpfView, stackFrame.LineNumber, control, ""); TryFindTagger(wpfView)?.ShowOrUpdateToolTip(); }