private static void WriteBaseMember(StringWriter writer, SymbolSearchResultEntry baseDefinition) { Write(writer, string.Format(@"<div class=""rH"" onclick=""ToggleExpandCollapse(this);return false;"">Base:</div>")); Write(writer, @"<div class=""rK"">"); writer.Write(GetSymbolText(baseDefinition)); writer.Write("</div>"); }
public static string GetSymbolText(SymbolSearchResultEntry searchResult) { var resultText = $@"<a onclick=""LoadSourceCode('{searchResult.Symbol.ProjectId.AsJavaScriptStringEncoded()}', '{searchResult.File.AsJavaScriptStringEncoded()}', '{searchResult.Symbol.Id}');return false;"" href=""/?rightProject={searchResult.Symbol.ProjectId}&rightSymbol={searchResult.Symbol.Id}""> <div class=""resultItem""> <img src=""/content/icons/{searchResult.Glyph}"" height=""16"" width=""16"" /><div class=""resultKind"">{searchResult.Symbol.Kind.ToLowerInvariant()}</div><div class=""resultName"">{searchResult.Symbol.ShortName}</div><div class=""resultDescription"">{searchResult.DisplayName}</div> </div> </a>"; return(resultText); }
private int CompareTermLower(string searchTerm, SymbolSearchResultEntry symbolResultEntry) { var comparisonResult = StringComparer.OrdinalIgnoreCase.Compare(searchTerm, symbolResultEntry.Symbol.ShortName); if (comparisonResult < 0) { if (symbolResultEntry.Symbol.ShortName.StartsWith(searchTerm)) { return(0); } } return(comparisonResult); }
/// <summary> /// This defines the ordering of results based on the kind of symbol and other heuristics /// </summary> public static int SymbolSorter(SymbolSearchResultEntry left, SymbolSearchResultEntry right) { if (left == right) { return(0); } if (left == null || right == null) { return(1); } var comparison = left.MatchLevel.CompareTo(right.MatchLevel); if (comparison != 0) { return(comparison); } comparison = left.KindRank.CompareTo(right.KindRank); if (comparison != 0) { return(comparison); } comparison = right.Rank.CompareTo(left.Rank); if (comparison != 0) { return(comparison); } if (left.Symbol.ShortName != null && right.Symbol.ShortName != null) { comparison = left.Symbol.ShortName.CompareTo(right.Symbol.ShortName); if (comparison != 0) { return(comparison); } } comparison = left.Symbol.ProjectId.CompareTo(right.Symbol.ProjectId); if (comparison != 0) { return(comparison); } comparison = StringComparer.Ordinal.Compare(left.DisplayName, right.DisplayName); return(comparison); }
public static ushort Rank(SymbolSearchResultEntry entry) { var kind = entry.Symbol.Kind.ToLowerInvariant(); switch (kind) { case "class": case "struct": case "interface": case "enum": case "delegate": return(1); case "field": return(3); case "file": return(4); default: return(2); } }
public static SymbolSearchResultEntry Process(this SymbolSearchResultEntry s) { s.Glyph = GetGlyph(s.Span, s.File); return(s); }