@@ -92,24 +92,32 @@ private SearchResultsViewModel CreateViewModel(Declaration declaration)
92
92
private Declaration FindTarget ( object parameter )
93
93
{
94
94
var declaration = parameter as Declaration ;
95
- if ( declaration = = null )
95
+ if ( declaration ! = null )
96
96
{
97
- var selection = _vbe . ActiveCodePane . GetSelection ( ) ;
98
- if ( ! selection . Equals ( default ( QualifiedSelection ) ) )
99
- {
100
- declaration = _state . AllUserDeclarations
101
- . SingleOrDefault ( item => item . QualifiedName . QualifiedModuleName == selection . QualifiedName
102
- && ( item . QualifiedSelection . Selection . ContainsFirstCharacter ( selection . Selection )
103
- ||
104
- item . References . Any ( reference => reference . Selection . ContainsFirstCharacter ( selection . Selection ) ) ) ) ;
105
- }
97
+ return declaration ;
98
+ }
106
99
107
- if ( declaration == null )
108
- {
109
- return null ;
110
- }
100
+ var selection = _vbe . ActiveCodePane . GetSelection ( ) ;
101
+ if ( ! selection . Equals ( default ( QualifiedSelection ) ) )
102
+ {
103
+ declaration = _state . AllDeclarations
104
+ . SingleOrDefault ( item =>
105
+ IsSelectedDeclaration ( selection , item ) ||
106
+ item . References . Any ( reference => IsSelectedReference ( selection , reference ) ) ) ;
111
107
}
112
108
return declaration ;
113
109
}
110
+
111
+ private static bool IsSelectedDeclaration ( QualifiedSelection selection , Declaration declaration )
112
+ {
113
+ return declaration . QualifiedSelection . QualifiedName . Equals ( selection . QualifiedName )
114
+ && declaration . QualifiedSelection . Selection . ContainsFirstCharacter ( selection . Selection ) ;
115
+ }
116
+
117
+ private static bool IsSelectedReference ( QualifiedSelection selection , IdentifierReference reference )
118
+ {
119
+ return reference . QualifiedModuleName . Equals ( selection . QualifiedName )
120
+ && reference . Selection . ContainsFirstCharacter ( selection . Selection ) ;
121
+ }
114
122
}
115
123
}
0 commit comments