@@ -622,7 +622,7 @@ private IEnumerable<Declaration> FindAllInReferencedProjectByPriority(Declaratio
622
622
}
623
623
}
624
624
625
- public static ConcurrentBag < Declaration > FindBuiltInEventHandlers ( IEnumerable < Declaration > declarations )
625
+ public ConcurrentBag < Declaration > FindBuiltInEventHandlers ( IEnumerable < Declaration > declarations )
626
626
{
627
627
var declarationList = declarations . ToList ( ) ;
628
628
@@ -635,18 +635,15 @@ public static ConcurrentBag<Declaration> FindBuiltInEventHandlers(IEnumerable<De
635
635
: new [ ] { e . ParentDeclaration . IdentifierName + "_" + e . IdentifierName } ;
636
636
} ) ;
637
637
638
- var user = declarationList . FirstOrDefault ( decl => ! decl . IsBuiltIn ) ;
639
- var host = user != null ? user . Project . VBE . HostApplication ( ) : null ;
640
-
641
638
var handlers = declarationList . Where ( item =>
642
639
// class module built-in events
643
640
( item . DeclarationType == DeclarationType . Procedure &&
644
641
item . ParentDeclaration . DeclarationType == DeclarationType . ClassModule && (
645
642
item . IdentifierName . Equals ( "Class_Initialize" , StringComparison . InvariantCultureIgnoreCase ) ||
646
643
item . IdentifierName . Equals ( "Class_Terminate" , StringComparison . InvariantCultureIgnoreCase ) ) ) ||
647
644
// standard module built-in handlers (Excel specific):
648
- ( host != null &&
649
- host . ApplicationName . Equals ( "Excel" , StringComparison . InvariantCultureIgnoreCase ) &&
645
+ ( _hostApp != null &&
646
+ _hostApp . ApplicationName . Equals ( "Excel" , StringComparison . InvariantCultureIgnoreCase ) &&
650
647
item . DeclarationType == DeclarationType . Procedure &&
651
648
item . ParentDeclaration . DeclarationType == DeclarationType . ProceduralModule && (
652
649
item . IdentifierName . Equals ( "auto_open" , StringComparison . InvariantCultureIgnoreCase ) ||
0 commit comments