diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
index 3653240871..9a9d9bc495 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
@@ -69,6 +69,7 @@
+
@@ -79,6 +80,7 @@
+
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IMemberProvider.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IMemberProvider.cs
new file mode 100644
index 0000000000..7b82f0c44c
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IMemberProvider.cs
@@ -0,0 +1,22 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+
+namespace ICSharpCode.PythonBinding
+{
+ ///
+ /// Returns member names or global names for the python console command line.
+ ///
+ public interface IMemberProvider
+ {
+ IList GetMemberNames(string name);
+
+ IList GetGlobals(string name);
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ITextEditor.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ITextEditor.cs
index 73d5d2b8b0..6677a39e87 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ITextEditor.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/ITextEditor.cs
@@ -10,6 +10,7 @@ using System.Drawing;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
+using ICSharpCode.TextEditor.Gui.CompletionWindow;
namespace ICSharpCode.PythonBinding
{
@@ -86,7 +87,7 @@ namespace ICSharpCode.PythonBinding
///
/// Shows the code completion window.
///
- void ShowCompletionWindow();
+ void ShowCompletionWindow(ICompletionDataProvider completionDataProvider);
///
/// Makes the current text content read only. Text can be entered at the end.
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs
index dca4ff8709..18261ec308 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs
@@ -19,7 +19,7 @@ using Microsoft.Scripting.Hosting.Shell;
namespace ICSharpCode.PythonBinding
{
- public class PythonConsole : IConsole, IDisposable
+ public class PythonConsole : IConsole, IDisposable, IMemberProvider
{
ITextEditor textEditor;
int lineReceivedEventIndex = 0; // The index into the waitHandles array where the lineReceivedEvent is stored.
@@ -28,11 +28,14 @@ namespace ICSharpCode.PythonBinding
WaitHandle[] waitHandles;
int promptLength;
List previousLines = new List();
+ CommandLine commandLine;
- public PythonConsole(ITextEditor textEditor)
+ public PythonConsole(ITextEditor textEditor, CommandLine commandLine)
{
waitHandles = new WaitHandle[] {lineReceivedEvent, disposedEvent};
+ this.commandLine = commandLine;
+
this.textEditor = textEditor;
textEditor.KeyPress += ProcessKeyPress;
textEditor.DialogKeyPress += ProcessDialogKeyPress;
@@ -67,6 +70,19 @@ namespace ICSharpCode.PythonBinding
}
}
+ ///
+ /// Gets the member names of the specified item.
+ ///
+ public IList GetMemberNames(string name)
+ {
+ return commandLine.GetMemberNames(name);
+ }
+
+ public IList GetGlobals(string name)
+ {
+ return commandLine.GetGlobals(name);
+ }
+
///
/// Returns the next line typed in by the console user. If no line is available this method
/// will block.
@@ -89,6 +105,9 @@ namespace ICSharpCode.PythonBinding
return null;
}
+ ///
+ /// Writes text to the console.
+ ///
public void Write(string text, Style style)
{
Console.WriteLine("PythonConsole.Write(text, style): " + text);
@@ -101,11 +120,17 @@ namespace ICSharpCode.PythonBinding
}
}
+ ///
+ /// Writes text followed by a newline to the console.
+ ///
public void WriteLine(string text, Style style)
{
Write(text + Environment.NewLine, style);
}
+ ///
+ /// Writes an empty line to the console.
+ ///
public void WriteLine()
{
Write(Environment.NewLine, Style.Out);
@@ -174,6 +199,10 @@ namespace ICSharpCode.PythonBinding
if (ch == '\n') {
OnEnterKeyPressed();
}
+
+ if (ch == '.') {
+ ShowCompletionWindow();
+ }
return false;
}
@@ -248,5 +277,11 @@ namespace ICSharpCode.PythonBinding
return cursorIndex > 0 && selectionStartIndex > 0;
}
}
+
+ void ShowCompletionWindow()
+ {
+ PythonConsoleCompletionDataProvider completionProvider = new PythonConsoleCompletionDataProvider(this);
+ textEditor.ShowCompletionWindow(completionProvider);
+ }
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleCompletionDataProvider.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleCompletionDataProvider.cs
new file mode 100644
index 0000000000..cdc114460a
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleCompletionDataProvider.cs
@@ -0,0 +1,75 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+using System.Windows.Forms;
+
+using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.TextEditor;
+using ICSharpCode.TextEditor.Document;
+using ICSharpCode.TextEditor.Gui.CompletionWindow;
+
+namespace ICSharpCode.PythonBinding
+{
+ ///
+ /// Provides code completion for the Python Console window.
+ ///
+ public class PythonConsoleCompletionDataProvider : AbstractCompletionDataProvider
+ {
+ IMemberProvider memberProvider;
+
+ public PythonConsoleCompletionDataProvider(IMemberProvider memberProvider)
+ {
+ this.memberProvider = memberProvider;
+ DefaultIndex = 0;
+ }
+
+ public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped)
+ {
+ return GenerateCompletionData(GetLineText(textArea));
+ }
+
+ ///
+ /// Generates completion data for the specified text. The text should be everything before
+ /// the dot character that triggered the completion. The text can contain the command line prompt
+ /// '>>>' as this will be ignored.
+ ///
+ public ICompletionData[] GenerateCompletionData(string line)
+ {
+ List items = new List();
+
+ string name = GetName(line);
+ if (!String.IsNullOrEmpty(name)) {
+ try {
+ foreach (string member in memberProvider.GetMemberNames(name)) {
+ items.Add(new DefaultCompletionData(member, String.Empty, ClassBrowserIconService.MethodIndex));
+ }
+ } catch {
+ // Do nothing.
+ }
+ }
+ return items.ToArray();
+ }
+
+ string GetName(string text)
+ {
+ int startIndex = text.LastIndexOf(' ');
+ return text.Substring(startIndex + 1);
+ }
+
+ ///
+ /// Gets the line of text up to the cursor position.
+ ///
+ string GetLineText(TextArea textArea)
+ {
+ LineSegment lineSegment = textArea.Document.GetLineSegmentForOffset(textArea.Caret.Offset);
+ return textArea.Document.GetText(lineSegment);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleHost.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleHost.cs
index efe95d63f7..05dc88961f 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleHost.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleHost.cs
@@ -73,7 +73,7 @@ namespace ICSharpCode.PythonBinding
protected override IConsole CreateConsole(ScriptEngine engine, CommandLine commandLine, ConsoleOptions options)
{
SetOutput(new PythonOutputStream(textEditor));
- pythonConsole = new PythonConsole(textEditor);
+ pythonConsole = new PythonConsole(textEditor, commandLine);
return pythonConsole;
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/TextEditor.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/TextEditor.cs
index 428f113e35..3eae661823 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/TextEditor.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/TextEditor.cs
@@ -10,6 +10,7 @@ using System.Drawing;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
+using ICSharpCode.TextEditor.Gui.CompletionWindow;
namespace ICSharpCode.PythonBinding
{
@@ -22,6 +23,8 @@ namespace ICSharpCode.PythonBinding
TextArea textArea;
Color customLineColour = Color.LightGray;
TextMarker readOnlyMarker;
+
+ CodeCompletionWindow completionWindow;
public TextEditor(TextEditorControl textEditorControl)
{
@@ -137,8 +140,12 @@ namespace ICSharpCode.PythonBinding
doc.UndoStack.ClearAll();
}
- public void ShowCompletionWindow()
+ public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider)
{
+ completionWindow = CodeCompletionWindow.ShowCompletionWindow(textEditorControl.ParentForm, textEditorControl, String.Empty, completionDataProvider, ' ');
+ if (completionWindow != null) {
+ completionWindow.Closed += CompletionWindowClosed;
+ }
}
///
@@ -158,5 +165,14 @@ namespace ICSharpCode.PythonBinding
textEditorControl.IndentStyle = style;
}
}
+
+ void CompletionWindowClosed(object source, EventArgs e)
+ {
+ if (completionWindow != null) {
+ completionWindow.Closed -= CompletionWindowClosed;
+ completionWindow.Dispose();
+ completionWindow = null;
+ }
+ }
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/BuiltinCodeCompletionTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/BuiltinCodeCompletionTestFixture.cs
new file mode 100644
index 0000000000..023edc102d
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/BuiltinCodeCompletionTestFixture.cs
@@ -0,0 +1,94 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+using Microsoft.Scripting.Hosting;
+
+using ICSharpCode.PythonBinding;
+using ICSharpCode.TextEditor;
+using ICSharpCode.TextEditor.Gui.CompletionWindow;
+using NUnit.Framework;
+
+namespace PythonBinding.Tests.Console
+{
+ ///
+ /// Tests the code completion when the user has typed in __builtins__.
+ ///
+ [TestFixture]
+ public class BuiltinCodeCompletionTestFixture
+ {
+ ICompletionData[] completionItems;
+ ICompletionData[] expectedCompletionItems;
+ PythonConsoleCompletionDataProvider provider;
+ MockMemberProvider memberProvider;
+
+ [TestFixtureSetUp]
+ public void SetUpFixture()
+ {
+ using (TextEditorControl textEditorControl = new TextEditorControl()) {
+ textEditorControl.Text = ">>> __builtins__";
+ TextEditor textEditor = new TextEditor(textEditorControl);
+
+ memberProvider = new MockMemberProvider();
+ memberProvider.SetMemberNames(new string[] {"a", "b", "c"});
+ expectedCompletionItems = CreateCompletionItems(memberProvider.GetMemberNames("__builtins__"));
+
+ provider = new PythonConsoleCompletionDataProvider(memberProvider);
+ completionItems = provider.GenerateCompletionData(String.Empty, textEditorControl.ActiveTextAreaControl.TextArea, '.');
+
+ }
+ }
+
+ [Test]
+ public void MoreThanOneCompletionItem()
+ {
+ Assert.IsTrue(completionItems.Length > 0);
+ }
+
+ [Test]
+ public void ExpectedCompletionItems()
+ {
+ for (int i = 0; i < expectedCompletionItems.Length; ++i) {
+ Assert.AreEqual(expectedCompletionItems[i].Text, completionItems[i].Text);
+ }
+ }
+
+ [Test]
+ public void ExpectedCompletionItemsCountEqualsActualCompletionItemsCount()
+ {
+ Assert.AreEqual(expectedCompletionItems.Length, completionItems.Length);
+ }
+
+ [Test]
+ public void PreSelectionIsNull()
+ {
+ Assert.IsNull(provider.PreSelection);
+ }
+
+ [Test]
+ public void DefaultIndexIsZero()
+ {
+ Assert.AreEqual(0, provider.DefaultIndex);
+ }
+
+ [Test]
+ public void BuiltinsPassedToMemberProvider()
+ {
+ Assert.AreEqual("__builtins__", memberProvider.GetMemberNamesParameter);
+ }
+
+ ICompletionData[] CreateCompletionItems(IList memberNames)
+ {
+ List items = new List();
+ foreach (string memberName in memberNames) {
+ items.Add(new DefaultCompletionData(memberName, String.Empty, 0));
+ }
+ return items.ToArray();
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/CodeCompletionTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/CodeCompletionTests.cs
new file mode 100644
index 0000000000..245b394d2b
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/CodeCompletionTests.cs
@@ -0,0 +1,74 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+
+using ICSharpCode.PythonBinding;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.TextEditor.Gui.CompletionWindow;
+using NUnit.Framework;
+
+namespace PythonBinding.Tests.Console
+{
+ [TestFixture]
+ public class EmptyStringCodeCompletionTestFixture
+ {
+ MockMemberProvider memberProvider;
+ PythonConsoleCompletionDataProvider completionProvider;
+
+ [SetUp]
+ public void Init()
+ {
+ memberProvider = new MockMemberProvider();
+ completionProvider = new PythonConsoleCompletionDataProvider(memberProvider);
+ }
+
+ ///
+ /// If the user presses the dot character without having any text in the command line then
+ /// a SyntaxException occurs if the code calls IronPython's CommandLine.GetMemberNames. So this
+ /// tests ensures that if the string is empty then this method is not called.
+ ///
+ [Test]
+ public void NoCompletionItemsGeneratedForEmptyString()
+ {
+ memberProvider.SetMemberNames(new string[] {"a"});
+ memberProvider.SetGlobals(new string[] {"a"});
+
+ Assert.AreEqual(0, completionProvider.GenerateCompletionData(">>> ").Length);
+ }
+
+ ///
+ /// Checks that the GenerateCompletionData method catches any exceptions thrown by the
+ /// IMemberProvider implementation. This can occur when an invalid name is passed to
+ /// IronPython's CommandLine.GetMemberNames or GetGlobals. For example, an UnboundNameException is
+ /// thrown if an unknown name is used.
+ ///
+ [Test]
+ public void NoCompletionItemsGeneratedWhenExceptionThrown()
+ {
+ memberProvider.ExceptionToThrow = new ApplicationException("Should not be thrown");
+
+ Assert.AreEqual(0, completionProvider.GenerateCompletionData(">>> a").Length);
+ }
+
+ [Test]
+ public void ImageIndexIsMethod()
+ {
+ memberProvider.SetMemberNames(new string[] {"a"});
+
+ ICompletionData[] items = completionProvider.GenerateCompletionData(">>> a");
+ Assert.AreEqual(ClassBrowserIconService.MethodIndex, items[0].ImageIndex);
+ }
+
+ [Test]
+ public void UnderscoresPassedToGetMemberNames()
+ {
+ completionProvider.GenerateCompletionData(">>> __builtins__");
+ Assert.AreEqual("__builtins__", memberProvider.GetMemberNamesParameter);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/DerivedPythonConsoleHost.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/DerivedPythonConsoleHost.cs
index 7d45c22a5e..bd6ee450a3 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/DerivedPythonConsoleHost.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/DerivedPythonConsoleHost.cs
@@ -45,15 +45,7 @@ namespace PythonBinding.Tests.Console
{
return base.CreateOptionsParser();
}
-
- ///
- /// Script engine to return from base.CreateEngine(Type context).
- ///
- public ScriptEngine ScriptEngineToReturn {
- get { return engine; }
- set { engine = value; }
- }
-
+
///
/// Context type passed to base.CreateEngine(Type context).
///
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/DisposedPythonConsoleTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/DisposedPythonConsoleTestFixture.cs
index f8ae87624e..b64bb2e04a 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/DisposedPythonConsoleTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/DisposedPythonConsoleTestFixture.cs
@@ -20,14 +20,14 @@ namespace PythonBinding.Tests.Console
[Test]
public void PythonConsoleImplementsIDisposable()
{
- PythonConsole console = new PythonConsole(new MockTextEditor());
+ PythonConsole console = new PythonConsole(new MockTextEditor(), null);
Assert.IsNotNull(console as IDisposable);
}
[Test]
public void ReadLineReturnsNullWhenConsoleDisposed()
{
- PythonConsole console = new PythonConsole(new MockTextEditor());
+ PythonConsole console = new PythonConsole(new MockTextEditor(), null);
console.Dispose();
Assert.IsNull(console.ReadLine(0));
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/MockMemberProvider.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/MockMemberProvider.cs
new file mode 100644
index 0000000000..8c9092cc82
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/MockMemberProvider.cs
@@ -0,0 +1,80 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+using ICSharpCode.PythonBinding;
+
+namespace PythonBinding.Tests.Console
+{
+ public class MockMemberProvider : IMemberProvider
+ {
+ List memberNames = new List();
+ string getMemberNamesParameter;
+ List globals = new List();
+ string getGlobalsParameter;
+ Exception exceptionToThrow;
+
+ public MockMemberProvider()
+ {
+ }
+
+ ///
+ /// Exception that will be thrown if the GetMemberNames method or GetGlobals method is called.
+ ///
+ public Exception ExceptionToThrow {
+ get { return exceptionToThrow; }
+ set { exceptionToThrow = value; }
+ }
+
+ public void SetMemberNames(string[] names)
+ {
+ memberNames.AddRange(names);
+ }
+
+ public IList GetMemberNames(string name)
+ {
+ getMemberNamesParameter = name;
+
+ if (exceptionToThrow != null) {
+ throw exceptionToThrow;
+ }
+
+ return memberNames;
+ }
+
+ public void SetGlobals(string[] names)
+ {
+ globals.AddRange(names);
+ }
+
+ public IList GetGlobals(string name)
+ {
+ getGlobalsParameter = name;
+
+ if (exceptionToThrow != null) {
+ throw exceptionToThrow;
+ }
+
+ return globals;
+ }
+
+ ///
+ /// Returns the parameter passed to the GetGlobals method.
+ ///
+ public string GetGlobalsParameter {
+ get { return getGlobalsParameter; }
+ }
+
+ ///
+ /// Returns the parameter passed to the GetMemberNames method.
+ ///
+ public string GetMemberNamesParameter {
+ get { return getMemberNamesParameter; }
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/MockTextEditor.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/MockTextEditor.cs
index 4886f66d84..f5cfe4fa41 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/MockTextEditor.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/MockTextEditor.cs
@@ -13,6 +13,7 @@ using System.Text;
using ICSharpCode.PythonBinding;
using ICSharpCode.TextEditor;
+using ICSharpCode.TextEditor.Gui.CompletionWindow;
using ICSharpCode.TextEditor.Document;
namespace PythonBinding.Tests.Console
@@ -31,6 +32,7 @@ namespace PythonBinding.Tests.Console
List textColors = new List();
bool showCompletionWindowCalled;
bool makeReadOnlyCalled;
+ ICompletionDataProvider completionProvider;
public MockTextEditor()
{
@@ -69,6 +71,13 @@ namespace PythonBinding.Tests.Console
public bool IsMakeCurrentContentReadOnlyCalled {
get { return makeReadOnlyCalled; }
}
+
+ ///
+ /// Returns the code completion data provider passed to the ShowCompletionWindow method.
+ ///
+ public ICompletionDataProvider CompletionDataProvider {
+ get { return completionProvider; }
+ }
public string Text {
get { return previousLines.ToString() + lineBuilder.ToString(); }
@@ -192,9 +201,10 @@ namespace PythonBinding.Tests.Console
return "aaaa";
}
- public void ShowCompletionWindow()
+ public void ShowCompletionWindow(ICompletionDataProvider completionDataProvider)
{
showCompletionWindowCalled = true;
+ this.completionProvider = completionDataProvider;
}
public void MakeCurrentContentReadOnly()
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleCodeCompletionTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleCodeCompletionTestFixture.cs
index 1bdb482790..2427ac1a7e 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleCodeCompletionTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleCodeCompletionTestFixture.cs
@@ -19,34 +19,24 @@ namespace PythonBinding.Tests.Console
/// When the dot character is typed in after an object the code completion window should appear.
///
[TestFixture]
- [Ignore("Not implemented")]
public class PythonConsoleCodeCompletionTestFixture
{
MockTextEditor textEditor;
PythonConsole console;
string prompt = ">>> ";
- IList expectedMembers;
- IList completionItems;
bool showCompletionWindowCalledBeforeDotTypedIn;
[TestFixtureSetUp]
public void SetUpFixture()
{
textEditor = new MockTextEditor();
- console = new PythonConsole(textEditor);
+ console = new PythonConsole(textEditor, null);
console.WriteLine(prompt, Style.Prompt);
-// expectedMembers = host.GetCommandLine().GetMemberNames("__builtins__");
textEditor.RaiseKeyPressEvents("__builtins__");
showCompletionWindowCalledBeforeDotTypedIn = textEditor.IsShowCompletionWindowCalled;
textEditor.RaiseKeyPressEvent('.');
}
-
-// [Test]
-// public void MoreThanZeroExpectedMembers()
-// {
-// Assert.IsTrue(expectedMembers.Count > 0);
-// }
[Test]
public void ShowCompletionWindowCalled()
@@ -59,5 +49,11 @@ namespace PythonBinding.Tests.Console
{
Assert.IsFalse(showCompletionWindowCalledBeforeDotTypedIn);
}
+
+ [Test]
+ public void PythonConsoleCompletionDataProviderPassedToShowCompletionWindowMethod()
+ {
+ Assert.IsInstanceOfType(typeof(PythonConsoleCompletionDataProvider), textEditor.CompletionDataProvider);
+ }
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleCurrentLineTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleCurrentLineTestFixture.cs
index a657505527..c6c6234ee3 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleCurrentLineTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleCurrentLineTestFixture.cs
@@ -29,7 +29,7 @@ namespace PythonBinding.Tests.Console
public void Init()
{
textEditor = new MockTextEditor();
- pythonConsole = new PythonConsole(textEditor);
+ pythonConsole = new PythonConsole(textEditor, null);
pythonConsole.Write(prompt, Style.Prompt);
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleEnterKeyTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleEnterKeyTestFixture.cs
index 22a6974b92..301af0e6d9 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleEnterKeyTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleEnterKeyTestFixture.cs
@@ -29,7 +29,7 @@ namespace PythonBinding.Tests.Console
public void Init()
{
textEditor = new MockTextEditor();
- console = new PythonConsole(textEditor);
+ console = new PythonConsole(textEditor, null);
console.Write(prompt, Style.Prompt);
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleHostTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleHostTests.cs
index d5d73eb2f4..102cd55469 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleHostTests.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleHostTests.cs
@@ -26,8 +26,6 @@ namespace PythonBinding.Tests.Console
{
DerivedPythonConsoleHost host;
TextEditorControl textEditorControl;
- ScriptEngine engine;
- ScriptEngine expectedEngine;
TextEditor textEditor;
[TestFixtureSetUp]
@@ -38,9 +36,6 @@ namespace PythonBinding.Tests.Console
host = new DerivedPythonConsoleHost(textEditor);
ScriptRuntime runtime = IronPython.Hosting.Python.CreateRuntime();
-// expectedEngine = runtime.GetEngine(typeof(PythonContext));
-// host.ScriptEngineToReturn = expectedEngine;
-// engine = host.CallCreateEngine();
}
[TestFixtureTearDown]
@@ -82,12 +77,6 @@ namespace PythonBinding.Tests.Console
{
Assert.AreEqual(typeof(PythonContext), host.GetProvider());
}
-
- [Test]
- public void ScriptEngineReturnedFromCreateEngine()
- {
- Assert.AreEqual(expectedEngine, engine);
- }
[Test]
public void ConsoleHostImplementsIDisposable()
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleReadOnlyRegionsTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleReadOnlyRegionsTestFixture.cs
index edfaeb90c9..c9bd38ab00 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleReadOnlyRegionsTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleReadOnlyRegionsTestFixture.cs
@@ -29,7 +29,7 @@ namespace PythonBinding.Tests.Console
public void Init()
{
textEditor = new MockTextEditor();
- console = new PythonConsole(textEditor);
+ console = new PythonConsole(textEditor, null);
console.Write(prompt, Style.Prompt);
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleReadTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleReadTestFixture.cs
index 7838e218af..ca6c2a4de1 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleReadTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleReadTestFixture.cs
@@ -33,7 +33,7 @@ namespace PythonBinding.Tests.Console
public void Init()
{
mockTextEditor = new MockTextEditor();
- pythonConsole = new PythonConsole(mockTextEditor);
+ pythonConsole = new PythonConsole(mockTextEditor, null);
autoIndentSize = initialAutoIndentSize;
Thread thread = new Thread(ReadLineFromConsoleOnDifferentThread);
@@ -88,7 +88,7 @@ namespace PythonBinding.Tests.Console
public void NoTextWrittenWhenAutoIndentSizeIsZero()
{
MockTextEditor textEditor = new MockTextEditor();
- PythonConsole console = new PythonConsole(textEditor);
+ PythonConsole console = new PythonConsole(textEditor, null);
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseDialogKeyPressEvent(Keys.Enter);
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleUnreadLinesTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleUnreadLinesTestFixture.cs
index 25b3d701ef..5248c3e41b 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleUnreadLinesTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleUnreadLinesTestFixture.cs
@@ -33,7 +33,7 @@ namespace PythonBinding.Tests.Console
public void Init()
{
textEditor = new MockTextEditor();
- pythonConsole = new PythonConsole(textEditor);
+ pythonConsole = new PythonConsole(textEditor, null);
}
[Test]
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleWriteTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleWriteTestFixture.cs
index 7faadb7e2c..99dd06fa88 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleWriteTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/PythonConsoleWriteTestFixture.cs
@@ -27,7 +27,7 @@ namespace PythonBinding.Tests.Console
{
mockTextEditor = new MockTextEditor();
mockTextEditor.Text = String.Empty;
- pythonConsole = new PythonConsole(mockTextEditor);
+ pythonConsole = new PythonConsole(mockTextEditor, null);
}
[Test]
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/TwoPythonConsoleLinesWaitingTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/TwoPythonConsoleLinesWaitingTestFixture.cs
index 50a2ba74a7..fe8231d9d3 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/TwoPythonConsoleLinesWaitingTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Console/TwoPythonConsoleLinesWaitingTestFixture.cs
@@ -39,7 +39,7 @@ namespace PythonBinding.Tests.Console
public void SetUpFixture()
{
MockTextEditor textEditor = new MockTextEditor();
- using (pythonConsole = new PythonConsole(textEditor)) {
+ using (pythonConsole = new PythonConsole(textEditor, null)) {
textEditor.RaiseKeyPressEvent('a');
textEditor.RaiseKeyPressEvent('=');
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
index b7b9895cdc..ff58ed4dea 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
@@ -69,8 +69,11 @@
+
+
+