@@ -345,25 +345,17 @@ private void AdjustSignatures(Declaration declaration)
345
345
346
346
private void RemoveSignatureParameters ( Declaration target , VBAParser . ArgListContext paramList , CodeModule module )
347
347
{
348
- var paramNames = paramList . arg ( ) ;
349
-
350
- var paramsRemoved = _model . Parameters . Where ( item => item . IsRemoved ) . ToList ( ) ;
348
+ // property set/let have one more parameter than is listed in the getter parameters
349
+ var nonRemovedParamNames = paramList . arg ( ) . Where ( ( a , s ) => s >= _model . Parameters . Count || ! _model . Parameters [ s ] . IsRemoved ) . Select ( s => s . GetText ( ) ) ;
351
350
var signature = GetOldSignature ( target ) ;
351
+ signature = signature . Remove ( signature . IndexOf ( '(' ) ) ;
352
+
353
+ var asTypeText = target . AsTypeContext == null ? string . Empty : " " + target . AsTypeContext . GetText ( ) ;
354
+ signature += '(' + string . Join ( ", " , nonRemovedParamNames ) + ")" + ( asTypeText == " " ? string . Empty : asTypeText ) ;
352
355
353
- foreach ( var param in paramsRemoved )
354
- {
355
- try
356
- {
357
- signature = ReplaceCommas ( signature . Replace ( paramNames . ElementAt ( param . Index ) . GetText ( ) , string . Empty ) , _model . Parameters . FindIndex ( item => item == param ) - paramsRemoved . FindIndex ( item => item == param ) ) ;
358
- }
359
- catch ( ArgumentOutOfRangeException )
360
- {
361
- }
362
- }
363
- var lineNum = paramList . GetSelection ( ) . LineCount ;
364
-
356
+ var lineCount = paramList . GetSelection ( ) . LineCount ;
365
357
module . ReplaceLine ( paramList . Start . Line , signature . Replace ( " _" + Environment . NewLine , string . Empty ) ) ;
366
- module . DeleteLines ( paramList . Start . Line + 1 , lineNum - 1 ) ;
358
+ module . DeleteLines ( paramList . Start . Line + 1 , lineCount - 1 ) ;
367
359
}
368
360
}
369
361
}
0 commit comments