@@ -34,8 +34,8 @@ public override void EnterStartRule(VBAParser.StartRuleContext context)
34
34
35
35
public override void EnterModuleVariableStmt ( VBAParser . ModuleVariableStmtContext context )
36
36
{
37
- var variableDeclarationStatemenList = context . variableStmt ( ) . variableListStmt ( ) . variableSubStmt ( ) ;
38
- foreach ( var variableContext in variableDeclarationStatemenList )
37
+ var variableDeclarationStatementList = context . variableStmt ( ) . variableListStmt ( ) . variableSubStmt ( ) ;
38
+ foreach ( var variableContext in variableDeclarationStatementList )
39
39
{
40
40
var variableName = Identifier . GetName ( variableContext ) ;
41
41
_membersAllowingAttributes [ ( variableName , DeclarationType . Variable ) ] = context ;
@@ -169,19 +169,29 @@ public override void ExitAttributeStmt(VBAParser.AttributeStmtContext context)
169
169
170
170
var scopeName = attributeNameParts [ 0 ] ;
171
171
172
- //Might be an attribute for the enclosing procedure, function or poperty .
172
+ //Might be an attribute for the enclosing procedure, function or property .
173
173
if ( _currentScopeAttributes != null && scopeName . Equals ( _currentScope . scopeIdentifier , StringComparison . OrdinalIgnoreCase ) )
174
174
{
175
175
AddOrUpdateAttribute ( _currentScopeAttributes , attributeName , context ) ;
176
176
return ;
177
177
}
178
178
179
+ //Member attributes
180
+ //Due to the VBA naming rules, a name can only refer to either a variable or constant.
181
+
179
182
//Member variable attributes
180
183
var moduleVariableScope = ( scopeName , DeclarationType . Variable ) ;
181
184
if ( _membersAllowingAttributes . TryGetValue ( moduleVariableScope , out _ ) )
182
185
{
183
186
AddOrUpdateAttribute ( moduleVariableScope , attributeName , context ) ;
184
187
}
188
+
189
+ //Member constant attributes
190
+ var moduleConstantScope = ( scopeName , DeclarationType . Constant ) ;
191
+ if ( _membersAllowingAttributes . TryGetValue ( moduleConstantScope , out _ ) )
192
+ {
193
+ AddOrUpdateAttribute ( moduleConstantScope , attributeName , context ) ;
194
+ }
185
195
}
186
196
187
197
private void AddOrUpdateAttribute ( ( string scopeName , DeclarationType Variable ) moduleVariableScope ,
0 commit comments