diff --git a/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideEqualsGetHashCodeMethodsDialog.xaml.cs b/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideEqualsGetHashCodeMethodsDialog.xaml.cs index d87b172b9e..dec801def6 100644 --- a/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideEqualsGetHashCodeMethodsDialog.xaml.cs +++ b/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideEqualsGetHashCodeMethodsDialog.xaml.cs @@ -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 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 ); } + protected override void OnInsertionCompleted() + { + base.OnInsertionCompleted(); + } + static int[] largePrimes = { 1000000007, 1000000009, 1000000021, 1000000033, 1000000087, 1000000093, 1000000097, 1000000103, diff --git a/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml.cs b/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml.cs index bf346df685..0cc21cc046 100644 --- a/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml.cs +++ b/src/AddIns/Misc/SharpRefactoring/Project/Src/Gui/OverrideToStringMethodDialog.xaml.cs @@ -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 { List> fields; - public OverrideToStringMethodDialog(InsertionContext context, ITextEditor editor, ITextAnchor anchor, IList fields) + public OverrideToStringMethodDialog(InsertionContext context, ITextEditor editor, ITextAnchor startAnchor, ITextAnchor anchor, IList fields) : base(context, editor, anchor) { InitializeComponent(); diff --git a/src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideEqualsGetHashCodeMethodsRefactoring.cs b/src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideEqualsGetHashCodeMethodsRefactoring.cs index 47f88036ef..1f3d5358ec 100644 --- a/src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideEqualsGetHashCodeMethodsRefactoring.cs +++ b/src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideEqualsGetHashCodeMethodsRefactoring.cs @@ -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 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) diff --git a/src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideToStringMethodRefactoring.cs b/src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideToStringMethodRefactoring.cs index 9b14fb55ed..ce44657c20 100644 --- a/src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideToStringMethodRefactoring.cs +++ b/src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideToStringMethodRefactoring.cs @@ -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 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)