4
4
using Rubberduck . Inspections . Resources ;
5
5
using Rubberduck . Inspections . Results ;
6
6
using Rubberduck . Parsing . VBA ;
7
- using Rubberduck . VBEditor . Application ;
8
- using Rubberduck . VBEditor . Extensions ;
9
- using Rubberduck . VBEditor . SafeComWrappers . Abstract ;
10
7
11
8
namespace Rubberduck . Inspections
12
9
{
13
10
public sealed class ImplicitActiveSheetReferenceInspection : InspectionBase
14
11
{
15
- private readonly IHostApplication _hostApp ;
16
-
17
- public ImplicitActiveSheetReferenceInspection ( IVBE vbe , RubberduckParserState state )
12
+ public ImplicitActiveSheetReferenceInspection ( RubberduckParserState state )
18
13
: base ( state )
19
14
{
20
- _hostApp = vbe . HostApplication ( ) ;
21
15
}
22
16
23
17
public override string Meta { get { return InspectionsUI . ImplicitActiveSheetReferenceInspectionMeta ; } }
@@ -31,22 +25,18 @@ public ImplicitActiveSheetReferenceInspection(IVBE vbe, RubberduckParserState st
31
25
32
26
public override IEnumerable < InspectionResultBase > GetInspectionResults ( )
33
27
{
34
- if ( _hostApp == null || _hostApp . ApplicationName != "Excel" )
35
- {
36
- return Enumerable . Empty < InspectionResultBase > ( ) ;
37
- // if host isn't Excel, the ExcelObjectModel declarations shouldn't be loaded anyway.
38
- }
39
-
40
28
var matches = BuiltInDeclarations . Where ( item =>
29
+ item . ProjectName == "Excel" &&
41
30
Targets . Contains ( item . IdentifierName ) &&
42
- item . ParentScope == "EXCEL.EXE;Excel. _Global" &&
31
+ item . ParentDeclaration . ComponentName == "_Global" &&
43
32
item . AsTypeName == "Range" ) . ToList ( ) ;
44
33
45
34
var issues = matches . Where ( item => item . References . Any ( ) )
46
35
. SelectMany ( declaration => declaration . References . Distinct ( ) ) ;
47
36
48
- return issues . Select ( issue =>
49
- new ImplicitActiveSheetReferenceInspectionResult ( this , issue ) ) ;
37
+ return issues
38
+ . Where ( issue => ! issue . IsInspectionDisabled ( AnnotationName ) )
39
+ . Select ( issue => new ImplicitActiveSheetReferenceInspectionResult ( this , issue ) ) ;
50
40
}
51
41
}
52
42
}
0 commit comments