diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunDebugPythonCommand.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunDebugPythonCommand.cs index d61b6ebe10..fb384afaa7 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunDebugPythonCommand.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunDebugPythonCommand.cs @@ -2,11 +2,8 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using ICSharpCode.Core; using ICSharpCode.Scripting; using ICSharpCode.SharpDevelop.Debugging; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.SharpDevelop.Util; namespace ICSharpCode.PythonBinding { diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs index 7f8d1e75a3..3748b65ab4 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs @@ -2,14 +2,8 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; -using System.Diagnostics; -using System.IO; - -using ICSharpCode.Core; using ICSharpCode.Scripting; using ICSharpCode.SharpDevelop.Debugging; -using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.SharpDevelop.Util; namespace ICSharpCode.PythonBinding { @@ -17,48 +11,16 @@ namespace ICSharpCode.PythonBinding /// Runs the Python console passing the filename of the /// active python script open in SharpDevelop. /// - public class RunPythonCommand : AbstractMenuCommand + public class RunPythonCommand : RunScriptingConsoleApplicationCommand { - IDebugger debugger; - PythonAddInOptions options; - IScriptingWorkbench workbench; - PythonConsoleApplication ipy; - public RunPythonCommand() : this(new PythonWorkbench(), new PythonAddInOptions(), DebuggerService.CurrentDebugger) { } public RunPythonCommand(IScriptingWorkbench workbench, PythonAddInOptions options, IDebugger debugger) + : base(workbench, debugger, new PythonConsoleApplication(options)) { - this.workbench = workbench; - this.debugger = debugger; - this.options = options; - ipy = new PythonConsoleApplication(options); - } - - public bool Debug { - get { return ipy.Debug; } - set { ipy.Debug = value; } - } - - public override void Run() - { - ProcessStartInfo processStartInfo = GetProcessStartInfo(); - if (Debug) { - debugger.Start(processStartInfo); - } else { - PauseCommandPromptProcessStartInfo pauseCommandPrompt = new PauseCommandPromptProcessStartInfo(processStartInfo); - debugger.StartWithoutDebugging(pauseCommandPrompt.ProcessStartInfo); - } - } - - ProcessStartInfo GetProcessStartInfo() - { - string scriptFileName = workbench.ActiveViewContent.PrimaryFileName; - ipy.ScriptFileName = scriptFileName; - ipy.WorkingDirectory = Path.GetDirectoryName(scriptFileName); - return ipy.GetProcessStartInfo(); } } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTests.cs similarity index 96% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTestFixture.cs rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTests.cs index af4215adb4..52a30a4ab9 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTests.cs @@ -51,7 +51,7 @@ namespace PythonBinding.Tests.Gui public void Run_PythonFileOpen_DebugOptionsPassedToIronPythonConsole() { string args = debugger.ProcessStartInfo.Arguments; - string expectedArgs = "-X:Debug \"C:\\Projects\\test.py\""; + string expectedArgs = "-X:Debug \"test.py\""; Assert.AreEqual(expectedArgs, args); } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/RunPythonCommandTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/RunPythonCommandTests.cs index b4ec3ed7a7..d1ebf7dea2 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/RunPythonCommandTests.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/RunPythonCommandTests.cs @@ -61,7 +61,7 @@ namespace PythonBinding.Tests.Gui public void Run_PythonFileOpen_IronPythonConsoleAndPythonFileNameAndPausePassedAsCommandLineArguments() { string args = debugger.ProcessStartInfo.Arguments; - string expectedArgs = "/c \"C:\\IronPython\\ipy.exe \"C:\\Projects\\test.py\"\" & pause"; + string expectedArgs = "/c \"C:\\IronPython\\ipy.exe \"test.py\"\" & pause"; Assert.AreEqual(expectedArgs, args); } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj index f028a53657..afe6b830dd 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj @@ -313,7 +313,7 @@ - + diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RunRubyCommand.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RunRubyCommand.cs index e744fc2853..2a69725588 100644 --- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RunRubyCommand.cs +++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RunRubyCommand.cs @@ -17,61 +17,16 @@ namespace ICSharpCode.RubyBinding /// Runs the Ruby console passing the filename of the /// active Ruby script open in SharpDevelop. /// - public class RunRubyCommand : AbstractMenuCommand - { - IDebugger debugger; - RubyAddInOptions options; - IScriptingWorkbench workbench; - RubyConsoleApplication rubyConsoleApplication; - + public class RunRubyCommand : RunScriptingConsoleApplicationCommand + { public RunRubyCommand() : this(new RubyWorkbench(), new RubyAddInOptions(), DebuggerService.CurrentDebugger) { } public RunRubyCommand(IScriptingWorkbench workbench, RubyAddInOptions options, IDebugger debugger) + : base(workbench, debugger, new RubyConsoleApplication(options)) { - this.workbench = workbench; - this.debugger = debugger; - this.options = options; - rubyConsoleApplication = new RubyConsoleApplication(options); - } - - public bool Debug { - get { return rubyConsoleApplication.Debug; } - set { rubyConsoleApplication.Debug = value; } - } - - public override void Run() - { - ProcessStartInfo processStartInfo = CreateProcessStartInfo(); - if (Debug) { - debugger.Start(processStartInfo); - } else { - PauseCommandPromptProcessStartInfo commandPrompt = new PauseCommandPromptProcessStartInfo(processStartInfo); - debugger.StartWithoutDebugging(commandPrompt.ProcessStartInfo); - } - } - - ProcessStartInfo CreateProcessStartInfo() - { - rubyConsoleApplication.ScriptFileName = GetRubyScriptFileName(); - rubyConsoleApplication.WorkingDirectory = GetWorkingDirectory(); - return rubyConsoleApplication.GetProcessStartInfo(); - } - - string GetWorkingDirectory() - { - return Path.GetDirectoryName(WorkbenchPrimaryFileName); - } - - FileName WorkbenchPrimaryFileName { - get { return workbench.ActiveViewContent.PrimaryFileName; } - } - - string GetRubyScriptFileName() - { - return Path.GetFileName(WorkbenchPrimaryFileName); } } } diff --git a/src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj b/src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj index 58282e9272..b37c760e48 100644 --- a/src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj +++ b/src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj @@ -81,6 +81,7 @@ + diff --git a/src/AddIns/BackendBindings/Scripting/Project/Src/RunScriptingConsoleApplicationCommand.cs b/src/AddIns/BackendBindings/Scripting/Project/Src/RunScriptingConsoleApplicationCommand.cs new file mode 100644 index 0000000000..ee357dcc7a --- /dev/null +++ b/src/AddIns/BackendBindings/Scripting/Project/Src/RunScriptingConsoleApplicationCommand.cs @@ -0,0 +1,65 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Diagnostics; +using System.IO; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Debugging; + +namespace ICSharpCode.Scripting +{ + public class RunScriptingConsoleApplicationCommand : AbstractMenuCommand + { + IDebugger debugger; + IScriptingWorkbench workbench; + ScriptingConsoleApplication scriptingConsoleApplication; + + public RunScriptingConsoleApplicationCommand(IScriptingWorkbench workbench, + IDebugger debugger, + ScriptingConsoleApplication scriptingConsoleApplication) + { + this.workbench = workbench; + this.debugger = debugger; + this.scriptingConsoleApplication = scriptingConsoleApplication; + } + + public bool Debug { + get { return scriptingConsoleApplication.Debug; } + set { scriptingConsoleApplication.Debug = value; } + } + + public override void Run() + { + ProcessStartInfo processStartInfo = CreateProcessStartInfo(); + if (Debug) { + debugger.Start(processStartInfo); + } else { + PauseCommandPromptProcessStartInfo commandPrompt = new PauseCommandPromptProcessStartInfo(processStartInfo); + debugger.StartWithoutDebugging(commandPrompt.ProcessStartInfo); + } + } + + ProcessStartInfo CreateProcessStartInfo() + { + scriptingConsoleApplication.ScriptFileName = GetScriptFileName(); + scriptingConsoleApplication.WorkingDirectory = GetWorkingDirectory(); + return scriptingConsoleApplication.GetProcessStartInfo(); + } + + string GetWorkingDirectory() + { + return Path.GetDirectoryName(WorkbenchPrimaryFileName); + } + + FileName WorkbenchPrimaryFileName { + get { return workbench.ActiveViewContent.PrimaryFileName; } + } + + string GetScriptFileName() + { + return Path.GetFileName(WorkbenchPrimaryFileName); + } + } +}