public Interpretation Clone() { var newInterpretation = new Interpretation(); newInterpretation.CoreSearchTerm = CoreSearchTerm; newInterpretation.IsVerbatim = IsVerbatim; newInterpretation.Namespace = Namespace; newInterpretation.FilterNames = new List<string>(FilterNames); newInterpretation.FilterDotSeparatedNames = new List<string>(FilterDotSeparatedNames); return newInterpretation; }
private void FindSymbols(Query query, Interpretation interpretation) { string searchTerm = interpretation.CoreSearchTerm; var search = new SortedSearch(i => symbols[i].Name, symbols.Count); int low, high; search.FindBounds(searchTerm, out low, out high); if (high < low) { return; } query.PotentialRawResults = high - low + 1; var result = Enumerable .Range(low, high - low + 1) .Where(i => !interpretation.IsVerbatim || symbols[i].Name.Length == searchTerm.Length) .Select(i => symbols[i].GetDeclaredSymbolInfo(huffman, assemblies, projects)) .Where(query.Filter) .Where(interpretation.Filter) .Take(MaxRawResults) .ToList(); foreach (var entry in result) { entry.MatchLevel = MatchLevel(entry.Name, searchTerm); } query.AddResultSymbols(result); }
private void BuildInterpretations() { foreach (var name in this.Names.Where(n => n.Length >= 3)) { string text = name; var interpretation = new Interpretation(); bool isQuoted = false; text = StripQuotes(text, out isQuoted); interpretation.CoreSearchTerm = text; interpretation.IsVerbatim = isQuoted; foreach (var otherName in this.Names.Where(n => n != text)) { interpretation.FilterNames.Add(otherName.StripQuotes()); } foreach (var dottedName in this.DotSeparatedNames) { interpretation.FilterDotSeparatedNames.Add(dottedName.StripQuotes()); } this.Interpretations.Add(interpretation); AddPossibleInterpretationWithoutClrPrefix(interpretation); } foreach (var dottedName in this.DotSeparatedNames) { bool isQuoted = false; string dottedNameText = StripQuotes(dottedName, out isQuoted); var lastPart = GetLastPart(dottedNameText); // is it a file name? var lastPartLower = lastPart.ToLowerInvariant(); if (supportedFileExtensions.Any(extension => extension.StartsWith(lastPartLower))) { var fileInterpretation = new Interpretation(); fileInterpretation.CoreSearchTerm = dottedNameText; fileInterpretation.IsVerbatim = isQuoted; this.Interpretations.Add(fileInterpretation); continue; } var interpretation = new Interpretation(); interpretation.CoreSearchTerm = lastPart; interpretation.IsVerbatim = isQuoted; interpretation.Namespace = dottedNameText; foreach (var name in this.Names) { interpretation.FilterNames.Add(name.StripQuotes()); } foreach (var otherDottedName in this.DotSeparatedNames.Where(i => i != dottedNameText)) { interpretation.FilterDotSeparatedNames.Add(otherDottedName.StripQuotes()); } this.Interpretations.Add(interpretation); AddPossibleInterpretationWithoutClrPrefix(interpretation); } }
private Interpretation InterpretWithoutGetOrSet(Interpretation interpretation) { if (string.IsNullOrEmpty(interpretation.CoreSearchTerm)) { return null; } foreach (var prefix in prefixes) { if (interpretation.CoreSearchTerm.StartsWith(prefix)) { var clone = interpretation.Clone(); clone.CoreSearchTerm = clone.CoreSearchTerm.Substring(prefix.Length); if (clone.Namespace != null) { clone.Namespace = clone.Namespace.Replace(prefix, ""); } return clone; } } return null; }
private void AddPossibleInterpretationWithoutClrPrefix(Interpretation interpretation) { var maybeWithoutGetOrSet = InterpretWithoutGetOrSet(interpretation); if (maybeWithoutGetOrSet != null) { this.Interpretations.Add(maybeWithoutGetOrSet); } }