void ItemCodeJump(DebugViewTool sender, DebugViewData data, DbgViewCodeJumpStyle style) { bool found = false; DTE2 applicationObject = parent.DTE; if (applicationObject == null) { throw new ArgumentNullException(null, "Invalid VisualStudio IDE application object."); } // get the projects: int projectCount = applicationObject.Solution.Projects.Count; IList <Project> projects = new List <Project>(); for (int p = 1; p <= projectCount; p++) { projects.Add(applicationObject.Solution.Projects.Item(p)); } // search: if (style != DbgViewCodeJumpStyle.Automatic && style != DbgViewCodeJumpStyle.Autodetect) { found = SolutionHelper.Activate(projects, SolutionHelper.GetFinder(data.Message, style)); } else { IList <DbgViewCodeJumpStyle> list = new List <DbgViewCodeJumpStyle>(); list.Add(DbgViewCodeJumpStyle.Class_12); list.Add(DbgViewCodeJumpStyle.Class_23); list.Add(DbgViewCodeJumpStyle.Class_34); list.Add(DbgViewCodeJumpStyle.Class_45); list.Add(DbgViewCodeJumpStyle.Class_56); list.Add(DbgViewCodeJumpStyle.Class_1); list.Add(DbgViewCodeJumpStyle.Class_2); list.Add(DbgViewCodeJumpStyle.Class_3); list.Add(DbgViewCodeJumpStyle.Class_4); list.Add(DbgViewCodeJumpStyle.Class_5); // try guess the style: foreach (DbgViewCodeJumpStyle e in list) { if (SolutionHelper.Activate(projects, SolutionHelper.GetFinder(data.Message, e))) { if (style == DbgViewCodeJumpStyle.Autodetect) { control.SetStyle(e); } found = true; break; } } } if (!found) { MessageBox.Show("Specific element doesn't contain reference to the code inside current solution.", DebugViewTool.DialogTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Creates the proper finder based on the message and code-jump style. /// </summary> public static ClassFinder GetFinder(string message, DbgViewCodeJumpStyle style) { return(GetFinder(message, style, true)); }
/// <summary> /// Creates the proper finder based on the message and code-jump style. /// </summary> public static ClassFinder GetFinder(string message, DbgViewCodeJumpStyle style, bool autoExecute) { string className = null; string methodName = null; string[] args; if (string.IsNullOrEmpty(message)) { return(null); } // generate array of 6 elements... args = message.Split(DebugViewData.SplitChars, 6); // obtain the class/method name: switch (style) { case DbgViewCodeJumpStyle.Class_1: if (args.Length > 0) { className = args[0]; } break; case DbgViewCodeJumpStyle.Class_2: if (args.Length > 1) { className = args[1]; } break; case DbgViewCodeJumpStyle.Class_3: if (args.Length > 2) { className = args[2]; } break; case DbgViewCodeJumpStyle.Class_4: if (args.Length > 3) { className = args[3]; } break; case DbgViewCodeJumpStyle.Class_5: if (args.Length > 4) { className = args[4]; } break; case DbgViewCodeJumpStyle.Class_12: if (args.Length > 0) { className = args[0]; } if (args.Length > 1) { methodName = args[1]; } break; case DbgViewCodeJumpStyle.Class_23: if (args.Length > 1) { className = args[1]; } if (args.Length > 2) { methodName = args[2]; } break; case DbgViewCodeJumpStyle.Class_34: if (args.Length > 2) { className = args[2]; } if (args.Length > 3) { methodName = args[3]; } break; case DbgViewCodeJumpStyle.Class_45: if (args.Length > 3) { className = args[3]; } if (args.Length > 4) { methodName = args[4]; } break; case DbgViewCodeJumpStyle.Class_56: if (args.Length > 4) { className = args[4]; } if (args.Length > 5) { methodName = args[5]; } break; default: return(null); } // extract C++ function name: if (!string.IsNullOrEmpty(className) && className.IndexOf("::") >= 0) { string[] items = className.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); className = items[0]; methodName = items.Length > 1 ? items[1] : null; } if (string.IsNullOrEmpty(className) && string.IsNullOrEmpty(methodName)) { return(null); } return(new ClassFinder(className, methodName, autoExecute)); }
public void SetStyle(DbgViewCodeJumpStyle newStyle) { toolStripCustomColumns.SelectedIndex = (int)newStyle + 1; }