11import Dependencies
22import Foundation
3+ import ModificationBasic
34import Preferences
45import SuggestionBasic
56import Toast
@@ -22,9 +23,10 @@ public protocol CommandHandler {
2223 func openChat( forceDetach: Bool , activateThisApp: Bool )
2324 func sendChatMessage( _ message: String ) async
2425
25- // MARK: Prompt to Code
26+ // MARK: Modification
2627
2728 func acceptPromptToCode( ) async
29+ func presentModification( fileURL: URL , snippets: [ ModificationSnippet ] ) async
2830
2931 // MARK: Custom Command
3032
@@ -33,11 +35,15 @@ public protocol CommandHandler {
3335 // MARK: Toast
3436
3537 func toast( _ string: String , as type: ToastType )
38+
39+ // MARK: Others
40+
41+ func presentFile( at fileURL: URL , line: Int ) async
3642}
3743
3844public struct CommandHandlerDependencyKey : DependencyKey {
3945 public static var liveValue : CommandHandler = UniversalCommandHandler . shared
40- public static var testValue : CommandHandler = NoopCommandHandler ( )
46+ public static var testValue : CommandHandler = NOOPCommandHandler ( )
4147}
4248
4349public extension DependencyValues {
@@ -52,10 +58,10 @@ public extension DependencyValues {
5258}
5359
5460public final class UniversalCommandHandler : CommandHandler {
55- public static let shared : UniversalCommandHandler = UniversalCommandHandler ( )
56-
57- public var commandHandler : CommandHandler = NoopCommandHandler ( )
58-
61+ public static let shared : UniversalCommandHandler = . init ( )
62+
63+ public var commandHandler : CommandHandler = NOOPCommandHandler ( )
64+
5965 private init ( ) { }
6066
6167 public func presentSuggestions( _ suggestions: [ SuggestionBasic . CodeSuggestion ] ) async {
@@ -98,27 +104,78 @@ public final class UniversalCommandHandler: CommandHandler {
98104 await commandHandler. acceptPromptToCode ( )
99105 }
100106
107+ public func presentModification( fileURL: URL , snippets: [ ModificationSnippet ] ) async {
108+ await commandHandler. presentModification ( fileURL: fileURL, snippets: snippets)
109+ }
110+
101111 public func handleCustomCommand( _ command: CustomCommand ) async {
102112 await commandHandler. handleCustomCommand ( command)
103113 }
104114
105115 public func toast( _ string: String , as type: ToastType ) {
106116 commandHandler. toast ( string, as: type)
107117 }
118+
119+ public func presentFile( at fileURL: URL , line: Int ) async {
120+ await commandHandler. presentFile ( at: fileURL, line: line)
121+ }
108122}
109123
110- struct NoopCommandHandler : CommandHandler {
111- func presentSuggestions( _: [ CodeSuggestion ] ) async { }
112- func presentPreviousSuggestion( ) async { }
113- func presentNextSuggestion( ) async { }
114- func rejectSuggestions( ) async { }
115- func acceptSuggestion( ) async { }
116- func dismissSuggestion( ) async { }
117- func generateRealtimeSuggestions( sourceEditor: SourceEditor ? ) async { }
118- func openChat( forceDetach: Bool , activateThisApp: Bool ) { }
119- func sendChatMessage( _: String ) async { }
120- func acceptPromptToCode( ) async { }
121- func handleCustomCommand( _: CustomCommand ) async { }
122- func toast( _: String , as: ToastType ) { }
124+ struct NOOPCommandHandler : CommandHandler {
125+ func presentSuggestions( _ suggestions: [ CodeSuggestion ] ) async {
126+ print ( " present \( suggestions. count) suggestions " )
127+ }
128+
129+ func presentPreviousSuggestion( ) async {
130+ print ( " previous suggestion " )
131+ }
132+
133+ func presentNextSuggestion( ) async {
134+ print ( " next suggestion " )
135+ }
136+
137+ func rejectSuggestions( ) async {
138+ print ( " reject suggestions " )
139+ }
140+
141+ func acceptSuggestion( ) async {
142+ print ( " accept suggestion " )
143+ }
144+
145+ func dismissSuggestion( ) async {
146+ print ( " dismiss suggestion " )
147+ }
148+
149+ func generateRealtimeSuggestions( sourceEditor: SourceEditor ? ) async {
150+ print ( " generate realtime suggestions " )
151+ }
152+
153+ func openChat( forceDetach: Bool , activateThisApp: Bool ) {
154+ print ( " open chat " )
155+ }
156+
157+ func sendChatMessage( _: String ) async {
158+ print ( " send chat message " )
159+ }
160+
161+ func acceptPromptToCode( ) async {
162+ print ( " accept prompt to code " )
163+ }
164+
165+ func presentModification( fileURL: URL , snippets: [ ModificationSnippet ] ) {
166+ print ( " present modification " )
167+ }
168+
169+ func handleCustomCommand( _: CustomCommand ) async {
170+ print ( " handle custom command " )
171+ }
172+
173+ func toast( _: String , as: ToastType ) {
174+ print ( " toast " )
175+ }
176+
177+ func presentFile( at fileURL: URL , line: Int ) async {
178+ print ( " present file " )
179+ }
123180}
124181
0 commit comments