Skip to content

Commit 58ad1a5

Browse files
committed
Fixes #934; at least, looks like it.
1 parent 8ef7d8f commit 58ad1a5

File tree

4 files changed

+50
-6
lines changed

4 files changed

+50
-6
lines changed

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public ObservableCollection<CodeExplorerProjectViewModel> Projects
7575
private void ParserState_StateChanged(object sender, ParserStateEventArgs e)
7676
{
7777
IsBusy = e.State == ParserState.Parsing;
78-
if (e.State != ParserState.Resolving) // ParserState.Parsed state is too volatile
78+
if (e.State != ParserState.Parsed) // ParserState.Parsed state is too volatile
7979
{
8080
return;
8181
}

Rubberduck.Parsing/Symbols/Declaration.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public Declaration(QualifiedMemberName qualifiedName, Declaration parentDeclarat
2929
{
3030
_qualifiedName = qualifiedName;
3131
_parentDeclaration = parentDeclaration;
32-
_parentScope = parentScope;
32+
_parentScope = parentScope ?? string.Empty;
3333
_identifierName = qualifiedName.MemberName;
3434
_asTypeName = asTypeName;
3535
_isSelfAssigned = isSelfAssigned;
@@ -467,7 +467,8 @@ public bool Equals(Declaration other)
467467
&& other.IdentifierName == IdentifierName
468468
&& other.DeclarationType == DeclarationType
469469
&& other.Scope == Scope
470-
&& other.ParentScope == ParentScope;
470+
&& other.ParentScope == ParentScope
471+
&& other.Selection.Equals(Selection);
471472
}
472473

473474
public override bool Equals(object obj)
@@ -477,7 +478,17 @@ public override bool Equals(object obj)
477478

478479
public override int GetHashCode()
479480
{
480-
return string.Concat(QualifiedName.QualifiedModuleName.ProjectHashCode, _identifierName, _declarationType, Scope, _parentScope).GetHashCode();
481+
unchecked
482+
{
483+
var hash = 17;
484+
hash = hash*23 + QualifiedName.QualifiedModuleName.ProjectHashCode;
485+
hash = hash*23 + _identifierName.GetHashCode();
486+
hash = hash*23 + _declarationType.GetHashCode();
487+
hash = hash*23 + Scope.GetHashCode();
488+
hash = hash*23 + _parentScope == null ? 0 : _parentScope.GetHashCode();
489+
hash = hash*23 + _selection.GetHashCode();
490+
return hash;
491+
}
481492
}
482493
}
483494
}

Rubberduck.Parsing/Symbols/IdentifierReferenceResolver.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ private Declaration ResolveType(VBAParser.ComplexTypeContext context)
210210

211211
private Declaration ResolveType(Declaration parent)
212212
{
213+
if (parent != null && parent.DeclarationType == DeclarationType.UserDefinedType)
214+
{
215+
return parent;
216+
}
217+
213218
if (parent == null || parent.AsTypeName == null)
214219
{
215220
return null;

Rubberduck.VBEEditor/Selection.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
namespace Rubberduck.VBEditor
1+
using System;
2+
3+
namespace Rubberduck.VBEditor
24
{
3-
public struct Selection
5+
public struct Selection : IEquatable<Selection>
46
{
57
public Selection(int startLine, int startColumn, int endLine, int endColumn)
68
{
@@ -65,9 +67,35 @@ public bool Contains(Selection selection)
6567

6668
public int LineCount { get { return _endLine - _startLine + 1; } }
6769

70+
public bool Equals(Selection other)
71+
{
72+
return other.StartLine == StartLine
73+
&& other.EndLine == EndLine
74+
&& other.StartColumn == StartColumn
75+
&& other.EndColumn == EndColumn;
76+
}
77+
6878
public override string ToString()
6979
{
7080
return string.Format("Start: L{0}C{1} End: L{2}C{3}", _startLine, _startColumn, _endLine, _endColumn);
7181
}
82+
83+
public override bool Equals(object obj)
84+
{
85+
return Equals((Selection) obj);
86+
}
87+
88+
public override int GetHashCode()
89+
{
90+
unchecked
91+
{
92+
var hash = 17;
93+
hash = hash*23 + StartLine;
94+
hash = hash*23 + EndLine;
95+
hash = hash*23 + StartColumn;
96+
hash = hash*23 + EndColumn;
97+
return hash;
98+
}
99+
}
72100
}
73101
}

0 commit comments

Comments
 (0)