@@ -10,10 +10,22 @@ import Foundation
1010import XcodeKit
1111import PACore
1212
13+ final class Commander {
14+
15+ class func perform( with invocation: XCSourceEditorCommandInvocation , for platform: PAInvocation . Platform ) {
16+ do {
17+ try PAInvocation . invoke ( with: invocation. buffer. completeBuffer, platform: platform)
18+ } catch {
19+ NSAlert ( error: error) . runModal ( )
20+ }
21+ }
22+
23+ }
24+
1325class EmbeddedCommand : NSObject , XCSourceEditorCommand {
1426
1527 func perform( with invocation: XCSourceEditorCommandInvocation , completionHandler: @escaping ( Error ? ) -> Void ) -> Void {
16- PAInvocation . invoke ( with: invocation. buffer . completeBuffer , platform : . iOS)
28+ Commander . perform ( with: invocation, for : . iOS)
1729
1830 completionHandler ( nil )
1931 }
@@ -23,7 +35,7 @@ class EmbeddedCommand: NSObject, XCSourceEditorCommand {
2335class MacCommand : NSObject , XCSourceEditorCommand {
2436
2537 func perform( with invocation: XCSourceEditorCommandInvocation , completionHandler: @escaping ( Error ? ) -> Void ) -> Void {
26- PAInvocation . invoke ( with: invocation. buffer . completeBuffer , platform : . macOS)
38+ Commander . perform ( with: invocation, for : . macOS)
2739
2840 completionHandler ( nil )
2941 }
@@ -33,7 +45,7 @@ class MacCommand: NSObject, XCSourceEditorCommand {
3345class TVCommand : NSObject , XCSourceEditorCommand {
3446
3547 func perform( with invocation: XCSourceEditorCommandInvocation , completionHandler: @escaping ( Error ? ) -> Void ) -> Void {
36- PAInvocation . invoke ( with: invocation. buffer . completeBuffer , platform : . tvOS)
48+ Commander . perform ( with: invocation, for : . tvOS)
3749
3850 completionHandler ( nil )
3951 }
0 commit comments