Skip to content

Commit a34755e

Browse files
committed
moved HasDefaultMember to ClassModuleDeclaration
1 parent 769f3ba commit a34755e

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

RetailCoder.VBE/Inspections/ObjectVariableNotSetInspection.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
4343
!item.IsSelfAssigned &&
4444
!item.IsArray &&
4545
!ValueTypes.Contains(item.AsTypeName) &&
46-
(item.AsTypeDeclaration == null || (!IsBuiltInTypeWithDefaultMember(item.AsTypeDeclaration) &&
46+
(item.AsTypeDeclaration == null || (!ClassModuleDeclaration.HasDefaultMember(item.AsTypeDeclaration) &&
4747
item.AsTypeDeclaration.DeclarationType != DeclarationType.Enumeration &&
4848
item.AsTypeDeclaration.DeclarationType != DeclarationType.UserDefinedType)) &&
4949
(item.DeclarationType == DeclarationType.Variable ||
@@ -58,7 +58,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
5858
&& (item.AsTypeDeclaration == null // null if unresolved (e.g. in unit tests)
5959
|| (item.AsTypeDeclaration.DeclarationType != DeclarationType.Enumeration && item.AsTypeDeclaration.DeclarationType != DeclarationType.UserDefinedType
6060
&& item.AsTypeDeclaration != null
61-
&& !IsBuiltInTypeWithDefaultMember(item.AsTypeDeclaration))));
61+
&& !ClassModuleDeclaration.HasDefaultMember(item.AsTypeDeclaration))));
6262

6363
var interestingReferences = interestingDeclarations
6464
.Union(interestingMembers.SelectMany(item =>
@@ -75,11 +75,5 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
7575

7676
return interestingReferences.Select(reference => new ObjectVariableNotSetInspectionResult(this, reference));
7777
}
78-
79-
private bool IsBuiltInTypeWithDefaultMember(Declaration asType)
80-
{
81-
var classModule = asType as ClassModuleDeclaration;
82-
return classModule != null && asType.IsBuiltIn && classModule.DefaultMember != null;
83-
}
8478
}
8579
}

Rubberduck.Parsing/Symbols/ClassModuleDeclaration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ public static IEnumerable<Declaration> GetSupertypes(Declaration type)
5757
return classType != null ? classType.Supertypes : new List<Declaration>();
5858
}
5959

60+
public static bool HasDefaultMember(Declaration type)
61+
{
62+
var classModule = type as ClassModuleDeclaration;
63+
return classModule != null && classModule.DefaultMember != null;
64+
}
6065

6166
private bool? _isExposed;
6267
/// <summary>

0 commit comments

Comments
 (0)