| 1 | namespace CascadeIDE.Features.Editor.Application.Monaco; |
| 2 | |
| 3 | /// <summary>CECB contract (ADR 0163 §2.2, §2.6). Shared with <c>bus-manifest.js</c>.</summary> |
| 4 | public static class CideEditorBusManifest |
| 5 | { |
| 6 | public static class SetIds |
| 7 | { |
| 8 | public const string Diagnostics = "diagnostics"; |
| 9 | public const string Highlights = "highlights"; |
| 10 | public const string Breakpoints = "breakpoints"; |
| 11 | public const string DebugLine = "debugLine"; |
| 12 | public const string AgentReveal = "agentReveal"; |
| 13 | public const string CfGutter = "cfGutter"; |
| 14 | |
| 15 | /// <summary>Legacy bridge id; maps to <see cref="DebugLine"/>.</summary> |
| 16 | public const string DebugLineLegacy = "debug-line"; |
| 17 | |
| 18 | /// <summary>Legacy bridge id; maps to <see cref="AgentReveal"/>.</summary> |
| 19 | public const string AgentRevealLegacy = "agent-reveal"; |
| 20 | |
| 21 | public static string Normalize(string? setId) => |
| 22 | setId switch |
| 23 | { |
| 24 | DebugLineLegacy => DebugLine, |
| 25 | AgentRevealLegacy => AgentReveal, |
| 26 | "cf-gutter" => CfGutter, |
| 27 | _ => setId ?? "default", |
| 28 | }; |
| 29 | } |
| 30 | |
| 31 | public static class Capabilities |
| 32 | { |
| 33 | public const string Completion = "capability/completion"; |
| 34 | public const string Hover = "capability/hover"; |
| 35 | public const string SignatureHelp = "capability/signatureHelp"; |
| 36 | public const string Definition = "capability/definition"; |
| 37 | public const string References = "capability/references"; |
| 38 | public const string Format = "capability/format"; |
| 39 | public const string CodeAction = "capability/codeAction"; |
| 40 | public const string CodeActionApply = "capability/codeActionApply"; |
| 41 | public const string Rename = "capability/rename"; |
| 42 | public const string Navigate = "capability/navigate"; |
| 43 | public const string InlayHints = "capability/inlayHints"; |
| 44 | public const string CodeLens = "capability/codeLens"; |
| 45 | public const string CodeLensClick = "capability/codeLensClick"; |
| 46 | public const string SemanticTokens = "capability/semanticTokens"; |
| 47 | |
| 48 | public const string CompletionResult = "capability/completionResult"; |
| 49 | public const string HoverResult = "capability/hoverResult"; |
| 50 | public const string SignatureResult = "capability/signatureResult"; |
| 51 | public const string DefinitionResult = "capability/definitionResult"; |
| 52 | public const string ReferencesResult = "capability/referencesResult"; |
| 53 | public const string FormatResult = "capability/formatResult"; |
| 54 | public const string CodeActionResult = "capability/codeActionResult"; |
| 55 | public const string WorkspaceEditResult = "capability/workspaceEditResult"; |
| 56 | public const string InlayHintsResult = "capability/inlayHintsResult"; |
| 57 | public const string CodeLensResult = "capability/codeLensResult"; |
| 58 | public const string SemanticTokensResult = "capability/semanticTokensResult"; |
| 59 | } |
| 60 | |
| 61 | public static class Editor |
| 62 | { |
| 63 | public const string SetModel = "editor/setModel"; |
| 64 | public const string ApplyEdits = "editor/applyEdits"; |
| 65 | public const string SetDecorations = "editor/setDecorations"; |
| 66 | public const string SetTheme = "editor/setTheme"; |
| 67 | public const string SetGutterGlyphs = "editor/setGutterGlyphs"; |
| 68 | public const string SetIntelligence = "editor/setIntelligence"; |
| 69 | public const string RevealRange = "editor/revealRange"; |
| 70 | public const string SetSelectionByOffset = "editor/setSelectionByOffset"; |
| 71 | public const string SetAgentReveal = "editor/setAgentReveal"; |
| 72 | public const string ClearAgentReveal = "editor/clearAgentReveal"; |
| 73 | public const string SetEpochDim = "editor/setEpochDim"; |
| 74 | public const string SetStickyScroll = "editor/setStickyScroll"; |
| 75 | public const string SetCfContentLane = "editor/setCfContentLane"; |
| 76 | public const string SetInlayHints = "editor/setInlayHints"; |
| 77 | public const string SetSemanticTokensLegend = "editor/setSemanticTokensLegend"; |
| 78 | |
| 79 | public const string DidChange = "editor/didChange"; |
| 80 | public const string DidChangeCursorSelection = "editor/didChangeCursorSelection"; |
| 81 | public const string DidScroll = "editor/didScroll"; |
| 82 | public const string DidGutterClick = "editor/didGutterClick"; |
| 83 | public const string Ready = "editor/ready"; |
| 84 | } |
| 85 | |
| 86 | public static class Legacy |
| 87 | { |
| 88 | public const string RequestCompletion = "editor/requestCompletion"; |
| 89 | public const string CompletionResult = "editor/completionResult"; |
| 90 | public const string RequestHover = "editor/requestHover"; |
| 91 | public const string HoverResult = "editor/hoverResult"; |
| 92 | public const string RequestSignature = "editor/requestSignature"; |
| 93 | public const string SignatureResult = "editor/signatureResult"; |
| 94 | } |
| 95 | |
| 96 | public static string NormalizeInboundType(string? type) => |
| 97 | type switch |
| 98 | { |
| 99 | Legacy.RequestCompletion => Capabilities.Completion, |
| 100 | Legacy.RequestHover => Capabilities.Hover, |
| 101 | Legacy.RequestSignature => Capabilities.SignatureHelp, |
| 102 | _ => type ?? "", |
| 103 | }; |
| 104 | |
| 105 | public static bool IsCapabilityRequest(string? type) => |
| 106 | type is Capabilities.Completion or Capabilities.Hover or Capabilities.SignatureHelp |
| 107 | or Capabilities.Definition or Capabilities.References or Capabilities.Format |
| 108 | or Capabilities.CodeAction or Capabilities.CodeActionApply or Capabilities.Rename |
| 109 | or Capabilities.InlayHints or Capabilities.CodeLens |
| 110 | or Capabilities.SemanticTokens |
| 111 | or Legacy.RequestCompletion or Legacy.RequestHover or Legacy.RequestSignature; |
| 112 | |
| 113 | public static bool IsCapabilitySideChannel(string? type) => |
| 114 | type is Capabilities.CodeLensClick or Capabilities.Navigate; |
| 115 | |
| 116 | public static bool IsCapabilityResult(string? type) => |
| 117 | type is Capabilities.CompletionResult or Capabilities.HoverResult |
| 118 | or Capabilities.SignatureResult or Capabilities.DefinitionResult |
| 119 | or Capabilities.ReferencesResult or Capabilities.FormatResult |
| 120 | or Capabilities.CodeActionResult or Capabilities.WorkspaceEditResult |
| 121 | or Capabilities.InlayHintsResult or Capabilities.CodeLensResult |
| 122 | or Capabilities.SemanticTokensResult |
| 123 | or Legacy.CompletionResult or Legacy.HoverResult or Legacy.SignatureResult; |
| 124 | } |
| 125 | |