Skip to content

Commit 257257c

Browse files
Andrin Meierretailcoder
authored andcommitted
fix documents/forms not marked as default instance variables (#1570)
1 parent 4688c80 commit 257257c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Rubberduck.Parsing/Symbols/ClassModuleDeclaration.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public sealed class ClassModuleDeclaration : Declaration
1010
{
1111
private readonly bool _isExposed;
1212
private readonly bool _isGlobalClassModule;
13+
private readonly bool _hasDefaultInstanceVariable;
1314
private readonly List<string> _supertypeNames;
1415
private readonly HashSet<Declaration> _supertypes;
1516
private readonly HashSet<Declaration> _subtypes;
@@ -22,7 +23,8 @@ public ClassModuleDeclaration(
2223
IEnumerable<IAnnotation> annotations,
2324
Attributes attributes,
2425
bool isExposed = false,
25-
bool isGlobalClassModule = false)
26+
bool isGlobalClassModule = false,
27+
bool hasDefaultInstanceVariable = false)
2628
: base(
2729
qualifiedName,
2830
projectDeclaration,
@@ -43,6 +45,7 @@ public ClassModuleDeclaration(
4345
{
4446
_isExposed = isExposed;
4547
_isGlobalClassModule = isGlobalClassModule;
48+
_hasDefaultInstanceVariable = hasDefaultInstanceVariable;
4649
_supertypeNames = new List<string>();
4750
_supertypes = new HashSet<Declaration>();
4851
_subtypes = new HashSet<Declaration>();
@@ -97,12 +100,13 @@ public bool HasPredeclaredId
97100
{
98101
get
99102
{
103+
bool attributeHasDefaultInstanceVariable = false;
100104
IEnumerable<string> value;
101105
if (Attributes.TryGetValue("VB_PredeclaredId", out value))
102106
{
103-
return value.Single() == "True";
107+
attributeHasDefaultInstanceVariable = value.Single() == "True";
104108
}
105-
return false;
109+
return _hasDefaultInstanceVariable || attributeHasDefaultInstanceVariable;
106110
}
107111
}
108112

Rubberduck.Parsing/Symbols/DeclarationSymbolsListener.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,15 @@ public DeclarationSymbolsListener(
6868
}
6969
else
7070
{
71+
bool hasDefaultInstanceVariable = type != vbext_ComponentType.vbext_ct_ClassModule && type != vbext_ComponentType.vbext_ct_StdModule;
7172
_moduleDeclaration = new ClassModuleDeclaration(
7273
_qualifiedName.QualifyMemberName(_qualifiedName.Component.Name),
7374
_projectDeclaration,
7475
_qualifiedName.Component.Name,
7576
false,
7677
FindAnnotations(),
77-
moduleAttributes);
78+
moduleAttributes,
79+
hasDefaultInstanceVariable: hasDefaultInstanceVariable);
7880
}
7981

8082
SetCurrentScope();

0 commit comments

Comments
 (0)