Skip to content

Commit fa62a55

Browse files
committed
Small correction of the AttributeListener for the case that a member has the same name as the enclosing module
1 parent 7ceeb29 commit fa62a55

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Rubberduck.Parsing/VBA/Parsing/AttributeListener.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ public override void ExitSubStmt(VBAParser.SubStmtContext context)
6363
private void ResetScope()
6464
{
6565
_currentScope = _moduleScope;
66-
_currentScopeAttributes = _attributes.TryGetValue(_currentScope, out var attributes)
67-
? attributes
68-
: new Attributes();
66+
_currentScopeAttributes = null;
6967
}
7068

7169
public override void EnterFunctionStmt(VBAParser.FunctionStmtContext context)
@@ -154,7 +152,8 @@ public override void ExitAttributeStmt(VBAParser.AttributeStmtContext context)
154152

155153
var scopeName = attributeNameParts[0];
156154

157-
if (scopeName.Equals(_currentScope.scopeIdentifier, StringComparison.OrdinalIgnoreCase))
155+
//Might be an attribute for the enclosing procedure, function or poperty.
156+
if (_currentScopeAttributes != null && scopeName.Equals(_currentScope.scopeIdentifier, StringComparison.OrdinalIgnoreCase))
158157
{
159158
AddOrUpdateAttribute(_currentScopeAttributes, attributeName, context);
160159
return;

0 commit comments

Comments
 (0)