| 1 | #nullable enable |
| 2 | using System.Globalization; |
| 3 | |
| 4 | namespace CascadeIDE.Features.WorkspaceNavigation.Application; |
| 5 | |
| 6 | /// <summary>Одна строка для UI: компактная подпись ориентации HCI без дублирования логики индекса.</summary> |
| 7 | public static class SemanticMapHciOrientationFormatting |
| 8 | { |
| 9 | /// <summary>Пустая строка — не показывать блок в UI.</summary> |
| 10 | public static string ToStatusLine(SemanticMapHciOrientationSnapshot? snap) |
| 11 | { |
| 12 | if (snap is null) |
| 13 | return ""; |
| 14 | |
| 15 | if (!string.IsNullOrEmpty(snap.Error)) |
| 16 | return "HCI (ориентация): " + snap.Error.Trim(); |
| 17 | |
| 18 | if (snap.Hits.Count == 0) |
| 19 | return ""; |
| 20 | |
| 21 | static string One(SemanticMapHciOrientationHit h) |
| 22 | { |
| 23 | var sn = (h.Snippet ?? "").Replace('\r', ' ').Replace('\n', ' ').Trim(); |
| 24 | if (sn.Length > 42) |
| 25 | sn = sn[..39] + "…"; |
| 26 | return $"{h.LeafPath}:{h.Line.ToString(CultureInfo.InvariantCulture)} ({h.HitKind}) {sn}"; |
| 27 | } |
| 28 | |
| 29 | var head = One(snap.Hits[0]); |
| 30 | if (snap.Hits.Count == 1) |
| 31 | return $"HCI (ориентация) «{snap.Query}»: {head}"; |
| 32 | |
| 33 | return $"HCI (ориентация) «{snap.Query}»: {head} +{snap.Hits.Count - 1}"; |
| 34 | } |
| 35 | } |
| 36 | |
View only · write via MCP/CIDE