@@ -77,9 +77,29 @@ public override void ExitModuleAttributes(AttributesParser.ModuleAttributesConte
7777                _attributes . Add ( _currentScope ,  _currentScopeAttributes ) ; 
7878            } 
7979
80+             private  static readonly  IReadOnlyDictionary < Type ,  DeclarationType >  ScopingContextTypes  = 
81+                 new  Dictionary < Type ,  DeclarationType > 
82+             { 
83+                 { typeof ( AttributesParser . SubStmtContext ) ,  DeclarationType . Procedure } , 
84+                 { typeof ( AttributesParser . FunctionStmtContext ) ,  DeclarationType . Function } , 
85+                 { typeof ( AttributesParser . PropertyGetStmtContext ) ,  DeclarationType . PropertyGet } , 
86+                 { typeof ( AttributesParser . PropertyLetStmtContext ) ,  DeclarationType . PropertyLet } , 
87+                 { typeof ( AttributesParser . PropertySetStmtContext ) ,  DeclarationType . PropertySet } 
88+             } ; 
89+ 
90+             public  override  void  EnterAmbiguousIdentifier ( AttributesParser . AmbiguousIdentifierContext  context ) 
91+             { 
92+                 DeclarationType  type ; 
93+                 if  ( ! ScopingContextTypes . TryGetValue ( context . Parent . GetType ( ) ,  out  type ) ) 
94+                 { 
95+                     return ; 
96+                 } 
97+ 
98+                 _currentScope  =  Tuple . Create ( context . GetText ( ) ,  type ) ; 
99+             } 
100+ 
80101            public  override  void  EnterSubStmt ( AttributesParser . SubStmtContext  context ) 
81102            { 
82-                 _currentScope  =  Tuple . Create ( context . ambiguousIdentifier ( ) . GetText ( ) ,  DeclarationType . Procedure ) ; 
83103                _currentScopeAttributes  =  new  Attributes ( ) ; 
84104            } 
85105
@@ -90,7 +110,6 @@ public override void ExitSubStmt(AttributesParser.SubStmtContext context)
90110
91111            public  override  void  EnterFunctionStmt ( AttributesParser . FunctionStmtContext  context ) 
92112            { 
93-                 _currentScope  =  Tuple . Create ( context . ambiguousIdentifier ( ) . GetText ( ) ,  DeclarationType . Function ) ; 
94113                _currentScopeAttributes  =  new  Attributes ( ) ; 
95114            } 
96115
@@ -101,7 +120,6 @@ public override void ExitFunctionStmt(AttributesParser.FunctionStmtContext conte
101120
102121            public  override  void  EnterPropertyGetStmt ( AttributesParser . PropertyGetStmtContext  context ) 
103122            { 
104-                 _currentScope  =  Tuple . Create ( context . ambiguousIdentifier ( ) . GetText ( ) ,  DeclarationType . PropertyGet ) ; 
105123                _currentScopeAttributes  =  new  Attributes ( ) ; 
106124            } 
107125
@@ -112,7 +130,6 @@ public override void ExitPropertyGetStmt(AttributesParser.PropertyGetStmtContext
112130
113131            public  override  void  EnterPropertyLetStmt ( AttributesParser . PropertyLetStmtContext  context ) 
114132            { 
115-                 _currentScope  =  Tuple . Create ( context . ambiguousIdentifier ( ) . GetText ( ) ,  DeclarationType . PropertyLet ) ; 
116133                _currentScopeAttributes  =  new  Attributes ( ) ; 
117134            } 
118135
@@ -123,7 +140,6 @@ public override void ExitPropertyLetStmt(AttributesParser.PropertyLetStmtContext
123140
124141            public  override  void  EnterPropertySetStmt ( AttributesParser . PropertySetStmtContext  context ) 
125142            { 
126-                 _currentScope  =  Tuple . Create ( context . ambiguousIdentifier ( ) . GetText ( ) ,  DeclarationType . PropertySet ) ; 
127143                _currentScopeAttributes  =  new  Attributes ( ) ; 
128144            } 
129145
0 commit comments