@@ -26,7 +26,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
2626 var interfaceDeclarationMembers = declarations . FindInterfaceMembers ( ) . ToList ( ) ;
2727 var interfaceScopes = declarations . FindInterfaceImplementationMembers ( ) . Concat ( interfaceDeclarationMembers ) . Select ( s => s . Scope ) ;
2828
29- issues . AddRange ( GetInterfaceResults ( declarations , interfaceDeclarationMembers ) ) ;
29+ issues . AddRange ( GetResults ( declarations , interfaceDeclarationMembers ) ) ;
3030
3131 var eventMembers = declarations . Where ( item => ! item . IsBuiltIn && item . DeclarationType == DeclarationType . Event ) . ToList ( ) ;
3232 var formEventHandlerScopes = State . FindFormEventHandlers ( ) . Select ( handler => handler . Scope ) ;
@@ -35,7 +35,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
3535 . Concat ( formEventHandlerScopes )
3636 . Concat ( eventHandlerScopes ) ;
3737
38- issues . AddRange ( GetEventResults ( declarations , eventMembers ) ) ;
38+ issues . AddRange ( GetResults ( declarations , eventMembers ) ) ;
3939
4040 var declareScopes = declarations . Where ( item =>
4141 item . DeclarationType == DeclarationType . LibraryFunction
@@ -56,67 +56,28 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
5656 return issues ;
5757 }
5858
59- private IEnumerable < ParameterCanBeByValInspectionResult > GetInterfaceResults ( List < Declaration > declarations , List < Declaration > interfaceDeclarationMembers )
59+ private IEnumerable < ParameterCanBeByValInspectionResult > GetResults ( List < Declaration > declarations , List < Declaration > declarationMembers )
6060 {
61- foreach ( var member in interfaceDeclarationMembers )
61+ foreach ( var declaration in declarationMembers )
6262 {
6363 var declarationParameters =
64- declarations . Where ( declaration => declaration . DeclarationType == DeclarationType . Parameter &&
65- declaration . ParentDeclaration == member )
64+ declarations . Where ( d => d . DeclarationType == DeclarationType . Parameter &&
65+ d . ParentDeclaration == declaration )
6666 . OrderBy ( o => o . Selection . StartLine )
6767 . ThenBy ( t => t . Selection . StartColumn )
6868 . ToList ( ) ;
6969
7070 var parametersAreByRef = declarationParameters . Select ( s => true ) . ToList ( ) ;
7171
72- var implementations = declarations . FindInterfaceImplementationMembers ( member ) . ToList ( ) ;
73- foreach ( var implementation in implementations )
74- {
75- var parameters =
76- declarations . Where ( declaration => declaration . DeclarationType == DeclarationType . Parameter &&
77- declaration . ParentDeclaration == implementation )
78- . OrderBy ( o => o . Selection . StartLine )
79- . ThenBy ( t => t . Selection . StartColumn )
80- . ToList ( ) ;
81-
82- for ( var i = 0 ; i < parameters . Count ; i ++ )
83- {
84- parametersAreByRef [ i ] = parametersAreByRef [ i ] && ! IsUsedAsByRefParam ( declarations , parameters [ i ] ) &&
85- ( ( VBAParser . ArgContext ) parameters [ i ] . Context ) . BYVAL ( ) == null &&
86- ! parameters [ i ] . References . Any ( reference => reference . IsAssignment ) ;
87- }
88- }
89-
90- for ( var i = 0 ; i < declarationParameters . Count ; i ++ )
91- {
92- if ( parametersAreByRef [ i ] )
93- {
94- yield return new ParameterCanBeByValInspectionResult ( this , State , declarationParameters [ i ] ,
95- declarationParameters [ i ] . Context , declarationParameters [ i ] . QualifiedName ) ;
96- }
97- }
98- }
99- }
100-
101- private IEnumerable < ParameterCanBeByValInspectionResult > GetEventResults ( List < Declaration > declarations , List < Declaration > eventDeclarationMembers )
102- {
103- foreach ( var member in eventDeclarationMembers )
104- {
105- var declarationParameters =
106- declarations . Where ( declaration => declaration . DeclarationType == DeclarationType . Parameter &&
107- declaration . ParentDeclaration == member )
108- . OrderBy ( o => o . Selection . StartLine )
109- . ThenBy ( t => t . Selection . StartColumn )
110- . ToList ( ) ;
111-
112- var parametersAreByRef = declarationParameters . Select ( s => true ) . ToList ( ) ;
72+ var members = declarationMembers . Any ( a => a . DeclarationType == DeclarationType . Event )
73+ ? declarations . FindHandlersForEvent ( declaration ) . Select ( s => s . Item2 ) . ToList ( )
74+ : declarations . FindInterfaceImplementationMembers ( declaration ) . ToList ( ) ;
11375
114- var handlers = declarations . FindHandlersForEvent ( member ) . Select ( s => s . Item2 ) . ToList ( ) ;
115- foreach ( var handler in handlers )
76+ foreach ( var member in members )
11677 {
11778 var parameters =
118- declarations . Where ( declaration => declaration . DeclarationType == DeclarationType . Parameter &&
119- declaration . ParentDeclaration == handler )
79+ declarations . Where ( d => d . DeclarationType == DeclarationType . Parameter &&
80+ d . ParentDeclaration == member )
12081 . OrderBy ( o => o . Selection . StartLine )
12182 . ThenBy ( t => t . Selection . StartColumn )
12283 . ToList ( ) ;
0 commit comments