Skip to content

Commit

Permalink
Merge pull request #671 from Hosch250/next
Browse files Browse the repository at this point in the history
Fix rename bug
  • Loading branch information
retailcoder committed Jun 29, 2015
2 parents b98d0c3 + bb49c4e commit d587441
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions RetailCoder.VBE/Refactorings/Rename/RenamePresenter.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
{
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit d587441

Please sign in to comment.