public static QueryTermTypeList ExamineQuery(string query) { string[] terms = query.Split(' '); QueryTermTypeList queryTypes = new QueryTermTypeList(); bool quotesOn = false; for (int i = 0, j = 0; i < terms.Length; i++) { if (quotesOn) { queryTypes[j] |= QueryTermType.Quoted; } else { queryTypes[j] = QueryTermType.None; } if (terms[i] == "-") { queryTypes[j + 1] |= QueryTermType.Minus; } else if (terms[i] == "\"") { quotesOn = !quotesOn; } else { if (terms[i].StartsWith("-")) { queryTypes[j] |= QueryTermType.Minus; } if (terms[i].StartsWith("\"")) { quotesOn = !quotesOn; if (quotesOn) { queryTypes[j] |= QueryTermType.Quoted; } else { queryTypes[j] ^= QueryTermType.Quoted; } } if (terms[i].StartsWith("filetype\\:")) { queryTypes[j] |= QueryTermType.Filetype; } if (terms[i].EndsWith("\"")) { quotesOn = !quotesOn; } if (_patternCamel.IsMatch(terms[i])) { queryTypes[j] |= QueryTermType.Camelcase; } if (_patternAcronym.IsMatch(terms[i])) { queryTypes[j] |= QueryTermType.Acronym; } if (terms[i].Contains('_')) { queryTypes[j] |= QueryTermType.Underscore; } j++; } } return(queryTypes); }
public static QueryTermTypeList ExamineQuery(string query) { string[] terms = query.Split(' '); QueryTermTypeList queryTypes = new QueryTermTypeList(); bool quotesOn = false; for (int i = 0, j = 0; i < terms.Length; i++) { if (quotesOn) { queryTypes[j] |= QueryTermType.Quoted; } else { queryTypes[j] = QueryTermType.None; } if (terms[i] == "-") { queryTypes[j+1] |= QueryTermType.Minus; } else if (terms[i] == "\"") { quotesOn = !quotesOn; } else { if (terms[i].StartsWith("-")) { queryTypes[j] |= QueryTermType.Minus; } if (terms[i].StartsWith("\"")) { quotesOn = !quotesOn; if (quotesOn) { queryTypes[j] |= QueryTermType.Quoted; } else { queryTypes[j] ^= QueryTermType.Quoted; } } if (terms[i].StartsWith("filetype\\:")) { queryTypes[j] |= QueryTermType.Filetype; } if (terms[i].EndsWith("\"")) { quotesOn = !quotesOn; } if (_patternCamel.IsMatch(terms[i])) { queryTypes[j] |= QueryTermType.Camelcase; } if (_patternAcronym.IsMatch(terms[i])) { queryTypes[j] |= QueryTermType.Acronym; } if (terms[i].Contains('_')) { queryTypes[j] |= QueryTermType.Underscore; } j++; } } return queryTypes; }