csharpdeeb25a2 | 1 | #nullable enable |
| 2 | |
| 3 | using CascadeIDE.Models.Editor; |
| 4 | using CascadeIDE.Models.Intercom; |
| 5 | using CascadeIDE.Services.Intercom; |
| 6 | |
| 7 | namespace CascadeIDE.Services; |
| 8 | |
| 9 | /// <summary>Сводный resolve для reveal: Roslyn member/scope, fallback на lines @ send.</summary> |
| 10 | public static class EditorRevealRangeResolution |
| 11 | { |
| 12 | public static bool TryResolveLines( |
| 13 | EditorRevealRangeRequest request, |
| 14 | string? workspaceRoot, |
| 15 | out LineRange lines, |
| 16 | out string detail, |
| 17 | out bool usedFallback, |
| 18 | string? solutionPath = null) |
| 19 | { |
| 20 | lines = default; |
| 21 | detail = ""; |
| 22 | usedFallback = false; |
| 23 | |
| 24 | var filePath = request.File.Value; |
| 25 | if (!AttachmentAnchorPaths.TryResolveAbsolute(filePath, workspaceRoot, out var absolute, out var pathErr)) |
| 26 | { |
| 27 | detail = pathErr; |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | if (request.SyntaxScope is not null || !string.IsNullOrWhiteSpace(request.MemberKey)) |
| 32 | { |
| 33 | var cacheContext = IntercomAttachResolveCacheContext.From( |
| 34 | workspaceRoot, |
| 35 | solutionPath, |
| 36 | filePath); |
| 37 | if (AttachmentAnchorRoslynResolver.TryResolveLineRange( |
| 38 | null, |
| 39 | absolute, |
| 40 | request.MemberKey, |
| 41 | request.SyntaxScope, |
| 42 | cacheContext, |
| 43 | out var resolved, |
| 44 | out var roslynDetail)) |
| 45 | { |
| 46 | lines = resolved; |
| 47 | detail = roslynDetail; |
| 48 | return true; |
| 49 | } |
| 50 | |
| 51 | if (request.Lines is { } fallback) |
| 52 | { |
| 53 | lines = fallback; |
| 54 | detail = roslynDetail; |
| 55 | usedFallback = true; |
| 56 | return true; |
| 57 | } |
| 58 | |
| 59 | detail = roslynDetail; |
| 60 | return false; |
| 61 | } |
| 62 | |
| 63 | if (request.Lines is { } explicitLines) |
| 64 | { |
| 65 | lines = explicitLines; |
| 66 | detail = "lines"; |
| 67 | return true; |
| 68 | } |
| 69 | |
| 70 | detail = "no_target"; |
| 71 | return false; |
| 72 | } |
| 73 | } |
| 74 | |
View only · write via MCP/CIDE