diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDomSerializer.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDomSerializer.cs
index 5f6a84d97f..1bfc6dca78 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDomSerializer.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDomSerializer.cs
@@ -7,12 +7,14 @@ using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
+using ICSharpCode.Scripting;
+
namespace ICSharpCode.PythonBinding
{
///
/// Used to generate Python code after the form has been changed in the designer.
///
- public class PythonCodeDomSerializer
+ public class PythonCodeDomSerializer : IScriptingCodeDomSerializer
{
PythonCodeBuilder codeBuilder;
string indentString = String.Empty;
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerGenerator.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerGenerator.cs
index b710e6c5e6..c04b6c7725 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerGenerator.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerGenerator.cs
@@ -23,200 +23,22 @@ namespace ICSharpCode.PythonBinding
///
/// Form's designer generator for the Python language.
///
- public class PythonDesignerGenerator : IScriptingDesignerGenerator
+ public class PythonDesignerGenerator : ScriptingDesignerGenerator
{
- FormsDesignerViewContent viewContent;
- ITextEditorOptions textEditorOptions;
-
public PythonDesignerGenerator(ITextEditorOptions textEditorOptions)
+ : base(textEditorOptions)
{
- this.textEditorOptions = textEditorOptions;
- }
-
- ///
- /// Gets the Python code dom provider.
- ///
- public CodeDomProvider CodeDomProvider {
- get { return null; }
- }
-
- public void Attach(FormsDesignerViewContent viewContent)
- {
- this.viewContent = viewContent;
- }
-
- public void Detach()
- {
- this.viewContent = null;
- }
-
- public IEnumerable GetSourceFiles(out OpenedFile designerCodeFile)
- {
- designerCodeFile = this.ViewContent.PrimaryFile;
- return new [] {designerCodeFile};
- }
-
- public void MergeFormChanges(CodeCompileUnit unit)
- {
- }
-
- public void NotifyFormRenamed(string newName)
- {
- }
-
- ///
- /// Updates the InitializeComponent method's body with the generated code.
- ///
- public void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager)
- {
- ParseInformation parseInfo = ParseFile();
- Merge(host, ViewContent.DesignerCodeFileDocument, parseInfo.CompilationUnit, textEditorOptions, serializationManager);
- }
-
- ///
- /// Merges the generated code into the specified document.
- ///
- /// The designer host.
- /// The document that the generated code will be merged into.
- /// The current compilation unit for the .
- public static void Merge(IDesignerHost host, IDocument document, ICompilationUnit compilationUnit, ITextEditorOptions textEditorOptions, IDesignerSerializationManager serializationManager)
- {
- // Get the document's initialize components method.
- IMethod method = GetInitializeComponents(compilationUnit);
-
- // Generate the python source code.
- PythonCodeDomSerializer serializer = new PythonCodeDomSerializer(textEditorOptions.IndentationString);
- int indent = method.Region.BeginColumn;
- if (textEditorOptions.ConvertTabsToSpaces) {
- indent = (indent / textEditorOptions.IndentationSize);
- if (textEditorOptions.IndentationSize > 1) {
- indent += 1;
- }
- }
- string rootNamespace = GetProjectRootNamespace(compilationUnit);
- string methodBody = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, rootNamespace, indent);
-
- // Merge the code.
- DomRegion methodRegion = GetBodyRegionInDocument(method);
- int startOffset = GetStartOffset(document, methodRegion);
- int endOffset = GetEndOffset(document, methodRegion);
-
- document.Replace(startOffset, endOffset - startOffset, methodBody);
- }
-
- ///
- /// Inserts an event handler.
- ///
- public bool InsertComponentEvent(IComponent component, EventDescriptor edesc, string eventMethodName, string body, out string file, out int position)
- {
- position = GetExistingEventHandler(eventMethodName);
- if (position == -1) {
- // Ensure the text editor has the latest version
- // of the source code before we insert any new code.
- viewContent.MergeFormChanges();
-
- // Insert the event handler at the end of the class with an extra
- // new line before it.
- IDocument doc = viewContent.DesignerCodeFileDocument;
- string eventHandler = CreateEventHandler(eventMethodName, body, textEditorOptions.IndentationString);
- int line = doc.TotalNumberOfLines;
- IDocumentLine lastLineSegment = doc.GetLine(line);
- int offset = lastLineSegment.Offset + lastLineSegment.Length;
-
- string newContent = "\r\n" + eventHandler;
- if (lastLineSegment.Length > 0) {
- // Add an extra new line between the last line and the event handler.
- newContent = "\r\n" + newContent;
- }
- doc.Insert(offset, newContent);
-
- // Set position so it points to the line
- // where the event handler was inserted.
- position = line + 1;
- }
-
- // Set the filename so it refers to the form being designed.
- file = viewContent.DesignerCodeFile.FileName;
-
- return true;
- }
-
- ///
- /// Returns a list of method names that could be used as an
- /// event handler with the specified event.
- ///
- public ICollection GetCompatibleMethods(EventDescriptor edesc)
- {
- // Get the form or user control class.
- ParseInformation parseInfo = ParseFile();
-
- // Look at the form's methods and see which are compatible.
- ArrayList methods = new ArrayList();
- IClass c = GetClass(parseInfo.CompilationUnit);
- foreach (IMethod method in c.Methods) {
- if (method.Parameters.Count == 2) {
- methods.Add(method.Name);
- }
- }
-
- return methods;
- }
-
- ///
- /// Gets the non-generated InitializeComponents from parse info.
- ///
- public static IMethod GetInitializeComponents(ParseInformation parseInfo)
- {
- return GetInitializeComponents(parseInfo.CompilationUnit);
- }
-
- ///
- /// Gets the non-generated InitializeComponents from the compilation unit.
- ///
- public static IMethod GetInitializeComponents(ICompilationUnit unit)
- {
- foreach (IClass c in unit.Classes) {
- if (FormsDesignerSecondaryDisplayBinding.BaseClassIsFormOrControl(c)) {
- IMethod method = FormsDesignerSecondaryDisplayBinding.GetInitializeComponents(c);
- if (method != null) {
- return method;
- }
- }
- }
- return null;
- }
-
- ///
- /// Converts from the DOM region to a document region.
- ///
- public static DomRegion GetBodyRegionInDocument(IMethod method)
- {
- DomRegion bodyRegion = method.BodyRegion;
- return new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine + 1, 1);
}
- ///
- /// Gets the view content attached to this generator.
- ///
- public FormsDesignerViewContent ViewContent {
- get { return viewContent; }
- }
-
- ///
- /// The default implementation calls the ParserService.ParseFile. This
- /// method is overridable so the class can be easily tested without
- /// the ParserService being required.
- ///
- protected virtual ParseInformation ParseFile(string fileName, string textContent)
+ public override IScriptingCodeDomSerializer CreateCodeDomSerializer(ITextEditorOptions options)
{
- return ParserService.ParseFile(fileName, new StringTextBuffer(textContent));
+ return new PythonCodeDomSerializer(options.IndentationString);
}
///
/// Returns the generated event handler.
///
- /// The indent string to use for the event handler.
- protected string CreateEventHandler(string eventMethodName, string body, string indentation)
+ public override string CreateEventHandler(string eventMethodName, string body, string indentation)
{
if (String.IsNullOrEmpty(body)) {
body = "pass";
@@ -230,71 +52,37 @@ namespace ICSharpCode.PythonBinding
eventHandler.Append("(self, sender, e):");
eventHandler.AppendLine();
eventHandler.Append(indentation);
- eventHandler.Append(textEditorOptions.IndentationString);
+ eventHandler.Append(TextEditorOptions.IndentationString);
eventHandler.Append(body);
return eventHandler.ToString();
}
-
- ///
- /// Gets the form or user control class from the compilation unit.
- ///
- IClass GetClass(ICompilationUnit unit)
- {
- return unit.Classes[0];
- }
-
- ///
- /// Gets the start offset of the region.
- ///
- static int GetStartOffset(IDocument document, DomRegion region)
- {
- return document.PositionToOffset(region.BeginLine, region.BeginColumn);
- }
-
- ///
- /// Gets the end offset of the region.
- ///
- static int GetEndOffset(IDocument document, DomRegion region)
- {
- if (region.EndLine > document.TotalNumberOfLines) {
- // At end of document.
- return document.TextLength;
- }
- return document.PositionToOffset(region.EndLine, region.EndColumn);
- }
-
- ///
- /// Checks if the event handler already exists.
- ///
- /// The line position of the first line of the existing event handler.
- int GetExistingEventHandler(string methodName)
- {
- ParseInformation parseInfo = ParseFile();
- IClass c = GetClass(parseInfo.CompilationUnit);
- foreach (IMethod method in c.Methods) {
- if ((method.Name == methodName) && (method.Parameters.Count == 2)) {
- return method.Region.BeginLine;
- }
- }
- return -1;
- }
-
+
///
- /// Parses the form or user control being designed.
+ /// Converts from the DOM region to a document region.
///
- ParseInformation ParseFile()
+ public override DomRegion GetBodyRegionInDocument(IMethod method)
{
- return ParseFile(this.ViewContent.DesignerCodeFile.FileName, this.ViewContent.DesignerCodeFileContent);
+ DomRegion bodyRegion = method.BodyRegion;
+ return new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine + 1, 1);
}
- static string GetProjectRootNamespace(ICompilationUnit compilationUnit)
+ public override int InsertEventHandler(IDocument document, string eventHandler)
{
- IProject project = compilationUnit.ProjectContent.Project as IProject;
- if (project != null) {
- return project.RootNamespace;
+ int line = document.TotalNumberOfLines;
+ IDocumentLine lastLineSegment = document.GetLine(line);
+ int offset = lastLineSegment.Offset + lastLineSegment.Length;
+
+ string newContent = "\r\n" + eventHandler;
+ if (lastLineSegment.Length > 0) {
+ // Add an extra new line between the last line and the event handler.
+ newContent = "\r\n" + newContent;
}
- return String.Empty;
+ document.Insert(offset, newContent);
+
+ // Set position so it points to the line
+ // where the event handler was inserted.
+ return line + 1;
}
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs
index 7f2876d2d8..24bdc641cf 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs
@@ -73,7 +73,8 @@ namespace PythonBinding.Tests.Designer
method.BodyRegion = bodyRegion;
DomRegion expectedRegion = new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine + 1, 1);
- Assert.AreEqual(expectedRegion, PythonDesignerGenerator.GetBodyRegionInDocument(method));
+ PythonDesignerGenerator generator = new PythonDesignerGenerator(new MockTextEditorOptions());
+ Assert.AreEqual(expectedRegion, generator.GetBodyRegionInDocument(method));
}
[Test]
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/MergeFormTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/MergeFormTestFixture.cs
index bd0a19f93a..e716aae309 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/MergeFormTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/MergeFormTestFixture.cs
@@ -60,7 +60,8 @@ namespace PythonBinding.Tests.Designer
using (serializationManager.CreateSession()) {
AvalonEditDocumentAdapter adapter = new AvalonEditDocumentAdapter(document, null);
MockTextEditorOptions options = new MockTextEditorOptions();
- PythonDesignerGenerator.Merge(host, adapter, compilationUnit, options, serializationManager);
+ PythonDesignerGenerator generator = new PythonDesignerGenerator(options);
+ generator.Merge(host, adapter, compilationUnit, serializationManager);
}
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/NoNewLineAfterInitializeComponentTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/NoNewLineAfterInitializeComponentTestFixture.cs
index 8837fe5e43..f5885c56ce 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/NoNewLineAfterInitializeComponentTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/NoNewLineAfterInitializeComponentTestFixture.cs
@@ -54,7 +54,8 @@ namespace PythonBinding.Tests.Designer
using (serializationManager.CreateSession()) {
AvalonEditDocumentAdapter adapter = new AvalonEditDocumentAdapter(document, null);
MockTextEditorOptions options = new MockTextEditorOptions();
- PythonDesignerGenerator.Merge(host, adapter, compilationUnit, options, serializationManager);
+ PythonDesignerGenerator generator = new PythonDesignerGenerator(options);
+ generator.Merge(host, adapter, compilationUnit, serializationManager);
}
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/ProjectRootNamespacePassedToMergeTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/ProjectRootNamespacePassedToMergeTestFixture.cs
index 0048918262..717bc66544 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/ProjectRootNamespacePassedToMergeTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/ProjectRootNamespacePassedToMergeTestFixture.cs
@@ -70,7 +70,8 @@ namespace PythonBinding.Tests.Designer
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
AvalonEditDocumentAdapter adapter = new AvalonEditDocumentAdapter(document, null);
- PythonDesignerGenerator.Merge(host, adapter, compilationUnit, options, serializationManager);
+ PythonDesignerGenerator generator = new PythonDesignerGenerator(options);
+ generator.Merge(host, adapter, compilationUnit, serializationManager);
}
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonGeneratorTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonGeneratorTestFixture.cs
index da56c8a167..b447cb5e30 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonGeneratorTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonGeneratorTestFixture.cs
@@ -7,8 +7,9 @@ using System.CodeDom.Compiler;
using System.ComponentModel;
using System.IO;
-using ICSharpCode.PythonBinding;
using ICSharpCode.FormsDesigner;
+using ICSharpCode.PythonBinding;
+using ICSharpCode.Scripting.Tests.Utils;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using NUnit.Framework;
@@ -29,7 +30,7 @@ namespace PythonBinding.Tests.Designer
DomRegion expectedRegion = new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine + 1, 1);
DerivedPythonDesignerGenerator generator = new DerivedPythonDesignerGenerator();
- Assert.AreEqual(expectedRegion, PythonDesignerGenerator.GetBodyRegionInDocument(method));
+ Assert.AreEqual(expectedRegion, generator.GetBodyRegionInDocument(method));
}
[Test]
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyCodeDomSerializer.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyCodeDomSerializer.cs
index 32432b3e57..8ffbbd4b02 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyCodeDomSerializer.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyCodeDomSerializer.cs
@@ -8,12 +8,14 @@ using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Text;
+using ICSharpCode.Scripting;
+
namespace ICSharpCode.RubyBinding
{
///
/// Used to generate Ruby code after the form has been changed in the designer.
///
- public class RubyCodeDomSerializer
+ public class RubyCodeDomSerializer : IScriptingCodeDomSerializer
{
RubyCodeBuilder codeBuilder;
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyDesignerGenerator.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyDesignerGenerator.cs
index 6f09f294b7..0844dda5b1 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyDesignerGenerator.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Project/Src/RubyDesignerGenerator.cs
@@ -23,205 +23,22 @@ namespace ICSharpCode.RubyBinding
///
/// Form's designer generator for the Ruby language.
///
- public class RubyDesignerGenerator : IScriptingDesignerGenerator
+ public class RubyDesignerGenerator : ScriptingDesignerGenerator
{
- FormsDesignerViewContent viewContent;
- ITextEditorOptions textEditorOptions;
-
public RubyDesignerGenerator(ITextEditorOptions textEditorOptions)
- {
- this.textEditorOptions = textEditorOptions;
- }
-
- ///
- /// Gets the Ruby code dom provider.
- ///
- public CodeDomProvider CodeDomProvider {
- get { return null; }
- }
-
- public void Attach(FormsDesignerViewContent viewContent)
- {
- this.viewContent = viewContent;
- }
-
- public void Detach()
- {
- this.viewContent = null;
- }
-
- public IEnumerable GetSourceFiles(out OpenedFile designerCodeFile)
- {
- designerCodeFile = this.ViewContent.PrimaryFile;
- return new [] {designerCodeFile};
- }
-
- public void MergeFormChanges(CodeCompileUnit unit)
+ : base(textEditorOptions)
{
}
- public void NotifyFormRenamed(string newName)
+ public override IScriptingCodeDomSerializer CreateCodeDomSerializer(ITextEditorOptions options)
{
- }
-
- ///
- /// Updates the InitializeComponent method's body with the generated code.
- ///
- public void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager)
- {
- ParseInformation parseInfo = ParseFile();
- Merge(host, ViewContent.DesignerCodeFileDocument, parseInfo.CompilationUnit, textEditorOptions, serializationManager);
- }
-
- ///
- /// Merges the generated code into the specified document.
- ///
- /// The designer host.
- /// The document that the generated code will be merged into.
- /// The current compilation unit for the .
- public static void Merge(IDesignerHost host, IDocument document, ICompilationUnit compilationUnit, ITextEditorOptions textEditorOptions, IDesignerSerializationManager serializationManager)
- {
- // Get the document's initialize components method.
- IMethod method = GetInitializeComponents(compilationUnit);
-
- // Generate the Ruby source code.
- RubyCodeDomSerializer serializer = new RubyCodeDomSerializer(textEditorOptions.IndentationString);
- int indent = method.Region.BeginColumn;
- if (textEditorOptions.ConvertTabsToSpaces) {
- indent = (indent / textEditorOptions.IndentationSize);
- if (textEditorOptions.IndentationSize > 1) {
- indent += 1;
- }
- }
- string rootNamespace = GetProjectRootNamespace(compilationUnit);
- string methodBody = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, rootNamespace, indent);
-
- // Merge the code.
- DomRegion methodRegion = GetBodyRegionInDocument(method);
- int startOffset = GetStartOffset(document, methodRegion);
- int endOffset = GetEndOffset(document, methodRegion);
-
- document.Replace(startOffset, endOffset - startOffset, methodBody);
- }
-
- ///
- /// Inserts an event handler.
- ///
- public bool InsertComponentEvent(IComponent component, EventDescriptor edesc, string eventMethodName, string body, out string file, out int position)
- {
- position = GetExistingEventHandler(eventMethodName);
- if (position == -1) {
- // Ensure the text editor has the latest version
- // of the source code before we insert any new code.
- viewContent.MergeFormChanges();
-
- // Insert the event handler at the end of the class with an extra
- // new line before it.
- IDocument doc = viewContent.DesignerCodeFileDocument;
- string eventHandler = CreateEventHandler(eventMethodName, body, textEditorOptions.IndentationString);
-
- IDocumentLine classEndLine = GetClassEndLine(doc);
- InsertEventHandlerBeforeLine(doc, eventHandler, classEndLine);
-
- // Set position so it points to the line
- // where the event handler was inserted.
- position = classEndLine.LineNumber;
- }
-
- // Set the filename so it refers to the form being designed.
- file = viewContent.DesignerCodeFile.FileName;
-
- return true;
- }
-
- IDocumentLine GetClassEndLine(IDocument doc)
- {
- int line = doc.TotalNumberOfLines;
- while (line > 0) {
- IDocumentLine documentLine = doc.GetLine(line);
- if (documentLine.Text.Trim() == "end") {
- return documentLine;
- }
- line--;
- }
- return doc.GetLine(doc.TotalNumberOfLines);
- }
-
- void InsertEventHandlerBeforeLine(IDocument doc, string eventHandler, IDocumentLine classEndLine)
- {
- string newContent = "\r\n" + eventHandler + "\r\n";
- int offset = classEndLine.Offset;
- doc.Insert(offset, newContent);
- }
-
- ///
- /// Returns a list of method names that could be used as an
- /// event handler with the specified event.
- ///
- public ICollection GetCompatibleMethods(EventDescriptor edesc)
- {
- // Get the form or user control class.
- ParseInformation parseInfo = ParseFile();
-
- // Look at the form's methods and see which are compatible.
- ArrayList methods = new ArrayList();
- IClass c = GetClass(parseInfo.CompilationUnit);
- foreach (IMethod method in c.Methods) {
- if (method.Parameters.Count == 2) {
- methods.Add(method.Name);
- }
- }
-
- return methods;
- }
-
- ///
- /// Gets the non-generated InitializeComponents from the compilation unit.
- ///
- public static IMethod GetInitializeComponents(ICompilationUnit unit)
- {
- foreach (IClass c in unit.Classes) {
- if (FormsDesignerSecondaryDisplayBinding.BaseClassIsFormOrControl(c)) {
- IMethod method = FormsDesignerSecondaryDisplayBinding.GetInitializeComponents(c);
- if (method != null) {
- return method;
- }
- }
- }
- return null;
- }
-
- ///
- /// Converts from the DOM region to a document region.
- ///
- public static DomRegion GetBodyRegionInDocument(IMethod method)
- {
- DomRegion bodyRegion = method.BodyRegion;
- return new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine, 1);
- }
-
- ///
- /// Gets the view content attached to this generator.
- ///
- public FormsDesignerViewContent ViewContent {
- get { return viewContent; }
- }
-
- ///
- /// The default implementation calls the ParserService.ParseFile. This
- /// method is overridable so the class can be easily tested without
- /// the ParserService being required.
- ///
- protected virtual ParseInformation ParseFile(string fileName, string textContent)
- {
- return ParserService.ParseFile(fileName, new StringTextBuffer(textContent));
+ return new RubyCodeDomSerializer(options.IndentationString);
}
///
/// Returns the generated event handler.
///
- /// The indent string to use for the event handler.
- protected string CreateEventHandler(string eventMethodName, string body, string indentation)
+ public override string CreateEventHandler(string eventMethodName, string body, string indentation)
{
if (String.IsNullOrEmpty(body)) {
body = String.Empty;
@@ -235,7 +52,7 @@ namespace ICSharpCode.RubyBinding
eventHandler.Append("(sender, e)");
eventHandler.AppendLine();
eventHandler.Append(indentation);
- eventHandler.Append(textEditorOptions.IndentationString);
+ eventHandler.Append(TextEditorOptions.IndentationString);
eventHandler.Append(body);
eventHandler.AppendLine();
eventHandler.Append(indentation);
@@ -245,64 +62,46 @@ namespace ICSharpCode.RubyBinding
}
///
- /// Gets the form or user control class from the compilation unit.
- ///
- IClass GetClass(ICompilationUnit unit)
- {
- return unit.Classes[0];
- }
-
- ///
- /// Gets the start offset of the region.
- ///
- static int GetStartOffset(IDocument document, DomRegion region)
- {
- return document.PositionToOffset(region.BeginLine, region.BeginColumn);
- }
-
- ///
- /// Gets the end offset of the region.
+ /// Insert the event handler at the end of the class with an extra
+ /// new line before it.
///
- static int GetEndOffset(IDocument document, DomRegion region)
+ public override int InsertEventHandler(IDocument document, string eventHandler)
{
- if (region.EndLine > document.TotalNumberOfLines) {
- // At end of document.
- return document.TextLength;
- }
- return document.PositionToOffset(region.EndLine, region.EndColumn);
+ IDocumentLine classEndLine = GetClassEndLine(document);
+ InsertEventHandlerBeforeLine(document, eventHandler, classEndLine);
+
+ // Set position so it points to the line
+ // where the event handler was inserted.
+ return classEndLine.LineNumber;
}
- ///
- /// Checks if the event handler already exists.
- ///
- /// The line position of the first line of the existing event handler.
- int GetExistingEventHandler(string methodName)
+ IDocumentLine GetClassEndLine(IDocument doc)
{
- ParseInformation parseInfo = ParseFile();
- IClass c = GetClass(parseInfo.CompilationUnit);
- foreach (IMethod method in c.Methods) {
- if ((method.Name == methodName) && (method.Parameters.Count == 2)) {
- return method.Region.BeginLine;
+ int line = doc.TotalNumberOfLines;
+ while (line > 0) {
+ IDocumentLine documentLine = doc.GetLine(line);
+ if (documentLine.Text.Trim() == "end") {
+ return documentLine;
}
+ line--;
}
- return -1;
+ return doc.GetLine(doc.TotalNumberOfLines);
}
- ///
- /// Parses the form or user control being designed.
- ///
- ParseInformation ParseFile()
+ void InsertEventHandlerBeforeLine(IDocument doc, string eventHandler, IDocumentLine classEndLine)
{
- return ParseFile(this.ViewContent.DesignerCodeFile.FileName, this.ViewContent.DesignerCodeFileContent);
+ string newContent = "\r\n" + eventHandler + "\r\n";
+ int offset = classEndLine.Offset;
+ doc.Insert(offset, newContent);
}
- static string GetProjectRootNamespace(ICompilationUnit compilationUnit)
+ ///
+ /// Converts from the DOM region to a document region.
+ ///
+ public override DomRegion GetBodyRegionInDocument(IMethod method)
{
- IProject project = compilationUnit.ProjectContent.Project as IProject;
- if (project != null) {
- return project.RootNamespace;
- }
- return String.Empty;
- }
+ DomRegion bodyRegion = method.BodyRegion;
+ return new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine, 1);
+ }
}
}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs
index db0b9b4c77..b19a7b92f3 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs
@@ -73,7 +73,7 @@ namespace RubyBinding.Tests.Designer
method.BodyRegion = bodyRegion;
DomRegion expectedRegion = new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine, 1);
- Assert.AreEqual(expectedRegion, RubyDesignerGenerator.GetBodyRegionInDocument(method));
+ Assert.AreEqual(expectedRegion, generator.GetBodyRegionInDocument(method));
}
[Test]
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/MergeFormTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/MergeFormTestFixture.cs
index becd3fb6c4..2e489d023c 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/MergeFormTestFixture.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/MergeFormTestFixture.cs
@@ -58,7 +58,8 @@ namespace RubyBinding.Tests.Designer
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
- RubyDesignerGenerator.Merge(host, new AvalonEditDocumentAdapter(document, null), compilationUnit, new MockTextEditorOptions(), serializationManager);
+ RubyDesignerGenerator generator = new RubyDesignerGenerator(new MockTextEditorOptions());
+ generator.Merge(host, new AvalonEditDocumentAdapter(document, null), compilationUnit, serializationManager);
}
}
}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/NoNewLineAfterInitializeComponentMethodTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/NoNewLineAfterInitializeComponentMethodTestFixture.cs
index 13961f7bef..e01d051491 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/NoNewLineAfterInitializeComponentMethodTestFixture.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/NoNewLineAfterInitializeComponentMethodTestFixture.cs
@@ -53,7 +53,8 @@ namespace RubyBinding.Tests.Designer
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
AvalonEditDocumentAdapter docAdapter = new AvalonEditDocumentAdapter(document, null);
- RubyDesignerGenerator.Merge(host, docAdapter, compilationUnit, new MockTextEditorOptions(), serializationManager);
+ RubyDesignerGenerator generator = new RubyDesignerGenerator(new MockTextEditorOptions());
+ generator.Merge(host, docAdapter, compilationUnit, serializationManager);
}
}
}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/ProjectRootNamespacePassedToMergeTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/ProjectRootNamespacePassedToMergeTestFixture.cs
index 44dabd61aa..a7a688c59d 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/ProjectRootNamespacePassedToMergeTestFixture.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/ProjectRootNamespacePassedToMergeTestFixture.cs
@@ -70,7 +70,8 @@ namespace RubyBinding.Tests.Designer
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
using (serializationManager.CreateSession()) {
AvalonEditDocumentAdapter docAdapter = new AvalonEditDocumentAdapter(document, null);
- RubyDesignerGenerator.Merge(host, docAdapter, compilationUnit, options, serializationManager);
+ RubyDesignerGenerator generator = new RubyDesignerGenerator(options);
+ generator.Merge(host, docAdapter, compilationUnit, serializationManager);
}
}
}
diff --git a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/RubyDesignerGeneratorTestFixture.cs b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/RubyDesignerGeneratorTestFixture.cs
index 6402ef24bf..6f933cddca 100644
--- a/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/RubyDesignerGeneratorTestFixture.cs
+++ b/src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/RubyDesignerGeneratorTestFixture.cs
@@ -29,7 +29,7 @@ namespace RubyBinding.Tests.Designer
DomRegion expectedRegion = new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine, 1);
DerivedRubyDesignerGenerator generator = new DerivedRubyDesignerGenerator();
- Assert.AreEqual(expectedRegion, RubyDesignerGenerator.GetBodyRegionInDocument(method));
+ Assert.AreEqual(expectedRegion, generator.GetBodyRegionInDocument(method));
}
[Test]
diff --git a/src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj b/src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj
index 270ca4d83f..5e4ebb7ca5 100644
--- a/src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj
+++ b/src/AddIns/BackendBindings/Scripting/Project/ICSharpCode.Scripting.csproj
@@ -71,6 +71,7 @@
+
@@ -83,6 +84,7 @@
+
@@ -107,6 +109,11 @@
ICSharpCode.Core
False
+
+ {924EE450-603D-49C1-A8E5-4AFAA31CE6F3}
+ ICSharpCode.SharpDevelop.Dom
+ False
+
{1F261725-6318-4434-A1B1-6C70CE4CD324}
UnitTesting
diff --git a/src/AddIns/BackendBindings/Scripting/Project/Src/IScriptingCodeDomSerializer.cs b/src/AddIns/BackendBindings/Scripting/Project/Src/IScriptingCodeDomSerializer.cs
new file mode 100644
index 0000000000..7a075fc974
--- /dev/null
+++ b/src/AddIns/BackendBindings/Scripting/Project/Src/IScriptingCodeDomSerializer.cs
@@ -0,0 +1,18 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.ComponentModel.Design;
+using System.ComponentModel.Design.Serialization;
+
+namespace ICSharpCode.Scripting
+{
+ public interface IScriptingCodeDomSerializer
+ {
+ string GenerateInitializeComponentMethodBody(IDesignerHost host, IDesignerSerializationManager serializationManager, string rootNamespace, int initialIndent);
+ }
+}
diff --git a/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingDesignerGenerator.cs b/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingDesignerGenerator.cs
new file mode 100644
index 0000000000..416e00568e
--- /dev/null
+++ b/src/AddIns/BackendBindings/Scripting/Project/Src/ScriptingDesignerGenerator.cs
@@ -0,0 +1,276 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.CodeDom;
+using System.CodeDom.Compiler;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.ComponentModel.Design.Serialization;
+
+using ICSharpCode.FormsDesigner;
+using ICSharpCode.SharpDevelop;
+using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.SharpDevelop.Editor;
+using ICSharpCode.SharpDevelop.Project;
+
+namespace ICSharpCode.Scripting
+{
+ public abstract class ScriptingDesignerGenerator : IScriptingDesignerGenerator
+ {
+ FormsDesignerViewContent viewContent;
+ ITextEditorOptions textEditorOptions;
+
+ public ITextEditorOptions TextEditorOptions {
+ get { return textEditorOptions; }
+ }
+
+ public ScriptingDesignerGenerator(ITextEditorOptions textEditorOptions)
+ {
+ this.textEditorOptions = textEditorOptions;
+ }
+
+ public CodeDomProvider CodeDomProvider {
+ get { return null; }
+ }
+
+ public FormsDesignerViewContent ViewContent {
+ get { return viewContent; }
+ }
+
+ public void Attach(FormsDesignerViewContent viewContent)
+ {
+ this.viewContent = viewContent;
+ }
+
+ public void Detach()
+ {
+ this.viewContent = null;
+ }
+
+ public IEnumerable GetSourceFiles(out OpenedFile designerCodeFile)
+ {
+ designerCodeFile = viewContent.PrimaryFile;
+ return new [] {designerCodeFile};
+ }
+
+ public void MergeFormChanges(CodeCompileUnit unit)
+ {
+ }
+
+ ///
+ /// Returns a list of method names that could be used as an
+ /// event handler with the specified event.
+ ///
+ public ICollection GetCompatibleMethods(EventDescriptor edesc)
+ {
+ // Get the form or user control class.
+ ParseInformation parseInfo = ParseFile();
+
+ // Look at the form's methods and see which are compatible.
+ ArrayList methods = new ArrayList();
+ IClass c = GetClass(parseInfo.CompilationUnit);
+ foreach (IMethod method in c.Methods) {
+ if (method.Parameters.Count == 2) {
+ methods.Add(method.Name);
+ }
+ }
+
+ return methods;
+ }
+
+ public void NotifyFormRenamed(string newName)
+ {
+ }
+
+ ///
+ /// Updates the InitializeComponent method's body with the generated code.
+ ///
+ public void MergeRootComponentChanges(IDesignerHost host, IDesignerSerializationManager serializationManager)
+ {
+ ParseInformation parseInfo = ParseFile();
+ Merge(host, ViewContent.DesignerCodeFileDocument, parseInfo.CompilationUnit, serializationManager);
+ }
+
+ ///
+ /// The default implementation calls the ParserService.ParseFile. This
+ /// method is overridable so the class can be easily tested without
+ /// the ParserService being required.
+ ///
+ protected virtual ParseInformation ParseFile(string fileName, string textContent)
+ {
+ return ParserService.ParseFile(fileName, new StringTextBuffer(textContent));
+ }
+
+ ///
+ /// Merges the generated code into the specified document.
+ ///
+ /// The designer host.
+ /// The document that the generated code will be merged into.
+ /// The current compilation unit for the .
+ public void Merge(IDesignerHost host, IDocument document, ICompilationUnit compilationUnit, IDesignerSerializationManager serializationManager)
+ {
+ IMethod method = GetInitializeComponents(compilationUnit);
+
+ // Generate the python source code.
+ IScriptingCodeDomSerializer serializer = CreateCodeDomSerializer(TextEditorOptions);
+ int indent = GetIndent(method);
+ string rootNamespace = GetProjectRootNamespace(compilationUnit);
+ string methodBody = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, rootNamespace, indent);
+
+ // Merge the code.
+ DomRegion methodRegion = GetBodyRegionInDocument(method);
+ int startOffset = GetStartOffset(document, methodRegion);
+ int endOffset = GetEndOffset(document, methodRegion);
+
+ document.Replace(startOffset, endOffset - startOffset, methodBody);
+ }
+
+ public virtual IScriptingCodeDomSerializer CreateCodeDomSerializer(ITextEditorOptions options)
+ {
+ return null;
+ }
+
+ public int GetIndent(IMethod method)
+ {
+ int indent = method.Region.BeginColumn;
+ if (textEditorOptions.ConvertTabsToSpaces) {
+ indent = (indent / textEditorOptions.IndentationSize);
+ if (textEditorOptions.IndentationSize > 1) {
+ indent += 1;
+ }
+ }
+ return indent;
+ }
+
+ public virtual DomRegion GetBodyRegionInDocument(IMethod method)
+ {
+ return DomRegion.Empty;
+ }
+
+ ///
+ /// Gets the non-generated InitializeComponents from parse info.
+ ///
+ public static IMethod GetInitializeComponents(ParseInformation parseInfo)
+ {
+ return GetInitializeComponents(parseInfo.CompilationUnit);
+ }
+
+ ///
+ /// Gets the non-generated InitializeComponents from the compilation unit.
+ ///
+ public static IMethod GetInitializeComponents(ICompilationUnit unit)
+ {
+ foreach (IClass c in unit.Classes) {
+ if (FormsDesignerSecondaryDisplayBinding.BaseClassIsFormOrControl(c)) {
+ IMethod method = FormsDesignerSecondaryDisplayBinding.GetInitializeComponents(c);
+ if (method != null) {
+ return method;
+ }
+ }
+ }
+ return null;
+ }
+
+ ///
+ /// Gets the form or user control class from the compilation unit.
+ ///
+ IClass GetClass(ICompilationUnit unit)
+ {
+ return unit.Classes[0];
+ }
+
+ ///
+ /// Gets the start offset of the region.
+ ///
+ static int GetStartOffset(IDocument document, DomRegion region)
+ {
+ return document.PositionToOffset(region.BeginLine, region.BeginColumn);
+ }
+
+ ///
+ /// Gets the end offset of the region.
+ ///
+ static int GetEndOffset(IDocument document, DomRegion region)
+ {
+ if (region.EndLine > document.TotalNumberOfLines) {
+ // At end of document.
+ return document.TextLength;
+ }
+ return document.PositionToOffset(region.EndLine, region.EndColumn);
+ }
+
+ ///
+ /// Inserts an event handler.
+ ///
+ public bool InsertComponentEvent(IComponent component, EventDescriptor edesc, string eventMethodName, string body, out string file, out int position)
+ {
+ position = GetExistingEventHandler(eventMethodName);
+ if (position == -1) {
+ // Ensure the text editor has the latest version
+ // of the source code before we insert any new code.
+ viewContent.MergeFormChanges();
+
+ // Insert the event handler at the end of the class with an extra
+ // new line before it.
+ IDocument doc = ViewContent.DesignerCodeFileDocument;
+ string eventHandler = CreateEventHandler(eventMethodName, body, TextEditorOptions.IndentationString);
+ position = InsertEventHandler(doc, eventHandler);
+ }
+
+ // Set the filename so it refers to the form being designed.
+ file = ViewContent.DesignerCodeFile.FileName;
+
+ return true;
+ }
+
+ ///
+ /// Checks if the event handler already exists.
+ ///
+ /// The line position of the first line of the existing event handler.
+ int GetExistingEventHandler(string methodName)
+ {
+ ParseInformation parseInfo = ParseFile();
+ IClass c = GetClass(parseInfo.CompilationUnit);
+ foreach (IMethod method in c.Methods) {
+ if ((method.Name == methodName) && (method.Parameters.Count == 2)) {
+ return method.Region.BeginLine;
+ }
+ }
+ return -1;
+ }
+
+ public virtual string CreateEventHandler(string eventMethodName, string body, string indentation)
+ {
+ return String.Empty;
+ }
+
+ public virtual int InsertEventHandler(IDocument document, string eventHandler)
+ {
+ return 0;
+ }
+
+ ///
+ /// Parses the form or user control being designed.
+ ///
+ ParseInformation ParseFile()
+ {
+ return ParseFile(this.ViewContent.DesignerCodeFile.FileName, this.ViewContent.DesignerCodeFileContent);
+ }
+
+ string GetProjectRootNamespace(ICompilationUnit compilationUnit)
+ {
+ IProject project = compilationUnit.ProjectContent.Project as IProject;
+ if (project != null) {
+ return project.RootNamespace;
+ }
+ return String.Empty;
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Scripting/Test/Designer/ScriptingDesignerGeneratorTests.cs b/src/AddIns/BackendBindings/Scripting/Test/Designer/ScriptingDesignerGeneratorTests.cs
new file mode 100644
index 0000000000..e7b36ab55a
--- /dev/null
+++ b/src/AddIns/BackendBindings/Scripting/Test/Designer/ScriptingDesignerGeneratorTests.cs
@@ -0,0 +1,90 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Collections.Generic;
+using ICSharpCode.FormsDesigner;
+using ICSharpCode.Scripting;
+using ICSharpCode.Scripting.Tests.Utils;
+using ICSharpCode.SharpDevelop;
+using NUnit.Framework;
+
+namespace ICSharpCode.Scripting.Tests.Designer
+{
+ [TestFixture]
+ [RequiresSTA]
+ public class ScriptingDesignerGeneratorTests
+ {
+ MockTextEditorOptions textEditorOptions;
+ TestableScriptingDesignerGenerator generator;
+ FormsDesignerViewContent formsDesignerView;
+ MockTextEditorViewContent textEditorViewContent;
+ MockOpenedFile formsDesignerOpenedFile;
+
+ [Test]
+ public void GetSourceFiles_FormDesignerViewHasOpenFile_ReturnsOneFile()
+ {
+ CreateDesignerGenerator();
+ OpenedFile designerOpenedFile;
+ IEnumerable files = generator.GetSourceFiles(out designerOpenedFile);
+ int count = HowManyInCollection(files);
+
+ Assert.AreEqual(1, count);
+ }
+
+ void CreateDesignerGenerator()
+ {
+ textEditorViewContent = new MockTextEditorViewContent();
+ formsDesignerOpenedFile = new MockOpenedFile("test.py");
+ textEditorViewContent.PrimaryFile = formsDesignerOpenedFile;
+ formsDesignerView = new FormsDesignerViewContent(textEditorViewContent, formsDesignerOpenedFile);
+ textEditorOptions = new MockTextEditorOptions();
+ generator = new TestableScriptingDesignerGenerator(textEditorOptions);
+ generator.Attach(formsDesignerView);
+ }
+
+ int HowManyInCollection(IEnumerable files)
+ {
+ int count = 0;
+ foreach (OpenedFile file in files) {
+ count++;
+ }
+ return count;
+ }
+
+ [Test]
+ public void GetSourceFiles_FormsDesignerHasOpenFile_DesignerOpenedFileParameterIsSetToFormsDesignerViewOpenedFile()
+ {
+ CreateDesignerGenerator();
+ OpenedFile designerOpenedFile;
+ generator.GetSourceFiles(out designerOpenedFile);
+
+ AssertAreEqual(formsDesignerOpenedFile, designerOpenedFile);
+ }
+
+ void AssertAreEqual(OpenedFile expectedOpenedFile, OpenedFile actualOpenedFile)
+ {
+ string fileName = actualOpenedFile.FileName.ToString();
+ string expectedFileName = expectedOpenedFile.FileName.ToString();
+
+ Assert.AreEqual(expectedFileName, fileName);
+ }
+
+ [Test]
+ public void GetSourceFiles_FormsDesignerHasOpenFile_FormsDesignerFileReturnedInFiles()
+ {
+ CreateDesignerGenerator();
+ OpenedFile designerOpenedFile;
+ IEnumerable files = generator.GetSourceFiles(out designerOpenedFile);
+ IEnumerator enumerator = files.GetEnumerator();
+ enumerator.MoveNext();
+ OpenedFile file = enumerator.Current;
+
+ AssertAreEqual(formsDesignerOpenedFile, file);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj b/src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj
index 60b3ba0682..821df83df0 100644
--- a/src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj
+++ b/src/AddIns/BackendBindings/Scripting/Test/ICSharpCode.Scripting.Tests.csproj
@@ -77,6 +77,7 @@
+
@@ -132,6 +133,7 @@
+
diff --git a/src/AddIns/BackendBindings/Scripting/Test/Utils/MockViewContent.cs b/src/AddIns/BackendBindings/Scripting/Test/Utils/MockViewContent.cs
index bc7be618a6..20093fa21e 100644
--- a/src/AddIns/BackendBindings/Scripting/Test/Utils/MockViewContent.cs
+++ b/src/AddIns/BackendBindings/Scripting/Test/Utils/MockViewContent.cs
@@ -13,6 +13,7 @@ namespace ICSharpCode.Scripting.Tests.Utils
{
public class MockViewContent : IViewContent
{
+ OpenedFile primaryFile = new MockOpenedFile();
FileName fileName;
List secondaryViewContents = new List();
@@ -143,11 +144,8 @@ namespace ICSharpCode.Scripting.Tests.Utils
}
public OpenedFile PrimaryFile {
- get {
- MockOpenedFile file = new MockOpenedFile();
- //file.FileName = fileName;
- return file;
- }
+ get { return primaryFile; }
+ set { primaryFile = value; }
}
public FileName PrimaryFileName {
diff --git a/src/AddIns/BackendBindings/Scripting/Test/Utils/TestableScriptingDesignerGenerator.cs b/src/AddIns/BackendBindings/Scripting/Test/Utils/TestableScriptingDesignerGenerator.cs
new file mode 100644
index 0000000000..e51d94c27d
--- /dev/null
+++ b/src/AddIns/BackendBindings/Scripting/Test/Utils/TestableScriptingDesignerGenerator.cs
@@ -0,0 +1,20 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using ICSharpCode.SharpDevelop.Editor;
+
+namespace ICSharpCode.Scripting.Tests.Utils
+{
+ public class TestableScriptingDesignerGenerator : ScriptingDesignerGenerator
+ {
+ public TestableScriptingDesignerGenerator(ITextEditorOptions textEditorOptions)
+ : base(textEditorOptions)
+ {
+ }
+ }
+}