Skip to content

Commit 53d05fe

Browse files
committed
Format codes
1 parent a36c8d7 commit 53d05fe

33 files changed

+187
-116
lines changed

.swiftformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
--hexliteralcase uppercase
2121
--ifdef no-indent
2222
--importgrouping testable-bottom
23-
--indent 2
23+
--indent 4
2424
--indentcase false
2525
--lifecycle
2626
--linebreaks lf

Copilot for Xcode/App.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import SwiftUI
33
@main
44
struct CopilotForXcodeApp: App {
55
var body: some Scene {
6-
return WindowGroup {
6+
WindowGroup {
77
ContentView()
88
.frame(minWidth: 500, maxWidth: .infinity, minHeight: 700)
99
}

Copilot for Xcode/AppInfoView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import SwiftUI
22

33
struct AppInfoView: View {
44
@State var appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
5-
5+
66
var body: some View {
77
Section {
88
VStack(alignment: .leading) {
@@ -12,7 +12,7 @@ struct AppInfoView: View {
1212
Text(appVersion ?? "")
1313
.font(.footnote)
1414
.foregroundColor(.white.opacity(0.5))
15-
15+
1616
Spacer()
1717
}
1818

Copilot for Xcode/CopilotView.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ struct CopilotView: View {
2929
.alert(isPresented: $isUserCodeCopiedAlertPresented) {
3030
Alert(
3131
title: Text(userCode ?? ""),
32-
message: Text("The user code is pasted into your clipboard, please paste it in the opened website to login.\nAfter that, click \"Confirm Sign-in\" to finish."),
32+
message: Text(
33+
"The user code is pasted into your clipboard, please paste it in the opened website to login.\nAfter that, click \"Confirm Sign-in\" to finish."
34+
),
3335
dismissButton: .default(Text("OK"))
3436
)
3537
}
3638
Button("Confirm Sign-in") { confirmSignIn() }
3739
}
38-
if copilotStatus == .ok || copilotStatus == .alreadySignedIn || copilotStatus == .notAuthorized {
40+
if copilotStatus == .ok || copilotStatus == .alreadySignedIn ||
41+
copilotStatus == .notAuthorized
42+
{
3943
Button("Sign Out") { signOut() }
4044
}
4145
if isRunningAction {

Copilot for Xcode/InstructionView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ struct InstructionView: View {
55
Section {
66
HStack {
77
VStack(alignment: .leading, spacing: 8) {
8-
// swiftformat: disable indent
8+
// swiftformat:disable indent
99
Text("Instruction")
1010
.font(.title)
1111
.padding(.bottom, 12)
@@ -28,7 +28,7 @@ Text("""
2828
1. Optionally sign out of GitHub Copilot.
2929
2. Click `Remove Launch Agent`.
3030
""")
31-
// swiftformat: enable indent
31+
// swiftformat:enable indent
3232
Spacer()
3333
}
3434
Spacer()

Copilot for Xcode/LaunchAgentManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct LaunchAgentManager {
5858
launchctl("unload", launchAgentPath)
5959
try FileManager.default.removeItem(atPath: launchAgentPath)
6060
}
61-
61+
6262
func restartLaunchAgent() {
6363
launchctl("unload", launchAgentPath)
6464
launchctl("load", launchAgentPath)

Core/Sources/Client/AsyncXPCService.swift

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import XPCShared
44

55
public struct AsyncXPCService {
66
let connection: NSXPCConnection
7-
7+
88
public init(connection: NSXPCConnection) {
99
self.connection = connection
1010
}
@@ -51,7 +51,9 @@ public struct AsyncXPCService {
5151
}
5252
}
5353

54-
public func signInConfirm(userCode: String) async throws -> (username: String, status: CopilotStatus) {
54+
public func signInConfirm(userCode: String) async throws
55+
-> (username: String, status: CopilotStatus)
56+
{
5557
try await withXPCServiceConnected(connection: connection) {
5658
service, continuation in
5759
service.signInConfirm(userCode: userCode) { username, status, error in
@@ -75,7 +77,8 @@ public struct AsyncXPCService {
7577
continuation.reject(error)
7678
return
7779
}
78-
continuation.resume(finishstatus.flatMap(CopilotStatus.init(rawValue:)) ?? .notSignedIn)
80+
continuation
81+
.resume(finishstatus.flatMap(CopilotStatus.init(rawValue:)) ?? .notSignedIn)
7982
}
8083
}
8184
}
@@ -96,31 +99,39 @@ public struct AsyncXPCService {
9699
)
97100
}
98101

99-
public func getPreviousSuggestedCode(editorContent: EditorContent) async throws -> UpdatedContent? {
102+
public func getPreviousSuggestedCode(editorContent: EditorContent) async throws
103+
-> UpdatedContent?
104+
{
100105
try await suggestionRequest(
101106
connection,
102107
editorContent,
103108
{ $0.getPreviousSuggestedCode }
104109
)
105110
}
106111

107-
public func getSuggestionAcceptedCode(editorContent: EditorContent) async throws -> UpdatedContent? {
112+
public func getSuggestionAcceptedCode(editorContent: EditorContent) async throws
113+
-> UpdatedContent?
114+
{
108115
try await suggestionRequest(
109116
connection,
110117
editorContent,
111118
{ $0.getSuggestionAcceptedCode }
112119
)
113120
}
114121

115-
public func getSuggestionRejectedCode(editorContent: EditorContent) async throws -> UpdatedContent? {
122+
public func getSuggestionRejectedCode(editorContent: EditorContent) async throws
123+
-> UpdatedContent?
124+
{
116125
try await suggestionRequest(
117126
connection,
118127
editorContent,
119128
{ $0.getSuggestionRejectedCode }
120129
)
121130
}
122-
123-
public func getRealtimeSuggestedCode(editorContent: EditorContent) async throws -> UpdatedContent? {
131+
132+
public func getRealtimeSuggestedCode(editorContent: EditorContent) async throws
133+
-> UpdatedContent?
134+
{
124135
try await suggestionRequest(
125136
connection,
126137
editorContent,
@@ -129,7 +140,7 @@ public struct AsyncXPCService {
129140
}
130141

131142
public func setAutoSuggestion(enabled: Bool) async throws {
132-
return try await withXPCServiceConnected(connection: connection) {
143+
try await withXPCServiceConnected(connection: connection) {
133144
service, continuation in
134145
service.setAutoSuggestion(enabled: enabled) { error in
135146
if let error {
@@ -138,9 +149,9 @@ public struct AsyncXPCService {
138149
}
139150
continuation.resume(())
140151
}
141-
}
152+
} as Void
142153
}
143-
154+
144155
public func prefetchRealtimeSuggestions(editorContent: EditorContent) async {
145156
guard let data = try? JSONEncoder().encode(editorContent) else { return }
146157
try? await withXPCServiceConnected(connection: connection) { service, continuation in

Core/Sources/Client/XPCService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
2-
import XPCShared
32
import os.log
3+
import XPCShared
44

55
var asyncService: AsyncXPCService?
66
var shared = XPCService()

Core/Sources/CopilotModel/CopilotCompletion.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import Foundation
22

33
public struct CopilotCompletion: Codable {
4-
public init(text: String, position: CursorPosition, uuid: String, range: CursorRange, displayText: String) {
4+
public init(
5+
text: String,
6+
position: CursorPosition,
7+
uuid: String,
8+
range: CursorRange,
9+
displayText: String
10+
) {
511
self.text = text
612
self.position = position
713
self.uuid = uuid
814
self.range = range
915
self.displayText = displayText
1016
}
11-
17+
1218
public var text: String
1319
public var position: CursorPosition
1420
public var uuid: String

Core/Sources/CopilotModel/CopilotStatus.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public enum CopilotStatus: String, Codable, CustomStringConvertible {
66
case notAuthorized = "NotAuthorized"
77
case notSignedIn = "NotSignedIn"
88
case ok = "OK"
9-
9+
1010
public var description: String {
1111
switch self {
1212
case .alreadySignedIn:

0 commit comments

Comments
 (0)