From 04d8d26fabbf022acf9e0113b2b78be2cfc06d14 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 2 Feb 2014 13:26:34 +0100 Subject: [PATCH] move most of the IDebugger DebuggerService infrastructure to Debugger.AddIn --- .../Interfaces/UnitTestDebuggerService.cs | 95 ++++- .../UnitTesting/NUnit/NUnitTestDebugger.cs | 2 +- .../TestRunner/TestDebuggerBase.cs | 10 +- .../Analysis/UnitTesting/UnitTesting.csproj | 3 +- .../AspNet.Mvc/Project/Src/WebBehavior.cs | 10 +- .../RunScriptingConsoleApplicationCommand.cs | 4 +- .../Breakpoints}/BreakpointBookmark.cs | 35 +- .../BreakpointBookmarkEventArgs.cs | 2 +- .../Breakpoints/BreakpointEditor.xaml | 7 + .../Breakpoints/BreakpointEditor.xaml.cs} | 24 +- .../Breakpoints}/CurrentLineBookmark.cs | 18 +- .../Debugger.AddIn/Debugger.AddIn.addin | 13 +- .../Debugger.AddIn/Debugger.AddIn.csproj | 8 + .../Debugger.AddIn/Pads/BreakPointsPad.cs | 3 +- .../Debugger.AddIn/Pads/ConsolePad.cs | 2 +- .../Service/AttachToProcessForm.cs | 2 +- .../Service/DebuggerCommands.cs | 9 +- .../EditBreakpointScriptWindow.xaml.cs | 1 + .../Debugger.AddIn/Service/WindowsDebugger.cs | 121 ++++--- .../ObjectGraphControl.xaml.cs | 3 +- .../GraphVisualizer/ObjectGraphWindow.xaml.cs | 3 +- .../AvalonEdit.AddIn/Src/IconBarMargin.cs | 2 +- .../Src/Options/HighlightingOptions.xaml.cs | 13 +- .../Project/Src/DesignerViewContent.cs | 4 +- .../Project/Debugging/BaseDebuggerService.cs | 214 ++++++++++++ .../Project/Debugging/IDebuggerService.cs | 326 ++++++++++++++++++ .../Project/Editor/Bookmarks/BookmarkBase.cs | 15 + .../Project/Editor/Bookmarks/BookmarkPad.cs | 2 +- .../Bookmarks/BookmarkPadToolbarCommands.cs | 10 +- .../Project/Editor/Bookmarks/SDBookmark.cs | 13 +- .../Base/Project/Editor/ToolTipService.cs | 2 +- .../Project/ICSharpCode.SharpDevelop.addin | 1 - .../Project/ICSharpCode.SharpDevelop.csproj | 10 +- src/Main/Base/Project/Services/SD.cs | 9 +- .../Project/Src/Commands/BuildCommands.cs | 4 +- .../Project/Src/Commands/DebugCommands.cs | 42 +-- .../DebuggerSupportsEvaluator.cs | 16 +- .../IsProcessRunningEvaluator.cs | 4 +- .../Behaviors/DefaultProjectBehavior.cs | 4 +- .../Src/Services/Debugger/DebuggerDoozer.cs | 129 ------- .../Src/Services/Debugger/DebuggerService.cs | 253 -------------- .../Src/Services/Debugger/DefaultDebugger.cs | 197 ----------- .../Src/Services/Debugger/IDebugger.cs | 122 ------- .../Src/Services/Tasks/ErrorPainter.cs | 10 +- .../SharpDevelop/Dom/ClassBrowser/Commands.cs | 8 +- 45 files changed, 879 insertions(+), 906 deletions(-) rename src/{Main/Base/Project/Src/Services/Debugger => AddIns/Debugger/Debugger.AddIn/Breakpoints}/BreakpointBookmark.cs (83%) rename src/{Main/Base/Project/Src/Services/Debugger => AddIns/Debugger/Debugger.AddIn/Breakpoints}/BreakpointBookmarkEventArgs.cs (97%) create mode 100644 src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointEditor.xaml rename src/AddIns/{Analysis/UnitTesting/Interfaces/IUnitTestDebuggerService.cs => Debugger/Debugger.AddIn/Breakpoints/BreakpointEditor.xaml.cs} (70%) rename src/{Main/Base/Project/Src/Services/Debugger => AddIns/Debugger/Debugger.AddIn/Breakpoints}/CurrentLineBookmark.cs (89%) create mode 100644 src/Main/Base/Project/Debugging/BaseDebuggerService.cs create mode 100644 src/Main/Base/Project/Debugging/IDebuggerService.cs delete mode 100644 src/Main/Base/Project/Src/Services/Debugger/DebuggerDoozer.cs delete mode 100644 src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs delete mode 100644 src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs delete mode 100644 src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs diff --git a/src/AddIns/Analysis/UnitTesting/Interfaces/UnitTestDebuggerService.cs b/src/AddIns/Analysis/UnitTesting/Interfaces/UnitTestDebuggerService.cs index 9dd6776b23..41fef01107 100644 --- a/src/AddIns/Analysis/UnitTesting/Interfaces/UnitTestDebuggerService.cs +++ b/src/AddIns/Analysis/UnitTesting/Interfaces/UnitTestDebuggerService.cs @@ -17,18 +17,101 @@ // DEALINGS IN THE SOFTWARE. using System; +using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Debugging; namespace ICSharpCode.UnitTesting { - public class UnitTestDebuggerService : IUnitTestDebuggerService + public class UnitTestDebuggerService : BaseDebuggerService { - public bool IsDebuggerLoaded { - get { return DebuggerService.IsDebuggerLoaded; } + public override bool CanDebug(ICSharpCode.SharpDevelop.Project.IProject project) + { + return SD.Debugger.CanDebug(project); } - - public IDebugger CurrentDebugger { - get { return DebuggerService.CurrentDebugger; } + public override bool Supports(DebuggerFeatures feature) + { + return SD.Debugger.Supports(feature); + } + public override void Start(System.Diagnostics.ProcessStartInfo processStartInfo) + { + SD.Debugger.Start(processStartInfo); + } + public override void StartWithoutDebugging(System.Diagnostics.ProcessStartInfo processStartInfo) + { + SD.Debugger.StartWithoutDebugging(processStartInfo); + } + public override void Stop() + { + SD.Debugger.Stop(); + } + public override void Break() + { + SD.Debugger.Break(); + } + public override void Continue() + { + SD.Debugger.Continue(); + } + public override void StepInto() + { + SD.Debugger.StepInto(); + } + public override void StepOver() + { + SD.Debugger.StepOver(); + } + public override void StepOut() + { + SD.Debugger.StepOut(); + } + public override void ShowAttachDialog() + { + SD.Debugger.ShowAttachDialog(); + } + public override void Attach(System.Diagnostics.Process process) + { + SD.Debugger.Attach(); + } + public override void Detach() + { + SD.Debugger.Detach(); + } + public override bool SetInstructionPointer(string filename, int line, int column, bool dryRun) + { + return SD.Debugger.SetInstructionPointer(filename, line, column, dryRun); + } + public override void HandleToolTipRequest(ICSharpCode.SharpDevelop.Editor.ToolTipRequestEventArgs e) + { + SD.Debugger.HandleToolTipRequest(e); + } + public override void ToggleBreakpointAt(ICSharpCode.SharpDevelop.Editor.ITextEditor editor, int lineNumber) + { + SD.Debugger.ToggleBreakpointAt(editor, lineNumber); + } + public override void RemoveCurrentLineMarker() + { + SD.Debugger.RemoveCurrentLineMarker(); + } + public override bool IsDebugging { + get { return SD.Debugger.IsDebugging; } + } + public override bool IsProcessRunning { + get { + return SD.Debugger.IsProcessRunning; + } + } + public override bool BreakAtBeginning { + get { + return SD.Debugger.BreakAtBeginning; + } + set { + SD.Debugger.BreakAtBeginning = value; + } + } + public override bool IsAttached { + get { + return SD.Debugger.IsAttached; + } } } } diff --git a/src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestDebugger.cs b/src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestDebugger.cs index 5b4a5bcec7..1b9c11801f 100644 --- a/src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestDebugger.cs +++ b/src/AddIns/Analysis/UnitTesting/NUnit/NUnitTestDebugger.cs @@ -38,7 +38,7 @@ namespace ICSharpCode.UnitTesting { } - public NUnitTestDebugger(IUnitTestDebuggerService debuggerService, + public NUnitTestDebugger(IDebuggerService debuggerService, IMessageService messageService, ITestResultsReader testResultsReader, UnitTestingOptions options) diff --git a/src/AddIns/Analysis/UnitTesting/TestRunner/TestDebuggerBase.cs b/src/AddIns/Analysis/UnitTesting/TestRunner/TestDebuggerBase.cs index cc7ab7eb6b..9e25bb849f 100644 --- a/src/AddIns/Analysis/UnitTesting/TestRunner/TestDebuggerBase.cs +++ b/src/AddIns/Analysis/UnitTesting/TestRunner/TestDebuggerBase.cs @@ -28,9 +28,8 @@ namespace ICSharpCode.UnitTesting { public abstract class TestDebuggerBase : TestRunnerBase { - IUnitTestDebuggerService debuggerService; IMessageService messageService; - IDebugger debugger; + IDebuggerService debugger; ITestResultsReader testResultsReader; public TestDebuggerBase() @@ -40,14 +39,13 @@ namespace ICSharpCode.UnitTesting { } - public TestDebuggerBase(IUnitTestDebuggerService debuggerService, + public TestDebuggerBase(IDebuggerService debuggerService, IMessageService messageService, ITestResultsReader testResultsReader) { - this.debuggerService = debuggerService; + this.debugger = debuggerService; this.messageService = messageService; this.testResultsReader = testResultsReader; - this.debugger = debuggerService.CurrentDebugger; testResultsReader.TestFinished += OnTestFinished; } @@ -70,7 +68,7 @@ namespace ICSharpCode.UnitTesting } public bool IsDebuggerRunning { - get { return debuggerService.IsDebuggerLoaded && debugger.IsDebugging; } + get { return debugger.IsDebuggerLoaded && debugger.IsDebugging; } } bool CanStopDebugging() diff --git a/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj b/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj index a310032dac..7a49082db4 100644 --- a/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj +++ b/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj @@ -56,6 +56,7 @@ + @@ -64,7 +65,6 @@ - @@ -82,7 +82,6 @@ - diff --git a/src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/WebBehavior.cs b/src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/WebBehavior.cs index ef43105b52..d63f11cb3c 100644 --- a/src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/WebBehavior.cs +++ b/src/AddIns/BackendBindings/AspNet.Mvc/Project/Src/WebBehavior.cs @@ -112,7 +112,7 @@ namespace ICSharpCode.AspNet.Mvc case StartAction.Program: ProcessStartInfo processInfo = DotNetStartBehavior.CreateStartInfo(StartProgram, Project.Directory, StartWorkingDirectory, StartArguments); if (withDebugging) { - DebuggerService.CurrentDebugger.Start(processInfo); + SD.Debugger.Start(processInfo); } else { Process.Start(processInfo); } @@ -152,14 +152,14 @@ namespace ICSharpCode.AspNet.Mvc int index = Array.FindIndex(processes, p => properties.UseIISExpress ? p.Id == LastStartedIISExpressProcessId : p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase)); if (index > -1) { if (withDebugging) - DebuggerService.CurrentDebugger.Attach(processes[index]); + SD.Debugger.Attach(processes[index]); } else { if (properties.UseIISExpress) { // start IIS express and attach to it if (WebProjectService.IsIISExpressInstalled) { ProcessStartInfo processInfo = IISExpressProcessStartInfo.Create(WebProject); if (withDebugging) { - DebuggerService.CurrentDebugger.Start(processInfo); + SD.Debugger.Start(processInfo); } else { var process = Process.Start(processInfo); LastStartedIISExpressProcessId = process.Id; @@ -192,9 +192,9 @@ namespace ICSharpCode.AspNet.Mvc if (index == -1) return; if (withDebugging) { - DebuggerService.CurrentDebugger.Attach(processes[index]); + SD.Debugger.Attach(processes[index]); - if (!DebuggerService.CurrentDebugger.IsAttached) { + if (!SD.Debugger.IsAttached) { if(properties.UseIIS) { string format = ResourceService.GetString("ICSharpCode.WebProjectOptionsPanel.NoIISWP"); MessageService.ShowMessage(string.Format(format, processName)); diff --git a/src/AddIns/BackendBindings/Scripting/Project/Src/RunScriptingConsoleApplicationCommand.cs b/src/AddIns/BackendBindings/Scripting/Project/Src/RunScriptingConsoleApplicationCommand.cs index e5ecf9f2a4..5c6eb5e19e 100644 --- a/src/AddIns/BackendBindings/Scripting/Project/Src/RunScriptingConsoleApplicationCommand.cs +++ b/src/AddIns/BackendBindings/Scripting/Project/Src/RunScriptingConsoleApplicationCommand.cs @@ -27,12 +27,12 @@ namespace ICSharpCode.Scripting { public class RunScriptingConsoleApplicationCommand : AbstractMenuCommand { - IDebugger debugger; + IDebuggerService debugger; IScriptingWorkbench workbench; ScriptingConsoleApplication scriptingConsoleApplication; public RunScriptingConsoleApplicationCommand(IScriptingWorkbench workbench, - IDebugger debugger, + IDebuggerService debugger, ScriptingConsoleApplication scriptingConsoleApplication) { this.workbench = workbench; diff --git a/src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs b/src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointBookmark.cs similarity index 83% rename from src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs rename to src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointBookmark.cs index 22bd28a194..d498e7cca7 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmark.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointBookmark.cs @@ -19,17 +19,21 @@ using System; using System.ComponentModel; using System.Linq; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; using System.Windows.Media; using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.Core; using ICSharpCode.NRefactory; using ICSharpCode.NRefactory.Editor; +using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Editor.Bookmarks; using ICSharpCode.SharpDevelop.Editor; -namespace ICSharpCode.SharpDevelop.Debugging +namespace Debugger.AddIn.Breakpoints { - public class BreakpointBookmark : SDMarkerBookmark + public class BreakpointBookmark : SDMarkerBookmark, IHaveStateEnabled { bool isHealthy = true; bool isEnabled = true; @@ -95,11 +99,6 @@ namespace ICSharpCode.SharpDevelop.Debugging this.FileName = fileName; } - public const string BreakpointMarker = "Breakpoint"; - - public static readonly Color DefaultBackground = Color.FromRgb(180, 38, 38); - public static readonly Color DefaultForeground = Colors.White; - public static IImage BreakpointImage { get { return SD.ResourceService.GetImage("Bookmarks.Breakpoint"); } } @@ -132,16 +131,16 @@ namespace ICSharpCode.SharpDevelop.Debugging IDocumentLine line = this.Document.GetLineByNumber(this.LineNumber); ITextMarker marker = markerService.Create(line.Offset, line.Length); IHighlighter highlighter = this.Document.GetService(typeof(IHighlighter)) as IHighlighter; - marker.BackgroundColor = DefaultBackground; - marker.ForegroundColor = DefaultForeground; - marker.MarkerColor = DefaultBackground; + marker.BackgroundColor = BookmarkBase.BreakpointDefaultBackground; + marker.ForegroundColor = BookmarkBase.BreakpointDefaultForeground; + marker.MarkerColor = BookmarkBase.BreakpointDefaultBackground; marker.MarkerTypes = TextMarkerTypes.CircleInScrollBar; if (highlighter != null) { - var color = highlighter.GetNamedColor(BreakpointMarker); + var color = highlighter.GetNamedColor(BookmarkBase.BreakpointMarkerName); if (color != null) { marker.BackgroundColor = color.Background.GetColor(null); - marker.MarkerColor = color.Background.GetColor(null) ?? DefaultBackground; + marker.MarkerColor = color.Background.GetColor(null) ?? BookmarkBase.BreakpointDefaultForeground; marker.ForegroundColor = color.Foreground.GetColor(null); } } @@ -152,5 +151,17 @@ namespace ICSharpCode.SharpDevelop.Debugging { return string.Format("{0} @{1}", this.FileName, this.LineNumber); } + + public override object CreateTooltipContent() + { + return new Popup { + StaysOpen = false, + Child = new Border { + Child = new BreakpointEditor(this), + BorderBrush = Brushes.Black, + BorderThickness = new Thickness(1) + } + }; + } } } diff --git a/src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmarkEventArgs.cs b/src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointBookmarkEventArgs.cs similarity index 97% rename from src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmarkEventArgs.cs rename to src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointBookmarkEventArgs.cs index 3146601b06..e0bc767fff 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/BreakpointBookmarkEventArgs.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointBookmarkEventArgs.cs @@ -18,7 +18,7 @@ using System; -namespace ICSharpCode.SharpDevelop.Debugging +namespace Debugger.AddIn.Breakpoints { public class BreakpointBookmarkEventArgs : EventArgs { diff --git a/src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointEditor.xaml b/src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointEditor.xaml new file mode 100644 index 0000000000..f3d694153e --- /dev/null +++ b/src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointEditor.xaml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/src/AddIns/Analysis/UnitTesting/Interfaces/IUnitTestDebuggerService.cs b/src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointEditor.xaml.cs similarity index 70% rename from src/AddIns/Analysis/UnitTesting/Interfaces/IUnitTestDebuggerService.cs rename to src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointEditor.xaml.cs index 2067c07272..73b67da072 100644 --- a/src/AddIns/Analysis/UnitTesting/Interfaces/IUnitTestDebuggerService.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Breakpoints/BreakpointEditor.xaml.cs @@ -17,13 +17,25 @@ // DEALINGS IN THE SOFTWARE. using System; -using ICSharpCode.SharpDevelop.Debugging; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; -namespace ICSharpCode.UnitTesting +namespace Debugger.AddIn.Breakpoints { - public interface IUnitTestDebuggerService + /// + /// Interaction logic for BreakpointEditor.xaml + /// + public partial class BreakpointEditor : UserControl { - bool IsDebuggerLoaded { get; } - IDebugger CurrentDebugger { get; } + public BreakpointEditor(BreakpointBookmark target) + { + InitializeComponent(); + } } -} +} \ No newline at end of file diff --git a/src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs b/src/AddIns/Debugger/Debugger.AddIn/Breakpoints/CurrentLineBookmark.cs similarity index 89% rename from src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs rename to src/AddIns/Debugger/Debugger.AddIn/Breakpoints/CurrentLineBookmark.cs index dc6e91d8c7..f9d1f79ee5 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Breakpoints/CurrentLineBookmark.cs @@ -85,11 +85,6 @@ namespace ICSharpCode.SharpDevelop.Debugging get { return false; } } - public const string Name = "Current statement"; - - public static readonly Color DefaultBackground = Colors.Yellow; - public static readonly Color DefaultForeground = Colors.Blue; - public override int ZOrder { get { return 100; } } @@ -98,8 +93,9 @@ namespace ICSharpCode.SharpDevelop.Debugging get { return false; } } - public override bool IsVisibleInBookmarkPad { - get { return false; } + public override bool ShowInPad(BookmarkPadBase pad) + { + return false; } public override IImage Image { @@ -114,11 +110,11 @@ namespace ICSharpCode.SharpDevelop.Debugging int eOffset = Math.Min(eLine.Offset + endColumn - 1, eLine.EndOffset); ITextMarker marker = markerService.Create(sOffset, Math.Max(eOffset - sOffset, 1)); IHighlighter highlighter = this.Document.GetService(typeof(IHighlighter)) as IHighlighter; - marker.BackgroundColor = DefaultBackground; - marker.ForegroundColor = DefaultForeground; + marker.BackgroundColor = BookmarkBase.CurrentLineDefaultBackground; + marker.ForegroundColor = BookmarkBase.CurrentLineDefaultForeground; if (highlighter != null) { - var color = highlighter.GetNamedColor(Name); + var color = highlighter.GetNamedColor(BookmarkBase.CurrentLineBookmarkName); if (color != null) { marker.BackgroundColor = color.Background.GetColor(null); marker.ForegroundColor = color.Foreground.GetColor(null); @@ -136,7 +132,7 @@ namespace ICSharpCode.SharpDevelop.Debugging // call async because the Debugger seems to use Application.DoEvents(), but we don't want to process events // because Drag'N'Drop operation has finished SD.MainThread.InvokeAsyncAndForget(delegate { - DebuggerService.CurrentDebugger.SetInstructionPointer(this.FileName, lineNumber, 1, false); + SD.Debugger.SetInstructionPointer(this.FileName, lineNumber, 1, false); }); } } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin index 6072ad7ec6..8c0527033b 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin +++ b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.addin @@ -9,6 +9,7 @@ + @@ -16,13 +17,9 @@ - - + + @@ -75,7 +72,7 @@ label = "${res:MainWindow.Windows.Debug.DebugExecutable}" class = "Debugger.AddIn.DebugExecutableMenuCommand"/> -