Browse Source

added InsertionContext for OverrideEqualsGetHashCodeMethodsDialog and OverrideToStringMethodDialog to make Enter and Escape working properly

pull/1/head
Siegfried Pammer 15 years ago
parent
commit
d065280fa6
  1. 10
      src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideEqualsGetHashCodeMethodsDialog.xaml.cs
  2. 10
      src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml.cs
  3. 11
      src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideEqualsGetHashCodeMethodsRefactoring.cs
  4. 12
      src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideToStringMethodRefactoring.cs

10
src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideEqualsGetHashCodeMethodsDialog.xaml.cs

@ -6,6 +6,7 @@ using System.Collections.Generic; @@ -6,6 +6,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.AvalonEdit.Snippets;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.SharpDevelop.Dom;
@ -25,9 +26,9 @@ namespace SharpRefactoring.Gui @@ -25,9 +26,9 @@ namespace SharpRefactoring.Gui
IMethod selectedMethod;
string baseCall;
public OverrideEqualsGetHashCodeMethodsDialog(ITextEditor editor, ITextAnchor startAnchor, ITextAnchor endAnchor,
public OverrideEqualsGetHashCodeMethodsDialog(InsertionContext context, ITextEditor editor, ITextAnchor startAnchor, ITextAnchor endAnchor,
ITextAnchor insertionPosition, IClass selectedClass, IMethod selectedMethod, string baseCall)
: base(null, editor, insertionPosition)
: base(context, editor, insertionPosition)
{
if (selectedClass == null)
throw new ArgumentNullException("selectedClass");
@ -60,6 +61,11 @@ namespace SharpRefactoring.Gui @@ -60,6 +61,11 @@ namespace SharpRefactoring.Gui
);
}
protected override void OnInsertionCompleted()
{
base.OnInsertionCompleted();
}
static int[] largePrimes = {
1000000007, 1000000009, 1000000021, 1000000033,
1000000087, 1000000093, 1000000097, 1000000103,

10
src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml.cs

@ -5,19 +5,13 @@ using System; @@ -5,19 +5,13 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.AvalonEdit.Snippets;
using Ast = ICSharpCode.NRefactory.Ast;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.Refactoring;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using Ast = ICSharpCode.NRefactory.Ast;
namespace SharpRefactoring.Gui
{
@ -28,7 +22,7 @@ namespace SharpRefactoring.Gui @@ -28,7 +22,7 @@ namespace SharpRefactoring.Gui
{
List<Wrapper<IField>> fields;
public OverrideToStringMethodDialog(InsertionContext context, ITextEditor editor, ITextAnchor anchor, IList<IField> fields)
public OverrideToStringMethodDialog(InsertionContext context, ITextEditor editor, ITextAnchor startAnchor, ITextAnchor anchor, IList<IField> fields)
: base(context, editor, anchor)
{
InitializeComponent();

11
src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideEqualsGetHashCodeMethodsRefactoring.cs

@ -3,14 +3,14 @@ @@ -3,14 +3,14 @@
using System;
using System.Linq;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Snippets;
using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.PrettyPrinter;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.Refactoring;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.SharpDevelop.Refactoring;
using SharpRefactoring.Gui;
namespace SharpRefactoring
@ -68,10 +68,15 @@ namespace SharpRefactoring @@ -68,10 +68,15 @@ namespace SharpRefactoring
ITextAnchor insertionPos = textEditor.Document.CreateAnchor(anchor.Offset);
insertionPos.MovementType = AnchorMovementType.BeforeInsertion;
AbstractInlineRefactorDialog dialog = new OverrideEqualsGetHashCodeMethodsDialog(textEditor, start, anchor, insertionPos, current, completionItem.Member as IMethod, codeForBaseCall.Trim());
InsertionContext insertionContext = new InsertionContext(textEditor.GetService(typeof(TextArea)) as TextArea, start.Offset);
AbstractInlineRefactorDialog dialog = new OverrideEqualsGetHashCodeMethodsDialog(insertionContext, textEditor, start, anchor, insertionPos, current, completionItem.Member as IMethod, codeForBaseCall.Trim());
dialog.Element = uiService.CreateInlineUIElement(insertionPos, dialog);
textEditor.Document.InsertNormalized(anchor.Offset, Environment.NewLine + code.Substring(marker + codeForBaseCall.Length));
insertionContext.RegisterActiveElement(new InlineRefactorSnippetElement(cxt => null, ""), dialog);
insertionContext.RaiseInsertionCompleted(EventArgs.Empty);
}
public bool Handles(ICompletionItem item)

12
src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideToStringMethodRefactoring.cs

@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.AvalonEdit.Editing;
using ICSharpCode.AvalonEdit.Snippets;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Dom.Refactoring;
@ -36,9 +38,17 @@ namespace SharpRefactoring @@ -36,9 +38,17 @@ namespace SharpRefactoring
ITextAnchor anchor = textEditor.Document.CreateAnchor(textEditor.Caret.Offset);
anchor.MovementType = AnchorMovementType.AfterInsertion;
AbstractInlineRefactorDialog dialog = new OverrideToStringMethodDialog(null, textEditor, anchor, current.Fields);
ITextAnchor startAnchor = textEditor.Document.CreateAnchor(textEditor.Caret.Offset);
anchor.MovementType = AnchorMovementType.BeforeInsertion;
InsertionContext insertionContext = new InsertionContext(textEditor.GetService(typeof(TextArea)) as TextArea, startAnchor.Offset);
AbstractInlineRefactorDialog dialog = new OverrideToStringMethodDialog(insertionContext, textEditor, startAnchor, anchor, current.Fields);
dialog.Element = uiService.CreateInlineUIElement(anchor, dialog);
insertionContext.RegisterActiveElement(new InlineRefactorSnippetElement(cxt => null, ""), dialog);
insertionContext.RaiseInsertionCompleted(EventArgs.Empty);
}
public bool Handles(ICompletionItem item)

Loading…
Cancel
Save