File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
Rubberduck.CodeAnalysis/Inspections/Concrete Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change 1
1
using System . Collections . Generic ;
2
2
using System . Diagnostics . CodeAnalysis ;
3
3
using System . Linq ;
4
+ using Antlr4 . Runtime ;
4
5
using Rubberduck . Inspections . Abstract ;
5
6
using Rubberduck . Inspections . Results ;
7
+ using Rubberduck . Parsing ;
6
8
using Rubberduck . Parsing . Inspections . Abstract ;
7
9
using Rubberduck . Resources . Inspections ;
8
10
using Rubberduck . Parsing . Symbols ;
@@ -36,8 +38,8 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
36
38
37
39
var excludedDeclarations = BuiltInDeclarations . Where ( decl => IgnoredFunctions . Contains ( decl . QualifiedName . ToString ( ) ) ) . ToList ( ) ;
38
40
39
- return declarations . Except ( excludedDeclarations )
40
- . Where ( d => d . References . Any ( ) )
41
+ return declarations
42
+ . Where ( d => d . References . Any ( ) && ! excludedDeclarations . Any ( excl => DeclarationReferencesContainsReference ( excl , d ) ) )
41
43
. SelectMany ( d => d . References )
42
44
. Distinct ( )
43
45
. Where ( r => ! r . IsIgnoringInspectionResultFor ( AnnotationName ) )
@@ -46,5 +48,22 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
46
48
State ,
47
49
r ) ) . ToList ( ) ;
48
50
}
51
+
52
+ private static bool DeclarationReferencesContainsReference ( Declaration parentDeclaration , Declaration target )
53
+ {
54
+ foreach ( var targetReference in target . References )
55
+ {
56
+ foreach ( var reference in parentDeclaration . References )
57
+ {
58
+ var context = ( ParserRuleContext ) reference . Context . Parent ;
59
+ if ( context . GetSelection ( ) . Contains ( targetReference . Selection ) )
60
+ {
61
+ return true ;
62
+ }
63
+ }
64
+ }
65
+
66
+ return false ;
67
+ }
49
68
}
50
69
}
You can’t perform that action at this time.
0 commit comments