Forge
csharpdeeb25a2
1#nullable enable
2
3namespace CascadeIDE.Features.Chat;
4
5/// <summary>Единственная точка маппинга <see cref="SlashCommandPreviewKind"/> → chrome severity (P0).</summary>
6public static class SlashCommandPreviewVisualMapper
7{
8 public static SlashPreviewChromeSeverity ToChromeSeverity(SlashCommandPreviewKind kind) =>
9 kind switch
10 {
11 SlashCommandPreviewKind.Ok => SlashPreviewChromeSeverity.Success,
12 SlashCommandPreviewKind.Incomplete => SlashPreviewChromeSeverity.Warning,
13 SlashCommandPreviewKind.Error => SlashPreviewChromeSeverity.Error,
14 SlashCommandPreviewKind.Hint => SlashPreviewChromeSeverity.Info,
15 SlashCommandPreviewKind.None => SlashPreviewChromeSeverity.None,
16 _ => throw new ArgumentOutOfRangeException(nameof(kind), kind, "Unmapped SlashCommandPreviewKind."),
17 };
18
19 public static bool ShouldDrawChip(SlashCommandPreviewKind kind, string? text) =>
20 ToChromeSeverity(kind) != SlashPreviewChromeSeverity.None
21 && !string.IsNullOrWhiteSpace(text)
22 && text.TrimStart().StartsWith('/');
23
24 /// <summary>Все значения enum, кроме <see cref="SlashCommandPreviewKind.None"/>.</summary>
25 public static IReadOnlyList<SlashCommandPreviewKind> NonNoneKinds { get; } =
26 Enum.GetValues<SlashCommandPreviewKind>()
27 .Where(static k => k != SlashCommandPreviewKind.None)
28 .ToArray();
29}
30
View only · write via MCP/CIDE