Skip to content

Commit 19965a9

Browse files
committed
Use the DeclarationFinder host instead of finding it.
1 parent 6634dc9 commit 19965a9

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Rubberduck.Parsing/Symbols/DeclarationFinder.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ private IEnumerable<Declaration> FindAllInReferencedProjectByPriority(Declaratio
622622
}
623623
}
624624

625-
public static ConcurrentBag<Declaration> FindBuiltInEventHandlers(IEnumerable<Declaration> declarations)
625+
public ConcurrentBag<Declaration> FindBuiltInEventHandlers(IEnumerable<Declaration> declarations)
626626
{
627627
var declarationList = declarations.ToList();
628628

@@ -635,18 +635,15 @@ public static ConcurrentBag<Declaration> FindBuiltInEventHandlers(IEnumerable<De
635635
: new[] { e.ParentDeclaration.IdentifierName + "_" + e.IdentifierName };
636636
});
637637

638-
var user = declarationList.FirstOrDefault(decl => !decl.IsBuiltIn);
639-
var host = user != null ? user.Project.VBE.HostApplication() : null;
640-
641638
var handlers = declarationList.Where(item =>
642639
// class module built-in events
643640
(item.DeclarationType == DeclarationType.Procedure &&
644641
item.ParentDeclaration.DeclarationType == DeclarationType.ClassModule && (
645642
item.IdentifierName.Equals("Class_Initialize", StringComparison.InvariantCultureIgnoreCase) ||
646643
item.IdentifierName.Equals("Class_Terminate", StringComparison.InvariantCultureIgnoreCase))) ||
647644
// 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) &&
650647
item.DeclarationType == DeclarationType.Procedure &&
651648
item.ParentDeclaration.DeclarationType == DeclarationType.ProceduralModule && (
652649
item.IdentifierName.Equals("auto_open", StringComparison.InvariantCultureIgnoreCase) ||

0 commit comments

Comments
 (0)