import Client import SuggestionModel import Foundation import XcodeKit class CustomCommand: NSObject, XCSourceEditorCommand, CommandType { var name: String = "" func perform( with invocation: XCSourceEditorCommandInvocation, completionHandler: @escaping (Error?) -> Void ) { Task { do { let service = try getService() if let content = try await service.customCommand( id: customCommandMap[invocation.commandIdentifier] ?? "", editorContent: .init(invocation) ) { invocation.accept(content) } completionHandler(nil) } catch is CancellationError { completionHandler(nil) } catch { completionHandler(error) } } } }