protected override void Run(RefactoringOptions options) { ExtractMethodRefactoring extractMethodRefactoring = new ExtractMethodRefactoring(); if (extractMethodRefactoring.IsValid(options)) { extractMethodRefactoring.Run(options); } }
public ExtractMethodDialog (RefactoringOptions options, ExtractMethodRefactoring extractMethod, ExtractMethodRefactoring.ExtractMethodParameters properties) { this.Build (); this.options = options; this.properties = properties; this.extractMethod = extractMethod; store = new ListStore (typeof (string), typeof (string)); treeviewParameters.Model = store; treeviewParameters.AppendColumn ("Type", new CellRendererText (), "text", 0); treeviewParameters.AppendColumn ("Name", new CellRendererText (), "text", 1); FillStore (); buttonPreview.Sensitive = buttonOk.Sensitive = false; entry.Changed += delegate { buttonPreview.Sensitive = buttonOk.Sensitive = ValidateName (); }; ValidateName (); buttonOk.Clicked += OnOKClicked; buttonCancel.Clicked += OnCancelClicked; buttonPreview.Clicked += OnPreviewClicked; buttonUp.Clicked += delegate { List<int> indices = new List<int> (); foreach (TreePath path in treeviewParameters.Selection.GetSelectedRows ()) { int index = Int32.Parse (path.ToString ()); if (index > 0) { VariableDescriptor tmp = properties.Parameters [index - 1]; properties.Parameters [index - 1] = properties.Parameters [index]; properties.Parameters [index] = tmp; indices.Add (index - 1); } } FillStore (); treeviewParameters.Selection.SelectPath (new TreePath (indices.ToArray ())); }; buttonDown.Clicked += delegate { List<int> indices = new List<int> (); foreach (TreePath path in treeviewParameters.Selection.GetSelectedRows ()) { int index = Int32.Parse (path.ToString ()); if (index + 1 < properties.Parameters.Count) { VariableDescriptor tmp = properties.Parameters [index + 1]; properties.Parameters [index + 1] = properties.Parameters [index]; properties.Parameters [index] = tmp; indices.Add (index + 1); } } FillStore (); treeviewParameters.Selection.SelectPath (new TreePath (indices.ToArray ())); }; ListStore modifiers = new ListStore (typeof (string)); modifiers.AppendValues (""); modifiers.AppendValues ("public"); modifiers.AppendValues ("private"); modifiers.AppendValues ("protected"); modifiers.AppendValues ("internal"); comboboxModifiers.Model = modifiers; comboboxModifiers.Active = PropertyService.Get<int> ("MonoDevelop.Refactoring.ExtractMethod.ExtractMethodDialog.DefaultModifier"); entry.Activated += delegate { if (buttonOk.Sensitive) buttonOk.Click (); }; }
void TestExtractMethod (string inputString, string outputString) { ExtractMethodRefactoring refactoring = new ExtractMethodRefactoring (); RefactoringOptions options = CreateRefactoringOptions (inputString); ExtractMethodRefactoring.ExtractMethodParameters parameters = refactoring.CreateParameters (options); Assert.IsNotNull (parameters); parameters.Name = "NewMethod"; parameters.InsertionPoint = new Mono.TextEditor.InsertionPoint (new DocumentLocation (options.ResolveResult.CallingMember.BodyRegion.End.Line + 1, 1), NewLineInsertion.BlankLine, NewLineInsertion.None); List<Change> changes = refactoring.PerformChanges (options, parameters); string output = GetOutput (options, changes); Assert.IsTrue (CompareSource (output, outputString), "Expected:" + Environment.NewLine + outputString + Environment.NewLine + "was:" + Environment.NewLine + output); }
protected override void Run (RefactoringOptions options) { ExtractMethodRefactoring extractMethodRefactoring = new ExtractMethodRefactoring (); if (extractMethodRefactoring.IsValid (options)) extractMethodRefactoring.Run (options); }
public ExtractMethodDialog(RefactoringOptions options, ExtractMethodRefactoring extractMethod, ExtractMethodRefactoring.ExtractMethodParameters properties) { this.Build(); this.options = options; this.properties = properties; this.extractMethod = extractMethod; store = new ListStore(typeof(string), typeof(string)); treeviewParameters.Model = store; treeviewParameters.AppendColumn("Type", new CellRendererText(), "text", 0); treeviewParameters.AppendColumn("Name", new CellRendererText(), "text", 1); FillStore(); buttonPreview.Sensitive = buttonOk.Sensitive = false; entry.Changed += delegate { buttonPreview.Sensitive = buttonOk.Sensitive = ValidateName(); }; ValidateName(); buttonOk.Clicked += OnOKClicked; buttonCancel.Clicked += OnCancelClicked; buttonPreview.Clicked += OnPreviewClicked; buttonUp.Clicked += delegate { List <int> indices = new List <int> (); foreach (TreePath path in treeviewParameters.Selection.GetSelectedRows()) { int index = Int32.Parse(path.ToString()); if (index > 0) { VariableDescriptor tmp = properties.Parameters [index - 1]; properties.Parameters [index - 1] = properties.Parameters [index]; properties.Parameters [index] = tmp; indices.Add(index - 1); } } FillStore(); treeviewParameters.Selection.SelectPath(new TreePath(indices.ToArray())); }; buttonDown.Clicked += delegate { List <int> indices = new List <int> (); foreach (TreePath path in treeviewParameters.Selection.GetSelectedRows()) { int index = Int32.Parse(path.ToString()); if (index + 1 < properties.Parameters.Count) { VariableDescriptor tmp = properties.Parameters [index + 1]; properties.Parameters [index + 1] = properties.Parameters [index]; properties.Parameters [index] = tmp; indices.Add(index + 1); } } FillStore(); treeviewParameters.Selection.SelectPath(new TreePath(indices.ToArray())); }; ListStore modifiers = new ListStore(typeof(string)); modifiers.AppendValues(""); modifiers.AppendValues("public"); modifiers.AppendValues("private"); modifiers.AppendValues("protected"); modifiers.AppendValues("internal"); comboboxModifiers.Model = modifiers; comboboxModifiers.Active = PropertyService.Get <int> ("MonoDevelop.Refactoring.ExtractMethod.ExtractMethodDialog.DefaultModifier"); entry.Activated += delegate { if (buttonOk.Sensitive) { buttonOk.Click(); } }; }