Skip to content

Commit 06c13bb

Browse files
authored
Merge pull request #2318 from retailcoder/next
minor fixes
2 parents 6885d09 + 6208b5b commit 06c13bb

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
lines changed

RetailCoder.VBE/Inspections/ImplicitActiveSheetReferenceInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
4040
item.AsTypeName == "Range").ToList();
4141

4242
var issues = matches.Where(item => item.References.Any())
43-
.SelectMany(declaration => declaration.References);
43+
.SelectMany(declaration => declaration.References.Distinct());
4444

4545
return issues.Select(issue =>
4646
new ImplicitActiveSheetReferenceInspectionResult(this, issue));

RetailCoder.VBE/Inspections/ImplicitActiveWorkbookReferenceInspection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
3737
{
3838
if (_hostApp == null || _hostApp.ApplicationName != "Excel")
3939
{
40-
return new InspectionResultBase[] { };
40+
return Enumerable.Empty<InspectionResultBase>();
4141
// if host isn't Excel, the ExcelObjectModel declarations shouldn't be loaded anyway.
4242
}
4343

4444
var issues = BuiltInDeclarations.Where(item => ParentScopes.Contains(item.ParentScope)
4545
&& Targets.Contains(item.IdentifierName)
4646
&& item.References.Any())
47-
.SelectMany(declaration => declaration.References);
47+
.SelectMany(declaration => declaration.References.Distinct());
4848

4949
return issues.Select(issue =>
5050
new ImplicitActiveWorkbookReferenceInspectionResult(this, issue));

RetailCoder.VBE/UI/Command/FindAllReferencesCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ protected override void ExecuteImpl(object parameter)
140140

141141
private SearchResultsViewModel CreateViewModel(Declaration declaration)
142142
{
143-
var results = declaration.References.Select(reference =>
143+
var results = declaration.References.Distinct().Select(reference =>
144144
new SearchResultItem(
145145
reference.ParentNonScoping,
146146
new NavigateCodeEventArgs(reference.QualifiedModuleName, reference.Selection),

Rubberduck.Parsing/Symbols/IdentifierReference.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
using System.Collections.Generic;
66
using System.Linq;
77
using System.Diagnostics;
8+
using System;
89

910
namespace Rubberduck.Parsing.Symbols
1011
{
1112
[DebuggerDisplay("({IdentifierName}) IsAss:{IsAssignment} | {Selection} ")]
12-
public class IdentifierReference
13+
public class IdentifierReference : IEquatable<IdentifierReference>
1314
{
1415
public IdentifierReference(
1516
QualifiedModuleName qualifiedName,
@@ -124,5 +125,23 @@ public bool IsSelected(QualifiedSelection selection)
124125
return QualifiedModuleName == selection.QualifiedName &&
125126
Selection.ContainsFirstCharacter(selection.Selection);
126127
}
128+
129+
public bool Equals(IdentifierReference other)
130+
{
131+
return other != null
132+
&& other.QualifiedModuleName.Equals(QualifiedModuleName)
133+
&& other.Selection.Equals(Selection)
134+
&& other.Declaration.Equals(Declaration);
135+
}
136+
137+
public override bool Equals(object obj)
138+
{
139+
return Equals(obj as IdentifierReference);
140+
}
141+
142+
public override int GetHashCode()
143+
{
144+
return HashCode.Compute(QualifiedModuleName, Selection, Declaration);
145+
}
127146
}
128147
}

Rubberduck.Parsing/Symbols/ReferencedDeclarationsCollector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public ReferencedDeclarationsCollector(RubberduckParserState state)
6060

6161
private static readonly IDictionary<VarEnum, string> TypeNames = new Dictionary<VarEnum, string>
6262
{
63-
{VarEnum.VT_DISPATCH, "DISPATCH"},
63+
{VarEnum.VT_DISPATCH, "Object"},
6464
{VarEnum.VT_VOID, string.Empty},
6565
{VarEnum.VT_VARIANT, "Variant"},
6666
{VarEnum.VT_BLOB_OBJECT, "Object"},

0 commit comments

Comments
 (0)