Skip to content

Commit a0a7d1d

Browse files
committed
Clean up a mite.
1 parent 3067b2b commit a0a7d1d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

RetailCoder.VBE/Inspections/ProcedureShouldBeFunctionInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public IEnumerable<CodeInspectionResultBase> GetInspectionResults(RubberduckPars
3030
new QualifiedContext<VBAParser.SubStmtContext>(context.ModuleName,
3131
context.Context.Parent as VBAParser.SubStmtContext),
3232
new QualifiedContext<VBAParser.ArgContext>(context.ModuleName,
33-
(context.Context as VBAParser.ArgListContext).arg()
33+
((VBAParser.ArgListContext) context.Context).arg()
3434
.First(a => a.BYREF() != null || (a.BYREF() == null && a.BYVAL() == null)))));
3535
}
3636
}

RetailCoder.VBE/Inspections/ProcedureShouldBeFunctionInspectionResult.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,23 @@ private void UpdateSignature()
5959
var subStmtText = _subStmtQualifiedContext.Context.GetText();
6060
var argText = _argQualifiedContext.Context.GetText();
6161

62+
var newArgText = argText.Contains("ByRef ") ? argText.Replace("ByRef ", "ByVal ") : "ByVal " + argText;
63+
6264
var newFunctionWithoutReturn = subStmtText.Insert(subStmtText.IndexOf(argListText, StringComparison.Ordinal) + argListText.Length,
6365
_argQualifiedContext.Context.asTypeClause().GetText())
6466
.Replace("Sub", "Function")
65-
.Replace(argText,
66-
argText.Contains("ByRef ")
67-
? argText.Replace("ByRef ", "ByVal ")
68-
: "ByVal " + argText);
67+
.Replace(argText, newArgText);
6968

7069
var newfunctionWithReturn = newFunctionWithoutReturn
7170
.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());
7473

7574
var rewriter = _state.GetRewriter(_subStmtQualifiedContext.ModuleName.Component);
7675
rewriter.Replace(_subStmtQualifiedContext.Context.Start, newfunctionWithReturn);
7776

7877
var module = _argListQualifiedContext.ModuleName.Component.CodeModule;
78+
7979
module.DeleteLines(_subStmtQualifiedContext.Context.Start.Line,
8080
_subStmtQualifiedContext.Context.Stop.Line - _subStmtQualifiedContext.Context.Start.Line + 1);
8181
module.InsertLines(_subStmtQualifiedContext.Context.Start.Line, newfunctionWithReturn);

0 commit comments

Comments
 (0)