@@ -247,7 +247,7 @@ private void RenameControl()
247
247
var module = handler . Project . VBComponents . Item ( handler . ComponentName ) . CodeModule ;
248
248
249
249
var content = module . Lines [ handler . Selection . StartLine , 1 ] ;
250
- var newContent = GetReplacementLine ( content , handler . IdentifierName , newMemberName ) ;
250
+ var newContent = GetReplacementLine ( content , handler . IdentifierName , newMemberName , handler . Selection ) ;
251
251
module . ReplaceLine ( handler . Selection . StartLine , newContent ) ;
252
252
}
253
253
@@ -279,7 +279,7 @@ private void RenameUsages(Declaration target, string interfaceName = null)
279
279
var module = member . Project . VBComponents . Item ( member . ComponentName ) . CodeModule ;
280
280
281
281
var content = module . Lines [ member . Selection . StartLine , 1 ] ;
282
- var newContent = GetReplacementLine ( content , member . IdentifierName , newMemberName ) ;
282
+ var newContent = GetReplacementLine ( content , member . IdentifierName , newMemberName , member . Selection ) ;
283
283
module . ReplaceLine ( member . Selection . StartLine , newContent ) ;
284
284
RenameUsages ( member , target . ComponentName ) ;
285
285
}
@@ -298,19 +298,25 @@ private void RenameUsages(Declaration target, string interfaceName = null)
298
298
var module = grouping . Key . Component . CodeModule ;
299
299
foreach ( var line in grouping . GroupBy ( reference => reference . Selection . StartLine ) )
300
300
{
301
- var content = module . Lines [ line . Key , 1 ] ;
302
- string newContent ;
303
-
304
- if ( interfaceName == null )
305
- {
306
- newContent = GetReplacementLine ( content , target . IdentifierName , _view . NewName ) ;
307
- }
308
- else
301
+ foreach ( var reference in line )
309
302
{
310
- newContent = GetReplacementLine ( content , target . IdentifierName , interfaceName + "_" + _view . NewName ) ;
311
- }
303
+ var content = module . Lines [ line . Key , 1 ] ;
304
+ string newContent ;
305
+
306
+ if ( interfaceName == null )
307
+ {
308
+ newContent = GetReplacementLine ( content , target . IdentifierName , _view . NewName ,
309
+ reference . Selection ) ;
310
+ }
311
+ else
312
+ {
313
+ newContent = GetReplacementLine ( content , target . IdentifierName ,
314
+ interfaceName + "_" + _view . NewName ,
315
+ reference . Selection ) ;
316
+ }
312
317
313
- module . ReplaceLine ( line . Key , newContent ) ;
318
+ module . ReplaceLine ( line . Key , newContent ) ;
319
+ }
314
320
}
315
321
316
322
// renaming interface
@@ -328,17 +334,21 @@ private void RenameUsages(Declaration target, string interfaceName = null)
328
334
}
329
335
330
336
var content = module . Lines [ method . Selection . StartLine , 1 ] ;
331
- var newContent = GetReplacementLine ( content , oldMemberName , newMemberName ) ;
337
+ var newContent = GetReplacementLine ( content , oldMemberName , newMemberName , member . Selection ) ;
332
338
module . ReplaceLine ( method . Selection . StartLine , newContent ) ;
333
339
}
334
340
}
335
341
}
336
342
}
337
343
338
- private string GetReplacementLine ( string content , string target , string newName )
344
+ private string GetReplacementLine ( string content , string target , string newName , Selection selection )
339
345
{
340
346
// until we figure out how to replace actual tokens,
341
347
// this is going to have to be done the ugly way...
348
+
349
+ // todo: come back after the identifier references are fixed
350
+ //var contentWithoutOldName = content.Remove(selection.StartColumn - 1, selection.EndColumn - selection.StartColumn);
351
+ //return contentWithoutOldName.Insert(selection.StartColumn - 1, newName);
342
352
return Regex . Replace ( content , "\\ b" + target + "\\ b" , newName ) ;
343
353
}
344
354
@@ -420,7 +430,7 @@ private string GetReplacementLine(CodeModule module, Declaration target, string
420
430
421
431
return rewriter . GetText ( new Interval ( firstTokenIndex , lastTokenIndex ) ) ;
422
432
}
423
- return GetReplacementLine ( content , target . IdentifierName , newName ) ;
433
+ return GetReplacementLine ( content , target . IdentifierName , newName , target . Selection ) ;
424
434
}
425
435
426
436
private static readonly DeclarationType [ ] ProcedureDeclarationTypes =
0 commit comments