Browse Source

manually merge #488 - Change type search to match FullNames in addition to just the type name

pull/550/head
Siegfried Pammer 10 years ago
parent
commit
d942200adf
  1. 37
      ILSpy/SearchPane.cs
  2. 5
      ILSpy/SearchStrategies.cs

37
ILSpy/SearchPane.cs

@ -55,17 +55,13 @@ namespace ICSharpCode.ILSpy @@ -55,17 +55,13 @@ namespace ICSharpCode.ILSpy
}
}
public const int SearchMode_Type = 0;
public const int SearchMode_Member = 1;
public const int SearchMode_Literal = 2;
private SearchPane()
{
InitializeComponent();
searchModeComboBox.Items.Add(new { Image = Images.Class, Name = "Type" });
searchModeComboBox.Items.Add(new { Image = Images.Property, Name = "Member" });
searchModeComboBox.Items.Add(new { Image = Images.Literal, Name = "Constant" });
searchModeComboBox.SelectedIndex = SearchMode_Type;
searchModeComboBox.SelectedIndex = (int)SearchMode.Type;
MainWindow.Instance.CurrentAssemblyListChanged += MainWindow_Instance_CurrentAssemblyListChanged;
}
@ -129,7 +125,7 @@ namespace ICSharpCode.ILSpy @@ -129,7 +125,7 @@ namespace ICSharpCode.ILSpy
listBox.ItemsSource = null;
} else {
MainWindow mainWindow = MainWindow.Instance;
currentSearch = new RunningSearch(mainWindow.CurrentAssemblyList.GetAssemblies(), searchTerm, searchModeComboBox.SelectedIndex, mainWindow.CurrentLanguage);
currentSearch = new RunningSearch(mainWindow.CurrentAssemblyList.GetAssemblies(), searchTerm, (SearchMode)searchModeComboBox.SelectedIndex, mainWindow.CurrentLanguage);
listBox.ItemsSource = currentSearch.Results;
new Thread(currentSearch.Run).Start();
}
@ -166,13 +162,13 @@ namespace ICSharpCode.ILSpy @@ -166,13 +162,13 @@ namespace ICSharpCode.ILSpy
{
base.OnKeyDown(e);
if (e.Key == Key.T && e.KeyboardDevice.Modifiers == ModifierKeys.Control) {
searchModeComboBox.SelectedIndex = SearchMode_Type;
searchModeComboBox.SelectedIndex = (int)SearchMode.Type;
e.Handled = true;
} else if (e.Key == Key.M && e.KeyboardDevice.Modifiers == ModifierKeys.Control) {
searchModeComboBox.SelectedIndex = SearchMode_Member;
searchModeComboBox.SelectedIndex = (int)SearchMode.Member;
e.Handled = true;
} else if (e.Key == Key.S && e.KeyboardDevice.Modifiers == ModifierKeys.Control) {
searchModeComboBox.SelectedIndex = SearchMode_Literal;
searchModeComboBox.SelectedIndex = (int)SearchMode.Literal;
e.Handled = true;
}
}
@ -192,12 +188,12 @@ namespace ICSharpCode.ILSpy @@ -192,12 +188,12 @@ namespace ICSharpCode.ILSpy
readonly CancellationTokenSource cts = new CancellationTokenSource();
readonly LoadedAssembly[] assemblies;
readonly string[] searchTerm;
readonly int searchMode;
readonly SearchMode searchMode;
readonly Language language;
public readonly ObservableCollection<SearchResult> Results = new ObservableCollection<SearchResult>();
int resultCount;
public RunningSearch(LoadedAssembly[] assemblies, string searchTerm, int searchMode, Language language)
public RunningSearch(LoadedAssembly[] assemblies, string searchTerm, SearchMode searchMode, Language language)
{
this.dispatcher = Dispatcher.CurrentDispatcher;
this.assemblies = assemblies;
@ -248,8 +244,8 @@ namespace ICSharpCode.ILSpy @@ -248,8 +244,8 @@ namespace ICSharpCode.ILSpy
new Action(delegate { this.Results.Insert(this.Results.Count - 1, result); }));
cts.Token.ThrowIfCancellationRequested();
}
AbstractSearchStrategy GetSearchStrategy(int mode, string[] terms)
AbstractSearchStrategy GetSearchStrategy(SearchMode mode, string[] terms)
{
if (terms.Length == 1) {
if (terms[0].StartsWith("t:"))
@ -263,11 +259,11 @@ namespace ICSharpCode.ILSpy @@ -263,11 +259,11 @@ namespace ICSharpCode.ILSpy
}
switch (mode) {
case SearchMode_Type:
case SearchMode.Type:
return new TypeSearchStrategy(terms);
case SearchMode_Member:
case SearchMode.Member:
return new MemberSearchStrategy(terms);
case SearchMode_Literal:
case SearchMode.Literal:
return new LiteralSearchStrategy(terms);
}
@ -305,4 +301,11 @@ namespace ICSharpCode.ILSpy @@ -305,4 +301,11 @@ namespace ICSharpCode.ILSpy
{
}
}
public enum SearchMode
{
Type,
Member,
Literal
}
}

5
ILSpy/SearchStrategies.cs

@ -316,9 +316,8 @@ namespace ICSharpCode.ILSpy @@ -316,9 +316,8 @@ namespace ICSharpCode.ILSpy
public override void Search(TypeDefinition type, Language language, Action<SearchResult> addResult)
{
if (IsMatch(type.Name)) {
addResult(new SearchResult
{
if (IsMatch(type.Name) || IsMatch(type.FullName)) {
addResult(new SearchResult {
Member = type,
Image = TypeTreeNode.GetIcon(type),
Name = language.TypeToString(type, includeNamespace: false),

Loading…
Cancel
Save