diff options
author | Marius Ungureanu <marius.ungureanu@xamarin.com> | 2020-01-15 16:48:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-15 16:48:59 +0300 |
commit | 7943dd66c4b3e3490932ad552e6265f2d41ac055 (patch) | |
tree | f80636945feb9486c49b8199957657bbfad8e04a /main/src | |
parent | 497c1f6b7c216fefbce50bd562bc67a368369aba (diff) |
Simplify SearchCategory tags (#9490)
Diffstat (limited to 'main/src')
4 files changed, 11 insertions, 49 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/CommandSearchCategory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/CommandSearchCategory.cs index 4f6e636415..eacb97fb2d 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/CommandSearchCategory.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/CommandSearchCategory.cs @@ -64,18 +64,8 @@ namespace MonoDevelop.Components.MainToolbar sortOrder = CommandCategoryOrder; } - readonly string[] validTags = { "cmd", "command", "c" }; - - public override string [] Tags { - get { - return validTags; - } - } - - public override bool IsValidTag (string tag) - { - return validTags.Any (t => t == tag); - } + public override string [] Tags { get; } = { "cmd", "command", "c" }; + public override bool IsValidTag (string tag) => Array.IndexOf (Tags, tag) >= 0; public override Task GetResults (ISearchResultCallback searchResultCallback, SearchPopupSearchPattern pattern, CancellationToken token) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs index 76e923f2ac..9c8875a4d6 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/FileSearchCategory.cs @@ -86,18 +86,8 @@ namespace MonoDevelop.Components.MainToolbar return list; } - string [] validTags = new [] { "file", "f" }; - - public override string [] Tags { - get { - return validTags; - } - } - - public override bool IsValidTag (string tag) - { - return validTags.Any (t => t == tag); - } + public override string [] Tags { get; } = { "file", "f" }; + public override bool IsValidTag (string tag) => Array.IndexOf (Tags, tag) >= 0; static List<Tuple<string, string, ProjectFile>> allFilesCache; static SemaphoreSlim allFilesLock = new SemaphoreSlim (1, 1); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/RoslynSearchCategory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/RoslynSearchCategory.cs index 4bbded7af5..c34ef49227 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/RoslynSearchCategory.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/RoslynSearchCategory.cs @@ -56,23 +56,14 @@ namespace MonoDevelop.Components.MainToolbar sortOrder = FirstCategoryOrder;
}
- static readonly string [] tags = new [] {
+ public override string [] Tags { get; } = new [] {
// Types
"type", "t", "class", "struct", "interface", "enum", "delegate",
// Members
"member", "m", "method", "property", "field", "event"
- };
-
- public override string [] Tags {
- get {
- return tags;
- }
- }
-
- public override bool IsValidTag (string tag)
- {
- return tags.Contains (tag);
- }
+ }; + + public override bool IsValidTag (string tag) => Array.IndexOf (Tags, tag) >= 0;
static readonly IImmutableSet<string> typeKinds = ImmutableHashSet.Create (
NavigateToItemKind.Class,
@@ -154,7 +145,7 @@ namespace MonoDevelop.Components.MainToolbar if (string.IsNullOrEmpty (searchPattern.Pattern))
return Task.CompletedTask;
- if (searchPattern.Tag != null && !tags.Contains (searchPattern.Tag) || searchPattern.HasLineNumber)
+ if (searchPattern.Tag != null && Array.IndexOf (Tags, searchPattern.Tag) < 0 || searchPattern.HasLineNumber)
return Task.CompletedTask;
return Task.Run (async delegate {
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchInSolutionSearchCategory.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchInSolutionSearchCategory.cs index d3d6474915..ec317bad20 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchInSolutionSearchCategory.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Components.MainToolbar/SearchInSolutionSearchCategory.cs @@ -59,18 +59,9 @@ namespace MonoDevelop.Components.MainToolbar // return (ISearchDataSource)new SearchInSolutionDataSource (searchPattern); // }); //} - static readonly string[] tags = { "search" }; + public override string [] Tags { get; } = { "search" }; - public override string[] Tags { - get { - return tags; - } - } - - public override bool IsValidTag (string tag) - { - return tag == "search"; - } + public override bool IsValidTag (string tag) => tag == "search"; class SearchInSolutionSearchResult : SearchResult { |