33using System . Windows . Forms ;
44using Rubberduck . Common ;
55using Rubberduck . Parsing . Grammar ;
6+ using Rubberduck . Parsing . PostProcessing ;
67using Rubberduck . Parsing . Symbols ;
78using Rubberduck . Parsing . VBA ;
89using Rubberduck . UI ;
@@ -18,6 +19,8 @@ public class IntroduceParameterRefactoring : IRefactoring
1819 private readonly IList < Declaration > _declarations ;
1920 private readonly IMessageBox _messageBox ;
2021
22+ private readonly HashSet < IModuleRewriter > _rewriters = new HashSet < IModuleRewriter > ( ) ;
23+
2124 private static readonly DeclarationType [ ] ValidDeclarationTypes =
2225 {
2326 DeclarationType . Function ,
@@ -94,6 +97,7 @@ private void PromoteVariable(Declaration target)
9497 }
9598
9699 var rewriter = _state . GetRewriter ( target ) ;
100+ _rewriters . Add ( rewriter ) ;
97101
98102 QualifiedSelection ? oldSelection = null ;
99103 var pane = _vbe . ActiveCodePane ;
@@ -110,6 +114,11 @@ private void PromoteVariable(Declaration target)
110114 {
111115 pane . Selection = oldSelection . Value . Selection ;
112116 }
117+
118+ foreach ( var tokenRewriter in _rewriters )
119+ {
120+ tokenRewriter . Rewrite ( ) ;
121+ }
113122 }
114123
115124 private bool PromptIfMethodImplementsInterface ( Declaration targetVariable )
@@ -188,6 +197,7 @@ private void UpdateSignature(Declaration targetMethod, Declaration targetVariabl
188197 private void AddParameter ( Declaration targetMethod , Declaration targetVariable , VBAParser . ArgListContext paramList )
189198 {
190199 var rewriter = _state . GetRewriter ( targetMethod ) ;
200+ _rewriters . Add ( rewriter ) ;
191201
192202 var argList = paramList . arg ( ) ;
193203 var newParameter = Tokens . ByVal + " " + targetVariable . IdentifierName + " " + Tokens . As + " " + targetVariable . AsTypeName ;
0 commit comments