Skip to content

Commit 2395914

Browse files
committed
fixed magic strings
1 parent 71847aa commit 2395914

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

RetailCoder.VBE/Inspections/ImplicitActiveSheetReferenceInspection.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
3838
}
3939

4040
var matches = BuiltInDeclarations.Where(item =>
41+
item.ProjectName == "Excel" &&
4142
Targets.Contains(item.IdentifierName) &&
42-
item.ParentScope == "EXCEL.EXE;Excel._Global" &&
43+
item.ParentDeclaration.ComponentName == "Global" &&
4344
item.AsTypeName == "Range").ToList();
4445

4546
var issues = matches.Where(item => item.References.Any())

RetailCoder.VBE/Inspections/ImplicitActiveWorkbookReferenceInspection.cs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,14 @@
44
using Rubberduck.Inspections.Resources;
55
using Rubberduck.Inspections.Results;
66
using Rubberduck.Parsing.VBA;
7-
using Rubberduck.VBEditor.Application;
8-
using Rubberduck.VBEditor.Extensions;
9-
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
107

118
namespace Rubberduck.Inspections
129
{
1310
public sealed class ImplicitActiveWorkbookReferenceInspection : InspectionBase
1411
{
15-
private readonly IHostApplication _hostApp;
16-
17-
public ImplicitActiveWorkbookReferenceInspection(IVBE vbe, RubberduckParserState state)
12+
public ImplicitActiveWorkbookReferenceInspection(RubberduckParserState state)
1813
: base(state)
1914
{
20-
_hostApp = vbe.HostApplication();
2115
}
2216

2317
public override string Meta { get { return InspectionsUI.ImplicitActiveWorkbookReferenceInspectionMeta; } }
@@ -31,22 +25,16 @@ public ImplicitActiveWorkbookReferenceInspection(IVBE vbe, RubberduckParserState
3125

3226
private static readonly string[] ParentScopes =
3327
{
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",
3832
};
3933

4034
public override IEnumerable<InspectionResultBase> GetInspectionResults()
4135
{
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-
4836
var issues = BuiltInDeclarations
49-
.Where(item => ParentScopes.Contains(item.ParentScope)
37+
.Where(item => item.ProjectName == "Excel" && ParentScopes.Contains(item.ComponentName)
5038
&& item.References.Any(r => Targets.Contains(r.IdentifierName)))
5139
.SelectMany(declaration => declaration.References.Distinct())
5240
.Where(item => Targets.Contains(item.IdentifierName))

Rubberduck.Parsing/VBA/RubberduckParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ private void ResolveReferences(DeclarationFinder finder, IVBComponent component,
654654
var watch = Stopwatch.StartNew();
655655
walker.Walk(listener, tree);
656656
watch.Stop();
657-
Logger.Debug("Binding Resolution done for component '{0}' in {1}ms (thread {2})", component.Name,
657+
Logger.Debug("Binding resolution done for component '{0}' in {1}ms (thread {2})", component.Name,
658658
watch.ElapsedMilliseconds, Thread.CurrentThread.ManagedThreadId);
659659

660660
State.SetModuleState(component, ParserState.Ready);

0 commit comments

Comments
 (0)