Browse Source

Fixed SD2-847. Generating VB.NET code for an overridden method inside a My class (e.g. MyApplication) would throw an ArgumentOutOfRangeException. Changed the CodeGenerateBase class to use the class selected in the text editor and not the compound class when inserting generated code.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.1@2278 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 19 years ago
parent
commit
b7d71e00d0
  1. 14
      src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/CodeGeneratorBase.cs

14
src/Main/Base/Project/Src/TextEditor/Commands/CodeGenerators/CodeGeneratorBase.cs

@ -20,12 +20,22 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -20,12 +20,22 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
public abstract class CodeGeneratorBase
{
ArrayList content = new ArrayList();
protected IClass currentClass;
protected ICSharpCode.SharpDevelop.Dom.Refactoring.CodeGenerator codeGen;
protected ClassFinder classFinderContext;
// This is the compound class created from the class selected
// when the code generator was created.
protected IClass currentClass;
// This is class that was selected when the code generator was
// created and will be the class that the generated code is inserted
// into.
IClass selectedClass;
public void Initialize(IClass currentClass)
{
selectedClass = currentClass;
this.currentClass = currentClass.GetCompoundClass();
this.codeGen = currentClass.ProjectContent.Language.CodeGenerator;
this.classFinderContext = new ClassFinder(currentClass, currentClass.Region.BeginLine + 1, 0);
@ -71,7 +81,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands @@ -71,7 +81,7 @@ namespace ICSharpCode.SharpDevelop.DefaultEditor.Commands
{
List<AbstractNode> nodes = new List<AbstractNode>();
GenerateCode(nodes, items);
codeGen.InsertCodeInClass(currentClass, new TextEditorDocument(textArea.Document), textArea.Caret.Line, nodes.ToArray());
codeGen.InsertCodeInClass(selectedClass, new TextEditorDocument(textArea.Document), textArea.Caret.Line, nodes.ToArray());
ParserService.ParseCurrentViewContent();
}

Loading…
Cancel
Save