@@ -36,14 +36,22 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
36
36
. Concat ( builtinHandlers )
37
37
. Concat ( userDeclarations . Where ( item => item . IsWithEvents ) ) ) ;
38
38
39
+ bool HasArgumentReferencesWithIsAssignmentFlagged ( QualifiedContext < ParserRuleContext > context )
40
+ => contextLookup . TryGetValue ( context . Context . GetChild < VBAParser . ArgContext > ( ) , out Declaration decl )
41
+ ? decl . References . Any ( rf => rf . IsAssignment ) : false ;
42
+
43
+ Declaration GetSubStmtParentDeclaration ( QualifiedContext < ParserRuleContext > context )
44
+ => contextLookup . TryGetValue ( ( VBAParser . SubStmtContext ) context . Context . Parent , out Declaration decl )
45
+ ? decl : null ;
46
+
39
47
return Listener . Contexts
40
48
. Where ( context => context . Context . Parent is VBAParser . SubStmtContext
41
- && contextLookup [ context . Context . GetChild < VBAParser . ArgContext > ( ) ] . References
42
- . Any ( reference => reference . IsAssignment ) )
43
- . Select ( context => contextLookup [ ( VBAParser . SubStmtContext ) context . Context . Parent ] )
44
- . Where ( decl => ! IsIgnoringInspectionResultFor ( decl , AnnotationName ) &&
45
- ! ignored . Contains ( decl ) &&
46
- userDeclarations . Where ( item => item . IsWithEvents )
49
+ && HasArgumentReferencesWithIsAssignmentFlagged ( context ) )
50
+ . Select ( context => GetSubStmtParentDeclaration ( context ) )
51
+ . Where ( decl => decl != null &&
52
+ ! IsIgnoringInspectionResultFor ( decl , AnnotationName ) &&
53
+ ! ignored . Contains ( decl ) &&
54
+ userDeclarations . Where ( item => item . IsWithEvents )
47
55
. All ( withEvents => userDeclarations . FindEventProcedures ( withEvents ) == null ) &&
48
56
! builtinHandlers . Contains ( decl ) )
49
57
. Select ( result => new DeclarationInspectionResult ( this ,
0 commit comments