@@ -220,33 +220,35 @@ public static IEnumerable<Declaration> FindEventHandlers(this IEnumerable<Declar
220
220
&& declaration . IdentifierName . StartsWith ( control . IdentifierName + "_" ) ) ;
221
221
}
222
222
223
- public static IEnumerable < Declaration > FindBuiltInEventHandlers ( this List < Declaration > declarations )
223
+ public static IEnumerable < Declaration > FindBuiltInEventHandlers ( this IEnumerable < Declaration > declarations )
224
224
{
225
- var handlerNames = declarations . Where ( declaration => declaration . IsBuiltIn && declaration . DeclarationType == DeclarationType . Event )
225
+ var declarationList = declarations . ToList ( ) ;
226
+
227
+ var handlerNames = declarationList . Where ( declaration => declaration . IsBuiltIn && declaration . DeclarationType == DeclarationType . Event )
226
228
. Select ( e => e . ParentDeclaration . IdentifierName + "_" + e . IdentifierName ) ;
227
229
228
230
// class module built-in events
229
- var classModuleHandlers = declarations . Where ( item =>
231
+ var classModuleHandlers = declarationList . Where ( item =>
230
232
item . DeclarationType == DeclarationType . Procedure &&
231
233
item . ParentDeclaration . DeclarationType == DeclarationType . ClassModule &&
232
234
( item . IdentifierName == "Class_Initialize" || item . IdentifierName == "Class_Terminate" ) ) ;
233
235
234
236
// user form built-in events
235
- var userFormHandlers = declarations . Where ( item =>
237
+ var userFormHandlers = declarationList . Where ( item =>
236
238
item . DeclarationType == DeclarationType . Procedure &&
237
239
item . ParentDeclaration . DeclarationType == DeclarationType . ClassModule &&
238
240
item . QualifiedName . QualifiedModuleName . Component . Type == vbext_ComponentType . vbext_ct_MSForm &&
239
241
new [ ]
240
242
{
241
243
"UserForm_Activate" , "UserForm_AddControl" , "UserForm_BeforeDragOver" , "UserForm_BeforeDropOrPaste" ,
242
- "UserForm_Click" , "UserForm_DblCIick " , "UserForm_Deactivate" , "UserForm_Error" ,
244
+ "UserForm_Click" , "UserForm_DblClick " , "UserForm_Deactivate" , "UserForm_Error" ,
243
245
"UserForm_Initialize" , "UserForm_KeyDown" , "UserForm_KeyPress" , "UserForm_KeyUp" , "UserForm_Layout" ,
244
246
"UserForm_MouseDown" , "UserForm_MouseMove" , "UserForm_MouseUp" , "UserForm_QueryClose" ,
245
247
"UserForm_RemoveControl" , "UserForm_Resize" , "UserForm_Scroll" , "UserForm_Terminate" ,
246
248
"UserForm_Zoom"
247
249
} . Contains ( item . IdentifierName ) ) ;
248
250
249
- var handlers = declarations . Where ( declaration => ! declaration . IsBuiltIn
251
+ var handlers = declarationList . Where ( declaration => ! declaration . IsBuiltIn
250
252
&& declaration . DeclarationType == DeclarationType . Procedure
251
253
&& handlerNames . Contains ( declaration . IdentifierName ) ) . ToList ( ) ;
252
254
0 commit comments