@@ -32,6 +32,9 @@ public AssignedByValParameterMakeLocalCopyQuickFix(RubberduckParserState state,
32
32
33
33
public override void Fix ( IInspectionResult result )
34
34
{
35
+ Debug . Assert ( result . Target . Context . Parent is ArgListContext ) ;
36
+ Debug . Assert ( null != ParserRuleContextHelper . GetChild < EndOfStatementContext > ( result . Target . Context . Parent . Parent ) ) ;
37
+
35
38
var forbiddenNames = _parserState . DeclarationFinder . GetDeclarationsWithIdentifiersToAvoid ( result . Target ) . Select ( n => n . IdentifierName ) ;
36
39
37
40
var localIdentifier = PromptForLocalVariableName ( result . Target , forbiddenNames . ToList ( ) ) ;
@@ -120,10 +123,8 @@ private void InsertLocalVariableDeclarationAndAssignment(IModuleRewriter rewrite
120
123
var endOfStmtCtxt = ParserRuleContextHelper . GetChild < EndOfStatementContext > ( target . Context . Parent . Parent ) ;
121
124
var eosContent = endOfStmtCtxt . GetText ( ) ;
122
125
var idxLastNewLine = eosContent . LastIndexOf ( Environment . NewLine ) ;
123
- var comment = eosContent . Substring ( 0 , idxLastNewLine ) ;
124
- var endOfStmtNewLineContent = eosContent . Substring ( idxLastNewLine ) ;
125
-
126
- Debug . Assert ( target . Context . Parent is ArgListContext ) ;
126
+ var endOfStmtCtxtComment = eosContent . Substring ( 0 , idxLastNewLine ) ;
127
+ var endOfStmtCtxtEndFormat = eosContent . Substring ( idxLastNewLine ) ;
127
128
128
129
var insertCtxt = ( ParserRuleContext ) ParserRuleContextHelper . GetChild < AsTypeClauseContext > ( target . Context . Parent . Parent ) ;
129
130
if ( insertCtxt == null )
@@ -132,7 +133,7 @@ private void InsertLocalVariableDeclarationAndAssignment(IModuleRewriter rewrite
132
133
}
133
134
134
135
rewriter . Remove ( endOfStmtCtxt ) ;
135
- rewriter . InsertAfter ( insertCtxt . Stop . TokenIndex , $ "{ comment } { endOfStmtNewLineContent } { localVariableDeclaration } " + $ "{ endOfStmtNewLineContent } { localVariableAssignment } { endOfStmtNewLineContent } ") ;
136
+ rewriter . InsertAfter ( insertCtxt . Stop . TokenIndex , $ "{ endOfStmtCtxtComment } { endOfStmtCtxtEndFormat } { localVariableDeclaration } " + $ "{ endOfStmtCtxtEndFormat } { localVariableAssignment } { endOfStmtCtxtEndFormat } ") ;
136
137
}
137
138
}
138
139
}
0 commit comments