From 122177828bb4ecd9c6e08e170ca8ad07c628c9ae Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 4 Oct 2008 13:27:11 +0000 Subject: [PATCH] Removed unused conditional breakpoint types and improved workflow of breakpoints. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3581 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Debugger.AddIn.addin | 27 ++++-- .../Project/Src/IsBreakpointCondition.cs | 89 ++++++++++++++++--- .../Src/Service/EditBreakpointScriptForm.cs | 6 +- .../Project/Src/Service/WindowsDebugger.cs | 32 +------ .../Services/Debugger/BreakpointBookmark.cs | 14 +-- .../TextEditor/Bookmarks/BookmarkConverter.cs | 2 +- 6 files changed, 116 insertions(+), 54 deletions(-) diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.addin b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.addin index ff34f78a4d..55a91682b3 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.addin +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.addin @@ -6,6 +6,7 @@ + @@ -38,12 +39,28 @@ type = "Separator"/> - - - + + + + + + + + + + + + + + + - - + + diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/IsBreakpointCondition.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/IsBreakpointCondition.cs index 8d7485a58b..f738c0798b 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/IsBreakpointCondition.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/IsBreakpointCondition.cs @@ -45,6 +45,84 @@ namespace Debugger.AddIn } } + public class IsActiveBreakpointCondition : IConditionEvaluator + { + public IsActiveBreakpointCondition() + { + } + + public bool IsValid(object caller, Condition condition) + { + if (WorkbenchSingleton.Workbench == null || WorkbenchSingleton.Workbench.ActiveWorkbenchWindow == null) + return false; + ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent as ITextEditorControlProvider; + if (provider == null) + return false; + if (string.IsNullOrEmpty(provider.TextEditorControl.FileName)) + return false; + + BreakpointBookmark point = null; + + foreach (BreakpointBookmark breakpoint in DebuggerService.Breakpoints) { + if ((breakpoint.FileName == provider.TextEditorControl.FileName) && + (breakpoint.LineNumber == provider.TextEditorControl.ActiveTextAreaControl.Caret.Line)) { + point = breakpoint; + break; + } + } + + if (point != null) { + return point.IsEnabled; + } + + return false; + } + } + + public class EnableBreakpointMenuCommand : AbstractMenuCommand + { + public override void Run() + { + ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent as ITextEditorControlProvider; + + BreakpointBookmark point = null; + + foreach (BreakpointBookmark breakpoint in DebuggerService.Breakpoints) { + if ((breakpoint.FileName == provider.TextEditorControl.FileName) && + (breakpoint.LineNumber == provider.TextEditorControl.ActiveTextAreaControl.Caret.Line)) { + point = breakpoint; + break; + } + } + + if (point != null) { + point.IsEnabled = true; + } + } + } + + public class DisableBreakpointMenuCommand : AbstractMenuCommand + { + public override void Run() + { + ITextEditorControlProvider provider = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent as ITextEditorControlProvider; + + BreakpointBookmark point = null; + + foreach (BreakpointBookmark breakpoint in DebuggerService.Breakpoints) { + if ((breakpoint.FileName == provider.TextEditorControl.FileName) && + (breakpoint.LineNumber == provider.TextEditorControl.ActiveTextAreaControl.Caret.Line)) { + point = breakpoint; + break; + } + } + + if (point != null) { + point.IsEnabled = false; + } + } + } + public class BreakpointChangeMenuBuilder : ISubmenuBuilder { public System.Windows.Forms.ToolStripItem[] BuildSubmenu(Codon codon, object owner) @@ -80,25 +158,16 @@ namespace Debugger.AddIn BreakpointBookmark bookmark = (BreakpointBookmark)item.Tag; switch (item.Name) { - case "Ask": - bookmark.Action = BreakpointAction.Ask; - break; case "Break": bookmark.Action = BreakpointAction.Break; break; - case "Continue": - bookmark.Action = BreakpointAction.Continue; - break; - case "Script": + case "Condition": EditBreakpointScriptForm form = new EditBreakpointScriptForm(bookmark); if (form.ShowDialog() == DialogResult.OK) { bookmark = form.Data; } break; - case "Terminate": - bookmark.Action = BreakpointAction.Terminate; - break; case "Trace": bookmark.Action = BreakpointAction.Trace; break; diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/EditBreakpointScriptForm.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/EditBreakpointScriptForm.cs index a1382118ca..8f2f68a2cb 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/EditBreakpointScriptForm.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/EditBreakpointScriptForm.cs @@ -35,9 +35,9 @@ namespace Debugger.AddIn.Service this.data = data; - this.data.Action = BreakpointAction.Script; + this.data.Action = BreakpointAction.Condition; - this.txtCode.Document.TextContent = data.Script; + this.txtCode.Document.TextContent = data.Condition; this.cmbLanguage.Items.AddRange(new string[] { "C#", "VBNET" }); this.cmbLanguage.SelectedIndex = (!string.IsNullOrEmpty(data.ScriptLanguage)) ? @@ -84,7 +84,7 @@ namespace Debugger.AddIn.Service { if (!this.CheckSyntax()) return; - this.data.Script = this.txtCode.Document.TextContent; + this.data.Condition = this.txtCode.Document.TextContent; this.DialogResult = DialogResult.OK; this.Close(); } diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs index 1ad6159f40..f0aebae549 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs @@ -523,41 +523,17 @@ namespace ICSharpCode.SharpDevelop.Services new EventHandler( delegate(object sender, BreakpointEventArgs e) { - LoggingService.Debug(bookmark.Action + " " + bookmark.ScriptLanguage + " " + bookmark.Script); + LoggingService.Debug(bookmark.Action + " " + bookmark.ScriptLanguage + " " + bookmark.Condition); switch (bookmark.Action) { - case BreakpointAction.Ask: - Bitmap icon = WinFormsResourceService.GetBitmap(false ? "Icons.32x32.Error" : "Icons.32x32.Warning"); - - DebuggerEventForm.Result result = - DebuggerEventForm.Show(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHit}"), - string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAt}"), bookmark.LineNumber, bookmark.FileName), icon, true); - - switch (result) { - case DebuggerEventForm.Result.Break: - break; - case DebuggerEventForm.Result.Continue: - this.debuggedProcess.AsyncContinue(); - break; - case DebuggerEventForm.Result.Terminate: - this.debuggedProcess.AsyncTerminate(); - break; - } - break; case BreakpointAction.Break: break; - case BreakpointAction.Continue: - this.debuggedProcess.AsyncContinue(); - break; - case BreakpointAction.Script: - if (Evaluate(bookmark.Script, bookmark.ScriptLanguage)) - DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAtBecause}") + "\n", bookmark.LineNumber + 1, bookmark.FileName, bookmark.Script)); + case BreakpointAction.Condition: + if (Evaluate(bookmark.Condition, bookmark.ScriptLanguage)) + DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAtBecause}") + "\n", bookmark.LineNumber + 1, bookmark.FileName, bookmark.Condition)); else this.debuggedProcess.AsyncContinue(); break; - case BreakpointAction.Terminate: - this.debuggedProcess.AsyncTerminate(); - break; case BreakpointAction.Trace: DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAt}") + "\n", bookmark.LineNumber + 1, bookmark.FileName)); break; diff --git a/src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs b/src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs index 3c4eaa2640..2825dbebc0 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs @@ -14,7 +14,7 @@ using ICSharpCode.SharpDevelop.Bookmarks; namespace ICSharpCode.SharpDevelop.Debugging { public enum BreakpointAction { - Ask, Break, Continue, Terminate, Trace, Script + Break, Trace, Condition } public class BreakpointBookmark : SDMarkerBookmark @@ -24,8 +24,8 @@ namespace ICSharpCode.SharpDevelop.Debugging static readonly Color defaultColor = Color.FromArgb(180, 38, 38); - BreakpointAction action = BreakpointAction.Ask; - string script; + BreakpointAction action = BreakpointAction.Break; + string condition; string scriptLanguage; public string ScriptLanguage { @@ -33,9 +33,9 @@ namespace ICSharpCode.SharpDevelop.Debugging set { scriptLanguage = value; } } - public string Script { - get { return script; } - set { script = value; } + public string Condition { + get { return condition; } + set { condition = value; } } public BreakpointAction Action { @@ -65,7 +65,7 @@ namespace ICSharpCode.SharpDevelop.Debugging { this.action = action; this.scriptLanguage = scriptLanguage; - this.script = script; + this.condition = script; } public override void Draw(IconBarMargin margin, Graphics g, Point p) diff --git a/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkConverter.cs b/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkConverter.cs index 129fa4c1f7..22ad7a5ce8 100644 --- a/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkConverter.cs +++ b/src/Main/Base/Project/Src/TextEditor/Bookmarks/BookmarkConverter.cs @@ -87,7 +87,7 @@ namespace ICSharpCode.SharpDevelop.Bookmarks b.Append('|'); b.Append(bbm.ScriptLanguage); b.Append('|'); - b.Append(bbm.Script); + b.Append(bbm.Condition); } return b.ToString(); } else {