Browse Source

Move common code for running the IronRuby or IronPython console from the menu to the Scripting project.

pull/1/head
mrward 15 years ago
parent
commit
c132891492
  1. 3
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunDebugPythonCommand.cs
  2. 42
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs
  3. 2
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTests.cs
  4. 2
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/RunPythonCommandTests.cs
  5. 2
      src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
  6. 51
      src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RunRubyCommand.cs
  7. 1
      src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj
  8. 65
      src/AddIns/BackendBindings/Scripting/Project/Src/RunScriptingConsoleApplicationCommand.cs

3
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunDebugPythonCommand.cs

@ -2,11 +2,8 @@ @@ -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

@ -2,14 +2,8 @@ @@ -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 @@ -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
src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTestFixture.cs → src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTests.cs

@ -51,7 +51,7 @@ namespace PythonBinding.Tests.Gui @@ -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);
}
}

2
src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/RunPythonCommandTests.cs

@ -61,7 +61,7 @@ namespace PythonBinding.Tests.Gui @@ -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);
}

2
src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj

@ -313,7 +313,7 @@ @@ -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

@ -17,61 +17,16 @@ namespace ICSharpCode.RubyBinding @@ -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

@ -81,6 +81,7 @@ @@ -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

@ -0,0 +1,65 @@ @@ -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);
}
}
}
Loading…
Cancel
Save