@@ -8,9 +8,6 @@ namespace Rubberduck.Parsing.Symbols
8
8
{
9
9
public sealed class ClassModuleDeclaration : Declaration
10
10
{
11
- private readonly bool _isExposed ;
12
- private readonly bool _isGlobalClassModule ;
13
- private readonly bool _hasDefaultInstanceVariable ;
14
11
private readonly List < string > _supertypeNames ;
15
12
private readonly HashSet < Declaration > _supertypes ;
16
13
private readonly HashSet < Declaration > _subtypes ;
@@ -21,10 +18,7 @@ public ClassModuleDeclaration(
21
18
string name ,
22
19
bool isBuiltIn ,
23
20
IEnumerable < IAnnotation > annotations ,
24
- Attributes attributes ,
25
- bool isExposed = false ,
26
- bool isGlobalClassModule = false ,
27
- bool hasDefaultInstanceVariable = false )
21
+ Attributes attributes , bool hasDefaultInstanceVariable = false )
28
22
: base (
29
23
qualifiedName ,
30
24
projectDeclaration ,
@@ -43,9 +37,10 @@ public ClassModuleDeclaration(
43
37
annotations ,
44
38
attributes )
45
39
{
46
- _isExposed = isExposed ;
47
- _isGlobalClassModule = isGlobalClassModule ;
48
- _hasDefaultInstanceVariable = hasDefaultInstanceVariable ;
40
+ if ( hasDefaultInstanceVariable )
41
+ {
42
+ _hasPredeclaredId = true ;
43
+ }
49
44
_supertypeNames = new List < string > ( ) ;
50
45
_supertypes = new HashSet < Declaration > ( ) ;
51
46
_subtypes = new HashSet < Declaration > ( ) ;
@@ -60,6 +55,8 @@ public static IEnumerable<Declaration> GetSupertypes(Declaration type)
60
55
return ( ( ClassModuleDeclaration ) type ) . Supertypes ;
61
56
}
62
57
58
+
59
+ private bool ? _isExposed ;
63
60
/// <summary>
64
61
/// Gets an attribute value indicating whether a class is exposed to other projects.
65
62
/// If this value is false, any public types and members cannot be accessed from outside the project they're declared in.
@@ -68,30 +65,44 @@ public bool IsExposed
68
65
{
69
66
get
70
67
{
71
- bool attributeIsExposed = false ;
68
+ if ( _isExposed . HasValue )
69
+ {
70
+ return _isExposed . Value ;
71
+ }
72
+
73
+ var attributeIsExposed = false ;
72
74
IEnumerable < string > value ;
73
75
if ( Attributes . TryGetValue ( "VB_Exposed" , out value ) )
74
76
{
75
77
attributeIsExposed = value . Single ( ) == "True" ;
76
78
}
77
- return _isExposed || attributeIsExposed ;
79
+ _isExposed = attributeIsExposed ;
80
+ return _isExposed . Value ;
78
81
}
79
82
}
80
83
84
+ private bool ? _isGlobal ;
81
85
public bool IsGlobalClassModule
82
86
{
83
87
get
84
88
{
85
- bool attributeIsGlobalClassModule = false ;
89
+ if ( _isGlobal . HasValue )
90
+ {
91
+ return _isGlobal . Value ;
92
+ }
93
+
94
+ var attributeIsGlobalClassModule = false ;
86
95
IEnumerable < string > value ;
87
96
if ( Attributes . TryGetValue ( "VB_GlobalNamespace" , out value ) )
88
97
{
89
98
attributeIsGlobalClassModule = value . Single ( ) == "True" ;
90
99
}
91
- return _isGlobalClassModule || attributeIsGlobalClassModule ;
100
+ _isGlobal = attributeIsGlobalClassModule ;
101
+ return _isGlobal . Value ;
92
102
}
93
103
}
94
104
105
+ private bool ? _hasPredeclaredId ;
95
106
/// <summary>
96
107
/// Gets an attribute value indicating whether a class has a predeclared ID.
97
108
/// Such classes can be treated as "static classes", or as far as resolving is concerned, as standard modules.
@@ -100,13 +111,19 @@ public bool HasPredeclaredId
100
111
{
101
112
get
102
113
{
103
- bool attributeHasDefaultInstanceVariable = false ;
114
+ if ( _hasPredeclaredId . HasValue )
115
+ {
116
+ return _hasPredeclaredId . Value ;
117
+ }
118
+
119
+ var attributeHasDefaultInstanceVariable = false ;
104
120
IEnumerable < string > value ;
105
121
if ( Attributes . TryGetValue ( "VB_PredeclaredId" , out value ) )
106
122
{
107
123
attributeHasDefaultInstanceVariable = value . Single ( ) == "True" ;
108
124
}
109
- return _hasDefaultInstanceVariable || attributeHasDefaultInstanceVariable ;
125
+ _hasPredeclaredId = attributeHasDefaultInstanceVariable ;
126
+ return _hasPredeclaredId . Value ;
110
127
}
111
128
}
112
129
0 commit comments