Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move common code for running the IronRuby or IronPython console from …

…the menu to the Scripting project.
  • Loading branch information...
commit c13289149252321dab2311038bb150e5b7c79936 1 parent fc508ad
Matt Ward mrward authored
3  src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunDebugPythonCommand.cs
View
@@ -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
{
42 src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs
View
@@ -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.
/// </summary>
- 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();
}
}
}
2  ...Binding/Test/Gui/DebugPythonCommandTestFixture.cs → ...PythonBinding/Test/Gui/DebugPythonCommandTests.cs
View
@@ -51,7 +51,7 @@ public void Run_PythonFileOpen_IronPythonConsoleFileNamePassedToDebugger()
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);
}
}
2  src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/RunPythonCommandTests.cs
View
@@ -61,7 +61,7 @@ public void Run_PythonFileOpen_CommandPromptExePassedToDebugger()
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);
}
2  src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
View
@@ -313,7 +313,7 @@
<Compile Include="Expressions\StringTextContentProviderTests.cs" />
<Compile Include="Gui\AppSettingsPanelTestFixture.cs" />
<Compile Include="Gui\CompilingOptionsPanelTestFixture.cs" />
- <Compile Include="Gui\DebugPythonCommandTestFixture.cs" />
+ <Compile Include="Gui\DebugPythonCommandTests.cs" />
<Compile Include="Gui\FormsDesignerDisplayBindingTestFixture.cs" />
<Compile Include="Gui\PythonIndentationTests.cs" />
<Compile Include="Gui\PythonOptionsPanelTestFixture.cs" />
51 src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RunRubyCommand.cs
View
@@ -17,61 +17,16 @@ namespace ICSharpCode.RubyBinding
/// Runs the Ruby console passing the filename of the
/// active Ruby script open in SharpDevelop.
/// </summary>
- 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);
}
}
}
1  src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj
View
@@ -81,6 +81,7 @@
<Compile Include="Src\IScriptingFileService.cs" />
<Compile Include="Src\IScriptingWorkbench.cs" />
<Compile Include="Src\PauseCommandPromptProcessStartInfo.cs" />
+ <Compile Include="Src\RunScriptingConsoleApplicationCommand.cs" />
<Compile Include="Src\ScriptingCodeBuilder.cs" />
<Compile Include="Src\ScriptingCommandLineBuilder.cs" />
<Compile Include="Src\ScriptingConsole.cs" />
65 src/AddIns/BackendBindings/Scripting/Project/Src/RunScriptingConsoleApplicationCommand.cs
View
@@ -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);
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.