Skip to content

Commit 92ae0fe

Browse files
committed
fixed local array declarations in extracted procedures. closes #415
1 parent 5d158b1 commit 92ae0fe

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

RetailCoder.VBE/UI/Refactorings/ExtractMethod/ExtractMethodPresenter.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,14 @@ private string GetExtractedMethod()
194194
var localConsts = _locals.Select(e => e.Parent)
195195
.OfType<VBAParser.ConstSubStmtContext>()
196196
.Select(e => " " + Tokens.Const + ' ' + e.ambiguousIdentifier().GetText() + ' ' + e.asTypeClause().GetText() + " = " + e.valueStmt().GetText());
197+
197198
var localVariables = _locals.Select(e => e.Parent)
198199
.OfType<VBAParser.VariableSubStmtContext>()
199200
.Where(e => _view.Parameters.All(param => param.Name != e.ambiguousIdentifier().GetText()))
200-
.Select(e => " " + Tokens.Dim + ' ' + e.ambiguousIdentifier().GetText() + ' ' + e.asTypeClause().GetText());
201+
.Select(e => " " + Tokens.Dim + ' ' + e.ambiguousIdentifier().GetText() +
202+
(e.LPAREN() == null
203+
? string.Empty
204+
: e.LPAREN().GetText() + (e.subscripts() == null ? string.Empty : e.subscripts().GetText()) + e.RPAREN().GetText()) + ' ' + e.asTypeClause().GetText());
201205
var locals = string.Join(newLine, localConsts.Union(localVariables)
202206
.Where(local => !_selectedCode.Contains(local)).ToArray()) + newLine;
203207

0 commit comments

Comments
 (0)