| 1 | namespace CascadeIDE.Features.Editor.Application.Monaco; |
| 2 | |
| 3 | /// <summary> |
| 4 | /// Единая C#-проекция HUD inline → CECB push (ADR 0163 §2.8, monaco-presentation-projection-v1). |
| 5 | /// Политика 0085: var-inlay не на строках с диагностикой. |
| 6 | /// </summary> |
| 7 | public static class MonacoEditorPresentationProjector |
| 8 | { |
| 9 | public sealed record Push( |
| 10 | int ModelVersion, |
| 11 | IReadOnlyList<CideEditorDecoration> DiagnosticDecorations, |
| 12 | IReadOnlyList<CideEditorInlayHint> InlayHints); |
| 13 | |
| 14 | public static Push ProjectEditorHud( |
| 15 | int modelVersion, |
| 16 | string sourceText, |
| 17 | IReadOnlyList<EditorDiagnosticStrip> strips, |
| 18 | IReadOnlyList<EditorTrailingInlayPart> varInlayParts) |
| 19 | { |
| 20 | var decorations = MonacoEditorDiagnosticsMapper.ToDecorations(strips); |
| 21 | var inlays = MergeInlayHints(sourceText, strips, varInlayParts); |
| 22 | return new Push(modelVersion, decorations, inlays); |
| 23 | } |
| 24 | |
| 25 | public static Push ProjectDiagnosticsOnly(int modelVersion, string sourceText, IReadOnlyList<EditorDiagnosticStrip> strips) |
| 26 | { |
| 27 | var decorations = MonacoEditorDiagnosticsMapper.ToDecorations(strips); |
| 28 | var inlays = MonacoEditorDiagnosticsMapper.ToDiagnosticInlays(strips); |
| 29 | return new Push(modelVersion, decorations, inlays); |
| 30 | } |
| 31 | |
| 32 | public static IReadOnlyList<CideEditorInlayHint> MergeInlayHints( |
| 33 | string sourceText, |
| 34 | IReadOnlyList<EditorDiagnosticStrip> strips, |
| 35 | IReadOnlyList<EditorTrailingInlayPart> varInlayParts) |
| 36 | { |
| 37 | var diagnosticLines = strips.Select(s => s.Line1).ToHashSet(); |
| 38 | var varHints = MonacoEditorInlayMapper.ToHints(sourceText, varInlayParts) |
| 39 | .Where(h => !diagnosticLines.Contains(h.Line)); |
| 40 | var diagHints = MonacoEditorDiagnosticsMapper.ToDiagnosticInlays(strips); |
| 41 | return varHints.Concat(diagHints).ToList(); |
| 42 | } |
| 43 | } |
| 44 | |