internal static bool ParseSearchString(string searchText, SearchFilter filter) { bool result; if (string.IsNullOrEmpty(searchText)) { result = false; } else { filter.ClearSearch(); string text = string.Copy(searchText); SearchUtility.RemoveUnwantedWhitespaces(ref text); bool flag = false; int i = SearchUtility.FindFirstPositionNotOf(text, " \t,*?"); if (i == -1) { i = 0; } while (i < text.Length) { int num = text.IndexOfAny(" \t,*?".ToCharArray(), i); int num2 = text.IndexOf('"', i); int num3 = -1; if (num2 != -1) { num3 = text.IndexOf('"', num2 + 1); if (num3 != -1) { num = text.IndexOfAny(" \t,*?".ToCharArray(), num3); } else { num = -1; } } if (num == -1) { num = text.Length; } if (num > i) { string text2 = text.Substring(i, num - i); if (SearchUtility.CheckForKeyWords(text2, filter, num2, num3)) { flag = true; } else { filter.nameFilter = filter.nameFilter + ((!string.IsNullOrEmpty(filter.nameFilter)) ? " " : "") + text2; } } i = num + 1; } result = flag; } return(result); }
internal static bool ParseSearchString(string searchText, SearchFilter filter) { if (string.IsNullOrEmpty(searchText)) { return(false); } filter.ClearSearch(); string searchString = string.Copy(searchText); RemoveUnwantedWhitespaces(ref searchString); bool flag = false; int startIndex = FindFirstPositionNotOf(searchString, " \t,"); if (startIndex == -1) { startIndex = 0; } while (startIndex < searchString.Length) { int length = searchString.IndexOfAny(" \t,".ToCharArray(), startIndex); int index = searchString.IndexOf('"', startIndex); int num4 = -1; if (index != -1) { num4 = searchString.IndexOf('"', index + 1); if (num4 != -1) { length = searchString.IndexOfAny(" \t,".ToCharArray(), num4); } else { length = -1; } } if (length == -1) { length = searchString.Length; } if (length > startIndex) { string str3 = searchString.Substring(startIndex, length - startIndex); if (ParseSingleWord(str3, filter, index, num4)) { flag = true; } else { filter.nameFilter = filter.nameFilter + (!string.IsNullOrEmpty(filter.nameFilter) ? " " : string.Empty) + str3; } } startIndex = length + 1; } return(flag); }
internal static bool ParseSearchString(string searchText, SearchFilter filter) { if (string.IsNullOrEmpty(searchText)) { return(false); } filter.ClearSearch(); string searchString1 = string.Copy(searchText); SearchUtility.RemoveUnwantedWhitespaces(ref searchString1); bool flag = false; int startIndex = SearchUtility.FindFirstPositionNotOf(searchString1, " \t,"); if (startIndex == -1) { startIndex = 0; } int num1; for (; startIndex < searchString1.Length; startIndex = num1 + 1) { num1 = searchString1.IndexOfAny(" \t,".ToCharArray(), startIndex); int quote1 = searchString1.IndexOf('"', startIndex); int num2 = -1; if (quote1 != -1) { num2 = searchString1.IndexOf('"', quote1 + 1); num1 = num2 == -1 ? -1 : searchString1.IndexOfAny(" \t,".ToCharArray(), num2); } if (num1 == -1) { num1 = searchString1.Length; } if (num1 > startIndex) { string searchString2 = searchString1.Substring(startIndex, num1 - startIndex); if (SearchUtility.CheckForKeyWords(searchString2, filter, quote1, num2)) { flag = true; } else { SearchFilter searchFilter = filter; string str = searchFilter.nameFilter + (!string.IsNullOrEmpty(filter.nameFilter) ? " " : string.Empty) + searchString2; searchFilter.nameFilter = str; } } } return(flag); }
// Supports the following syntax: // 't:type' syntax (e.g 't:Texture2D' will show Texture2D objects) // 'l:assetlabel' syntax (e.g 'l:architecture' will show assets with AssetLabel 'architecture') // 'ref[:id]:path' syntax (e.g 'ref:1234' will show objects that references the object with instanceID 1234) // 'v:versionState' syntax (e.g 'v:modified' will show objects that are modified locally) // 's:softLockState' syntax (e.g 's:inprogress' will show objects that are modified by anyone (except you)) // 'a:area' syntax (e.g 'a:all' will s search in all assets, 'a:assets' will s search in assets folder only and 'a:packages' will s search in packages folder only) // 'glob:path' syntax (e.g 'glob:Assets/**/*.{png|PNG}' will show objects in any subfolder with name ending by .png or .PNG) internal static bool ParseSearchString(string searchText, SearchFilter filter) { if (string.IsNullOrEmpty(searchText)) { return(false); } filter.ClearSearch(); filter.originalText = searchText; string searchString = string.Copy(searchText); RemoveUnwantedWhitespaces(ref searchString); bool parsed = false; // Split filter into separate words with space or tab as seperators const string kFilterSeparator = " \t,*?"; // Skip any separators preceding the filter int pos = FindFirstPositionNotOf(searchString, kFilterSeparator); if (pos == -1) { pos = 0; } while (pos < searchString.Length) { int endpos = searchString.IndexOfAny(kFilterSeparator.ToCharArray(), pos); if (endpos == -1) { endpos = searchString.Length; } // Check if we have quotes (may be used for pathnames) inbetween start and a /filter-separator/ int q1 = searchString.IndexOf('"', pos); int q2 = -1; if (q1 != -1 && q1 < endpos) { q2 = searchString.IndexOf('"', q1 + 1); if (q2 != -1 && q2 > endpos - 1) { // Advance to a /filter-separator/ after the quote endpos = searchString.IndexOfAny(kFilterSeparator.ToCharArray(), q2); if (endpos == -1) { endpos = searchString.Length; } } } if (endpos > pos) { string token = searchString.Substring(pos, endpos - pos); if (CheckForKeyWords(token, filter, q1 - pos, q2 - pos)) { parsed = true; } else { filter.nameFilter += (string.IsNullOrEmpty(filter.nameFilter) ? "" : " ") + token; // force single space between name tokens } } pos = endpos + 1; } return(parsed); }