csharpdeeb25a2 | 1 | #nullable enable |
| 2 | using CascadeIDE.Features.HybridIndex.Application; |
| 3 | using CascadeIDE.Models; |
| 4 | |
| 5 | namespace CascadeIDE.Features.Search.Application; |
| 6 | |
| 7 | /// <summary>Фабрика бэкенда go-to (<c>t:/m:/x:</c>) по <see cref="CommandPaletteGoToSearchSettings.Backend"/>.</summary> |
| 8 | internal static class CommandPaletteGoToSearchBackendFactory |
| 9 | { |
| 10 | private static readonly RipgrepCommandPaletteGoToSearchBackend RipgrepSingleton = new(); |
| 11 | |
| 12 | /// <summary>При <see cref="HybridIndexSettings.Enabled"/> = false — любой режим, кроме <c>rg</c>, эквивалентен ripgrep.</summary> |
| 13 | internal static ICommandPaletteGoToSearchBackend Resolve( |
| 14 | CommandPaletteGoToSearchBackendKind kind, |
| 15 | IHybridIndexOrchestratorSearch hybridIndexOrchestrator, |
| 16 | string hybridScopeMode, |
| 17 | bool hybridIntegrationEnabled) |
| 18 | { |
| 19 | if (!hybridIntegrationEnabled) |
| 20 | return RipgrepSingleton; |
| 21 | |
| 22 | return kind switch |
| 23 | { |
| 24 | CommandPaletteGoToSearchBackendKind.Hci => new HybridIndexCommandPaletteGoToSearchBackend( |
| 25 | hybridIndexOrchestrator, |
| 26 | hybridScopeMode), |
| 27 | CommandPaletteGoToSearchBackendKind.Auto => |
| 28 | new CompositeAutoCommandPaletteGoToSearchBackend( |
| 29 | hybridIndexOrchestrator, |
| 30 | hybridScopeMode, |
| 31 | RipgrepSingleton, |
| 32 | new HybridIndexCommandPaletteGoToSearchBackend(hybridIndexOrchestrator, hybridScopeMode)), |
| 33 | _ => RipgrepSingleton, |
| 34 | }; |
| 35 | } |
| 36 | } |
| 37 | |
View only · write via MCP/CIDE