Browse Source

Merge pull request #1119 from TheOneAmir/master

Feature Request: Search by abbreviated qualified name #1090
pull/1213/head
Siegfried Pammer 7 years ago committed by GitHub
parent
commit
659e7170d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      ILSpy/SearchStrategies.cs

31
ILSpy/SearchStrategies.cs

@ -113,6 +113,10 @@ namespace ICSharpCode.ILSpy @@ -113,6 +113,10 @@ namespace ICSharpCode.ILSpy
return false;
}
break;
case '~':
if (term.Length > 1 && !IsNoncontiguousMatch(text.ToLower(), term.Substring(1).ToLower()))
return false;
break;
default:
if (text.IndexOf(term, StringComparison.OrdinalIgnoreCase) < 0)
return false;
@ -122,6 +126,33 @@ namespace ICSharpCode.ILSpy @@ -122,6 +126,33 @@ namespace ICSharpCode.ILSpy
return true;
}
bool IsNoncontiguousMatch(string text, string searchTerm)
{
if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(searchTerm)) {
return false;
}
var textLength = text.Length;
if (searchTerm.Length > textLength) {
return false;
}
var i = 0;
for (int searchIndex = 0; searchIndex < searchTerm.Length;) {
while (i != textLength) {
if (text[i] == searchTerm[searchIndex]) {
// Check if all characters in searchTerm have been matched
if (searchTerm.Length == ++searchIndex)
return true;
i++;
break;
}
i++;
}
if (i == textLength)
return false;
}
return false;
}
string GetLanguageSpecificName(Language language, IMemberDefinition member, bool fullName = false)
{
switch (member) {

Loading…
Cancel
Save