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 ImplicitActiveWorkbookReferenceInspection : InspectionBase
14
11
{
15
- private readonly IHostApplication _hostApp ;
16
-
17
- public ImplicitActiveWorkbookReferenceInspection ( IVBE vbe , RubberduckParserState state )
12
+ public ImplicitActiveWorkbookReferenceInspection ( 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 . ImplicitActiveWorkbookReferenceInspectionMeta ; } }
@@ -31,22 +25,16 @@ public ImplicitActiveWorkbookReferenceInspection(IVBE vbe, RubberduckParserState
31
25
32
26
private static readonly string [ ] ParentScopes =
33
27
{
34
- "EXCEL.EXE;Excel. _Global" ,
35
- "EXCEL.EXE;Excel. _Application" ,
36
- "EXCEL.EXE;Excel. Sheets" ,
37
- //"EXCEL.EXE;Excel. Worksheets",
28
+ "_Global" ,
29
+ "_Application" ,
30
+ "Sheets" ,
31
+ //"Worksheets",
38
32
} ;
39
33
40
34
public override IEnumerable < InspectionResultBase > GetInspectionResults ( )
41
35
{
42
- if ( _hostApp == null || _hostApp . ApplicationName != "Excel" )
43
- {
44
- return Enumerable . Empty < InspectionResultBase > ( ) ;
45
- // if host isn't Excel, the ExcelObjectModel declarations shouldn't be loaded anyway.
46
- }
47
-
48
36
var issues = BuiltInDeclarations
49
- . Where ( item => ParentScopes . Contains ( item . ParentScope )
37
+ . Where ( item => item . ProjectName == "Excel" && ParentScopes . Contains ( item . ComponentName )
50
38
&& item . References . Any ( r => Targets . Contains ( r . IdentifierName ) ) )
51
39
. SelectMany ( declaration => declaration . References . Distinct ( ) )
52
40
. Where ( item => Targets . Contains ( item . IdentifierName ) )
0 commit comments