Browse Source

Merge pull request #311 from RKlier/search

Search for multiple strings separate by space
pull/310/merge
Daniel Grunwald 14 years ago
parent
commit
2370f8c61f
  1. 17
      ILSpy/SearchPane.cs

17
ILSpy/SearchPane.cs

@ -185,7 +185,7 @@ namespace ICSharpCode.ILSpy @@ -185,7 +185,7 @@ namespace ICSharpCode.ILSpy
readonly Dispatcher dispatcher;
readonly CancellationTokenSource cts = new CancellationTokenSource();
readonly LoadedAssembly[] assemblies;
readonly string searchTerm;
readonly string[] searchTerm;
readonly int searchMode;
readonly Language language;
public readonly ObservableCollection<SearchResult> Results = new ObservableCollection<SearchResult>();
@ -198,7 +198,7 @@ namespace ICSharpCode.ILSpy @@ -198,7 +198,7 @@ namespace ICSharpCode.ILSpy
{
this.dispatcher = Dispatcher.CurrentDispatcher;
this.assemblies = assemblies;
this.searchTerm = searchTerm;
this.searchTerm = searchTerm.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
this.language = language;
this.searchMode = searchMode;
@ -214,8 +214,10 @@ namespace ICSharpCode.ILSpy @@ -214,8 +214,10 @@ namespace ICSharpCode.ILSpy
{
try {
if (searchMode == SearchMode_Literal) {
if (1 == searchTerm.Length)
{
CSharpParser parser = new CSharpParser();
PrimitiveExpression pe = parser.ParseExpression(new StringReader(searchTerm)) as PrimitiveExpression;
PrimitiveExpression pe = parser.ParseExpression(new StringReader(searchTerm[0])) as PrimitiveExpression;
if (pe != null && pe.Value != null) {
TypeCode peValueType = Type.GetTypeCode(pe.Value.GetType());
switch (peValueType) {
@ -239,6 +241,7 @@ namespace ICSharpCode.ILSpy @@ -239,6 +241,7 @@ namespace ICSharpCode.ILSpy
}
}
}
}
foreach (var loadedAssembly in assemblies) {
AssemblyDefinition asm = loadedAssembly.AssemblyDefinition;
@ -273,11 +276,13 @@ namespace ICSharpCode.ILSpy @@ -273,11 +276,13 @@ namespace ICSharpCode.ILSpy
bool IsMatch(string text)
{
if (text.IndexOf(searchTerm, StringComparison.OrdinalIgnoreCase) >= 0)
return true;
else
for (int i = 0; i < searchTerm.Length; ++i) {
// How to handle overlapping matches?
if (text.IndexOf(searchTerm[i], StringComparison.OrdinalIgnoreCase) < 0)
return false;
}
return true;
}
void PerformSearch(TypeDefinition type)
{

Loading…
Cancel
Save