From bb49c4e357bf7e127735d769a22c44082af35518 Mon Sep 17 00:00:00 2001 From: Hosch250 Date: Sun, 28 Jun 2015 23:22:28 -0500 Subject: [PATCH] Fix rename bug --- RetailCoder.VBE/Refactorings/Rename/RenamePresenter.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/RetailCoder.VBE/Refactorings/Rename/RenamePresenter.cs b/RetailCoder.VBE/Refactorings/Rename/RenamePresenter.cs index 581883981e..ed0c63d28f 100644 --- a/RetailCoder.VBE/Refactorings/Rename/RenamePresenter.cs +++ b/RetailCoder.VBE/Refactorings/Rename/RenamePresenter.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; -using System.Text.RegularExpressions; using System.Windows.Forms; using Antlr4.Runtime; using Antlr4.Runtime.Misc; @@ -270,7 +268,7 @@ private void RenameControl() var form = _view.Target.QualifiedName.QualifiedModuleName.Component.CodeModule; var control = ((dynamic)form.Parent.Designer).Controls(_view.Target.IdentifierName); - foreach (var handler in _declarations.FindEventHandlers(_view.Target)) + foreach (var handler in _declarations.FindEventHandlers(_view.Target).OrderByDescending(h => h.Selection.StartColumn)) { var newMemberName = handler.IdentifierName.Replace(control.Name + '_', _view.NewName + '_'); var module = handler.Project.VBComponents.Item(handler.ComponentName).CodeModule; @@ -300,7 +298,7 @@ private void RenameUsages(Declaration target, string interfaceName = null) var implementations = _declarations.FindInterfaceImplementationMembers() .Where(m => m.IdentifierName == target.ComponentName + '_' + target.IdentifierName); - foreach (var member in implementations) + foreach (var member in implementations.OrderByDescending(m => m.Selection.StartColumn)) { try { @@ -327,7 +325,7 @@ private void RenameUsages(Declaration target, string interfaceName = null) var module = grouping.Key.Component.CodeModule; foreach (var line in grouping.GroupBy(reference => reference.Selection.StartLine)) { - foreach (var reference in line) + foreach (var reference in line.OrderByDescending(l => l.Selection.StartColumn)) { var content = module.Lines[line.Key, 1]; string newContent; @@ -351,7 +349,7 @@ private void RenameUsages(Declaration target, string interfaceName = null) // renaming interface if (grouping.Any(reference => reference.Context.Parent is VBAParser.ImplementsStmtContext)) { - var members = _declarations.FindMembers(target); + var members = _declarations.FindMembers(target).OrderByDescending(m => m.Selection.StartColumn); foreach (var member in members) { var oldMemberName = target.IdentifierName + '_' + member.IdentifierName;