Skip to content

Commit 5356e21

Browse files
committed
Modified local functions per comments
1 parent 2c054fc commit 5356e21

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Rubberduck.CodeAnalysis/Inspections/Concrete/ProcedureCanBeWrittenAsFunctionInspection.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
4141
.Concat(builtinHandlers)
4242
.Concat(userDeclarations.Where(item => item.IsWithEvents)));
4343

44-
bool HasArgumentReferencesWithIsAssignmentFlagged(QualifiedContext<ParserRuleContext> context)
45-
=> contextLookup.TryGetValue(context.Context.GetChild<VBAParser.ArgContext>(), out Declaration decl)
46-
? decl.References.Any(rf => rf.IsAssignment) : false;
47-
48-
Declaration GetSubStmtParentDeclaration(QualifiedContext<ParserRuleContext> context)
49-
=> contextLookup.TryGetValue((VBAParser.SubStmtContext)context.Context.Parent, out Declaration decl)
50-
? decl : null;
51-
5244
return Listener.Contexts
5345
.Where(context => context.Context.Parent is VBAParser.SubStmtContext
5446
&& HasArgumentReferencesWithIsAssignmentFlagged(context))
@@ -62,6 +54,20 @@ Declaration GetSubStmtParentDeclaration(QualifiedContext<ParserRuleContext> cont
6254
.Select(result => new DeclarationInspectionResult(this,
6355
string.Format(InspectionResults.ProcedureCanBeWrittenAsFunctionInspection, result.IdentifierName),
6456
result));
57+
58+
bool HasArgumentReferencesWithIsAssignmentFlagged(QualifiedContext<ParserRuleContext> context)
59+
{
60+
return contextLookup.TryGetValue(context.Context.GetChild<VBAParser.ArgContext>(), out Declaration decl)
61+
? decl.References.Any(rf => rf.IsAssignment)
62+
: false;
63+
}
64+
65+
Declaration GetSubStmtParentDeclaration(QualifiedContext<ParserRuleContext> context)
66+
{
67+
return contextLookup.TryGetValue(context.Context.Parent as VBAParser.SubStmtContext, out Declaration decl)
68+
? decl
69+
: null;
70+
}
6571
}
6672

6773
public class SingleByRefParamArgListListener : VBAParserBaseListener, IInspectionListener

0 commit comments

Comments
 (0)