@@ -59,23 +59,23 @@ private void UpdateSignature()
59
59
var subStmtText = _subStmtQualifiedContext . Context . GetText ( ) ;
60
60
var argText = _argQualifiedContext . Context . GetText ( ) ;
61
61
62
+ var newArgText = argText . Contains ( "ByRef " ) ? argText . Replace ( "ByRef " , "ByVal " ) : "ByVal " + argText ;
63
+
62
64
var newFunctionWithoutReturn = subStmtText . Insert ( subStmtText . IndexOf ( argListText , StringComparison . Ordinal ) + argListText . Length ,
63
65
_argQualifiedContext . Context . asTypeClause ( ) . GetText ( ) )
64
66
. Replace ( "Sub" , "Function" )
65
- . Replace ( argText ,
66
- argText . Contains ( "ByRef " )
67
- ? argText . Replace ( "ByRef " , "ByVal " )
68
- : "ByVal " + argText ) ;
67
+ . Replace ( argText , newArgText ) ;
69
68
70
69
var newfunctionWithReturn = newFunctionWithoutReturn
71
70
. Insert ( newFunctionWithoutReturn . LastIndexOf ( Environment . NewLine , StringComparison . Ordinal ) ,
72
- " " + _subStmtQualifiedContext . Context . ambiguousIdentifier ( ) . GetText ( ) + " = " +
73
- _argQualifiedContext . Context . ambiguousIdentifier ( ) . GetText ( ) ) ;
71
+ " " + _subStmtQualifiedContext . Context . ambiguousIdentifier ( ) . GetText ( ) +
72
+ " = " + _argQualifiedContext . Context . ambiguousIdentifier ( ) . GetText ( ) ) ;
74
73
75
74
var rewriter = _state . GetRewriter ( _subStmtQualifiedContext . ModuleName . Component ) ;
76
75
rewriter . Replace ( _subStmtQualifiedContext . Context . Start , newfunctionWithReturn ) ;
77
76
78
77
var module = _argListQualifiedContext . ModuleName . Component . CodeModule ;
78
+
79
79
module . DeleteLines ( _subStmtQualifiedContext . Context . Start . Line ,
80
80
_subStmtQualifiedContext . Context . Stop . Line - _subStmtQualifiedContext . Context . Start . Line + 1 ) ;
81
81
module . InsertLines ( _subStmtQualifiedContext . Context . Start . Line , newfunctionWithReturn ) ;
0 commit comments