44using Rubberduck . Inspections . Resources ;
55using Rubberduck . Inspections . Results ;
66using Rubberduck . Parsing . VBA ;
7- using Rubberduck . VBEditor . Application ;
8- using Rubberduck . VBEditor . Extensions ;
9- using Rubberduck . VBEditor . SafeComWrappers . Abstract ;
107
118namespace Rubberduck . Inspections
129{
1310 public sealed class ImplicitActiveSheetReferenceInspection : InspectionBase
1411 {
15- private readonly IHostApplication _hostApp ;
16-
17- public ImplicitActiveSheetReferenceInspection ( IVBE vbe , RubberduckParserState state )
12+ public ImplicitActiveSheetReferenceInspection ( RubberduckParserState state )
1813 : base ( state )
1914 {
20- _hostApp = vbe . HostApplication ( ) ;
2115 }
2216
2317 public override string Meta { get { return InspectionsUI . ImplicitActiveSheetReferenceInspectionMeta ; } }
@@ -31,22 +25,18 @@ public ImplicitActiveSheetReferenceInspection(IVBE vbe, RubberduckParserState st
3125
3226 public override IEnumerable < InspectionResultBase > GetInspectionResults ( )
3327 {
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-
4028 var matches = BuiltInDeclarations . Where ( item =>
29+ item . ProjectName == "Excel" &&
4130 Targets . Contains ( item . IdentifierName ) &&
42- item . ParentScope == "EXCEL.EXE;Excel. _Global" &&
31+ item . ParentDeclaration . ComponentName == "_Global" &&
4332 item . AsTypeName == "Range" ) . ToList ( ) ;
4433
4534 var issues = matches . Where ( item => item . References . Any ( ) )
4635 . SelectMany ( declaration => declaration . References . Distinct ( ) ) ;
4736
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 ) ) ;
5040 }
5141 }
5242}
0 commit comments