@@ -23,7 +23,6 @@ public sealed class IdentifierReferenceResolver
23
23
private Declaration _currentParent ;
24
24
private readonly BindingService _bindingService ;
25
25
private readonly BoundExpressionVisitor _boundExpressionVisitor ;
26
- private readonly IdentifierAnnotationService _identifierAnnotationService ;
27
26
private static readonly Logger Logger = LogManager . GetCurrentClassLogger ( ) ;
28
27
29
28
public IdentifierReferenceResolver ( QualifiedModuleName qualifiedModuleName , DeclarationFinder finder )
@@ -44,8 +43,7 @@ public IdentifierReferenceResolver(QualifiedModuleName qualifiedModuleName, Decl
44
43
new DefaultBindingContext ( _declarationFinder , typeBindingContext , procedurePointerBindingContext ) ,
45
44
typeBindingContext ,
46
45
procedurePointerBindingContext ) ;
47
- _identifierAnnotationService = new IdentifierAnnotationService ( _declarationFinder ) ;
48
- _boundExpressionVisitor = new BoundExpressionVisitor ( _identifierAnnotationService ) ;
46
+ _boundExpressionVisitor = new BoundExpressionVisitor ( finder ) ;
49
47
}
50
48
51
49
public void SetCurrentScope ( )
@@ -153,10 +151,16 @@ private void ResolveLabel(ParserRuleContext context, string label)
153
151
identifier ,
154
152
callee ,
155
153
callSiteContext . GetSelection ( ) ,
156
- _identifierAnnotationService . FindAnnotations ( _qualifiedModuleName , callSiteContext . GetSelection ( ) . StartLine ) ) ;
154
+ FindIdentifierAnnotations ( _qualifiedModuleName , callSiteContext . GetSelection ( ) . StartLine ) ) ;
157
155
}
158
156
}
159
157
158
+ private IEnumerable < IAnnotation > FindIdentifierAnnotations ( QualifiedModuleName module , int line )
159
+ {
160
+ return _declarationFinder . FindAnnotations ( module , line )
161
+ . Where ( annotation => annotation . AnnotationType . HasFlag ( AnnotationType . IdentifierAnnotation ) ) ;
162
+ }
163
+
160
164
private void ResolveDefault (
161
165
ParserRuleContext expression ,
162
166
StatementResolutionContext statementContext = StatementResolutionContext . Undefined ,
@@ -713,7 +717,7 @@ public void Resolve(VBAParser.RaiseEventStmtContext context)
713
717
identifier ,
714
718
callee ,
715
719
callSiteContext . GetSelection ( ) ,
716
- _identifierAnnotationService . FindAnnotations ( _qualifiedModuleName , callSiteContext . GetSelection ( ) . StartLine ) ) ;
720
+ FindIdentifierAnnotations ( _qualifiedModuleName , callSiteContext . GetSelection ( ) . StartLine ) ) ;
717
721
}
718
722
if ( context . eventArgumentList ( ) == null )
719
723
{
@@ -819,7 +823,7 @@ public void Resolve(VBAParser.DebugPrintStmtContext context)
819
823
context . debugPrint ( ) . debugModule ( ) . GetText ( ) ,
820
824
debugModule ,
821
825
context . debugPrint ( ) . debugModule ( ) . GetSelection ( ) ,
822
- _identifierAnnotationService . FindAnnotations ( _qualifiedModuleName , context . debugPrint ( ) . debugModule ( ) . GetSelection ( ) . StartLine ) ) ;
826
+ FindIdentifierAnnotations ( _qualifiedModuleName , context . debugPrint ( ) . debugModule ( ) . GetSelection ( ) . StartLine ) ) ;
823
827
debugPrint . AddReference (
824
828
_qualifiedModuleName ,
825
829
_currentScope ,
@@ -828,7 +832,7 @@ public void Resolve(VBAParser.DebugPrintStmtContext context)
828
832
context . debugPrint ( ) . debugPrintSub ( ) . GetText ( ) ,
829
833
debugPrint ,
830
834
context . debugPrint ( ) . debugPrintSub ( ) . GetSelection ( ) ,
831
- _identifierAnnotationService . FindAnnotations ( _qualifiedModuleName , context . debugPrint ( ) . debugPrintSub ( ) . GetSelection ( ) . StartLine ) ) ;
835
+ FindIdentifierAnnotations ( _qualifiedModuleName , context . debugPrint ( ) . debugPrintSub ( ) . GetSelection ( ) . StartLine ) ) ;
832
836
var outputList = context . outputList ( ) ;
833
837
if ( outputList != null )
834
838
{
0 commit comments