csharpdeeb25a2 | 1 | namespace CascadeIDE.Features.Agent.Environment; |
| 2 | |
| 3 | /// <summary>Пути .cs для <see cref="VerifyRung.DiagnoseFiles"/> из того же набора, что прогревает solution warm-up (ADR 0141 → 0148).</summary> |
| 4 | internal static class AgentDiagnoseFilesWarmupPathCollector |
| 5 | { |
| 6 | public static IReadOnlyList<string> Collect( |
| 7 | bool enabled, |
| 8 | bool warmActiveFile, |
| 9 | bool warmOpenDocuments, |
| 10 | bool warmRecentCsFiles, |
| 11 | int maxOpenDocumentFiles, |
| 12 | Func<IReadOnlyList<string>> getOpenCsPaths, |
| 13 | Func<string?> getActiveCsPath) |
| 14 | { |
| 15 | if (!enabled) |
| 16 | return []; |
| 17 | |
| 18 | if (!warmActiveFile && !warmOpenDocuments && !warmRecentCsFiles) |
| 19 | return []; |
| 20 | |
| 21 | var ordered = new List<string>(); |
| 22 | var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase); |
| 23 | |
| 24 | void Add(string? path) |
| 25 | { |
| 26 | if (string.IsNullOrWhiteSpace(path)) |
| 27 | return; |
| 28 | if (!path.EndsWith(".cs", StringComparison.OrdinalIgnoreCase)) |
| 29 | return; |
| 30 | |
| 31 | string full; |
| 32 | try |
| 33 | { |
| 34 | full = Path.GetFullPath(path.Trim()); |
| 35 | } |
| 36 | catch |
| 37 | { |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | if (!File.Exists(full)) |
| 42 | return; |
| 43 | if (!seen.Add(full)) |
| 44 | return; |
| 45 | |
| 46 | ordered.Add(full); |
| 47 | } |
| 48 | |
| 49 | if (warmActiveFile) |
| 50 | Add(getActiveCsPath()); |
| 51 | |
| 52 | if (warmOpenDocuments || warmRecentCsFiles) |
| 53 | { |
| 54 | foreach (var path in getOpenCsPaths()) |
| 55 | Add(path); |
| 56 | } |
| 57 | |
| 58 | var max = Math.Clamp(maxOpenDocumentFiles, 1, 32); |
| 59 | return ordered.Count <= max ? ordered : ordered.Take(max).ToList(); |
| 60 | } |
| 61 | } |
| 62 | |
View only · write via MCP/CIDE