Skip to content

Commit 1126e47

Browse files
committed
fixed FormEventDeclarations
1 parent b0b3e9c commit 1126e47

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

Rubberduck.Parsing/Symbols/DeclarationFinder.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,24 @@ public Declaration FindStdModule(string name, Declaration parent = null, bool in
140140
return result;
141141
}
142142

143+
public Declaration FindClassModule(string name, Declaration parent = null, bool includeBuiltIn = false)
144+
{
145+
Declaration result = null;
146+
try
147+
{
148+
var matches = MatchName(name);
149+
result = matches.SingleOrDefault(declaration => declaration.DeclarationType.HasFlag(DeclarationType.ClassModule)
150+
&& (parent == null || parent.Equals(declaration.ParentDeclaration))
151+
&& (includeBuiltIn || !declaration.IsBuiltIn));
152+
}
153+
catch (InvalidOperationException exception)
154+
{
155+
Logger.Error(exception, "Multiple matches found for class module '{0}'.", name);
156+
}
157+
158+
return result;
159+
}
160+
143161
public Declaration FindReferencedProject(Declaration callingProject, string referencedProjectName)
144162
{
145163
return FindInReferencedProjectByPriority(callingProject, referencedProjectName, p => p.DeclarationType.HasFlag(DeclarationType.Project));

Rubberduck.Parsing/Symbols/FormEventDeclarations.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ private static Declaration FormsClassModuleFromParserState(RubberduckParserState
3333
var msForms = finder.FindProject("MSForms");
3434
if (msForms == null)
3535
{
36-
// If the VBA project is null, we haven't loaded any COM references;
37-
// we're in a unit test and the mock project didn't setup any references.
36+
//The corresponding COM reference has not been loaded.
3837
return null;
3938
}
4039

41-
return finder.FindStdModule("FormEvents", msForms, true);
40+
return finder.FindClassModule("FormEvents", msForms, true);
4241
}
4342

4443

0 commit comments

Comments
 (0)