Skip to content

Commit be149f2

Browse files
committed
Rename CopilotCompletion to CodeSuggestion
1 parent 6e08e2c commit be149f2

File tree

10 files changed

+38
-38
lines changed

10 files changed

+38
-38
lines changed

Core/Sources/CopilotModel/CopilotCompletion.swift renamed to Core/Sources/CopilotModel/CodeSuggestion.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Foundation
22

3-
public struct CopilotCompletion: Codable, Equatable {
3+
public struct CodeSuggestion: Codable, Equatable {
44
public init(
55
text: String,
66
position: CursorPosition,

Core/Sources/GitHubCopilotService/CopilotRequest.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ enum CopilotRequest {
101101

102102
struct GetCompletions: CopilotRequestType {
103103
struct Response: Codable {
104-
var completions: [CopilotCompletion]
104+
var completions: [CodeSuggestion]
105105
}
106106

107107
var doc: CopilotDoc
@@ -117,7 +117,7 @@ enum CopilotRequest {
117117

118118
struct GetCompletionsCycling: CopilotRequestType {
119119
struct Response: Codable {
120-
var completions: [CopilotCompletion]
120+
var completions: [CodeSuggestion]
121121
}
122122

123123
var doc: CopilotDoc
@@ -133,7 +133,7 @@ enum CopilotRequest {
133133

134134
struct GetPanelCompletions: CopilotRequestType {
135135
struct Response: Codable {
136-
var completions: [CopilotCompletion]
136+
var completions: [CodeSuggestion]
137137
}
138138

139139
var doc: CopilotDoc

Core/Sources/GitHubCopilotService/CopilotService.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ public protocol CopilotSuggestionServiceType {
2323
indentSize: Int,
2424
usesTabsForIndentation: Bool,
2525
ignoreSpaceOnlySuggestions: Bool
26-
) async throws -> [CopilotCompletion]
27-
func notifyAccepted(_ completion: CopilotCompletion) async
28-
func notifyRejected(_ completions: [CopilotCompletion]) async
26+
) async throws -> [CodeSuggestion]
27+
func notifyAccepted(_ completion: CodeSuggestion) async
28+
func notifyRejected(_ completions: [CodeSuggestion]) async
2929
func notifyOpenTextDocument(fileURL: URL, content: String) async throws
3030
func notifyChangeTextDocument(fileURL: URL, content: String) async throws
3131
func notifyCloseTextDocument(fileURL: URL) async throws
@@ -202,7 +202,7 @@ public final class CopilotSuggestionService: CopilotBaseService, CopilotSuggesti
202202
indentSize: Int,
203203
usesTabsForIndentation: Bool,
204204
ignoreSpaceOnlySuggestions: Bool
205-
) async throws -> [CopilotCompletion] {
205+
) async throws -> [CodeSuggestion] {
206206
let languageId = languageIdentifierFromFileURL(fileURL)
207207

208208
let relativePath = {
@@ -243,13 +243,13 @@ public final class CopilotSuggestionService: CopilotBaseService, CopilotSuggesti
243243
return completions
244244
}
245245

246-
public func notifyAccepted(_ completion: CopilotCompletion) async {
246+
public func notifyAccepted(_ completion: CodeSuggestion) async {
247247
_ = try? await server.sendRequest(
248248
CopilotRequest.NotifyAccepted(completionUUID: completion.uuid)
249249
)
250250
}
251251

252-
public func notifyRejected(_ completions: [CopilotCompletion]) async {
252+
public func notifyRejected(_ completions: [CodeSuggestion]) async {
253253
_ = try? await server.sendRequest(
254254
CopilotRequest.NotifyRejected(completionUUIDs: completions.map(\.uuid))
255255
)

Core/Sources/PromptToCodeService/PromptToCodeService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public final class PromptToCodeService: ObservableObject {
124124
self.description = description
125125
}
126126

127-
public func generateCompletion() -> CopilotCompletion {
127+
public func generateCompletion() -> CodeSuggestion {
128128
.init(
129129
text: code,
130130
position: selectionRange.start,

Core/Sources/Service/SuggestionCommandHandler/WindowBaseCommandHandler.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ struct WindowBaseCommandHandler: SuggestionCommandHandler {
155155
var extraInfo = SuggestionInjector.ExtraInfo()
156156

157157
if let service = WidgetDataSource.shared.promptToCodes[fileURL]?.promptToCodeService {
158-
let suggestion = CopilotCompletion(
158+
let suggestion = CodeSuggestion(
159159
text: service.code,
160160
position: service.selectionRange.start,
161161
uuid: UUID().uuidString,

Core/Sources/Service/Workspace.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ final class Filespace {
1717

1818
let fileURL: URL
1919
private(set) lazy var language: String = languageIdentifierFromFileURL(fileURL).rawValue
20-
var suggestions: [CopilotCompletion] = [] {
20+
var suggestions: [CodeSuggestion] = [] {
2121
didSet { refreshUpdateTime() }
2222
}
2323

@@ -30,7 +30,7 @@ final class Filespace {
3030

3131
var suggestionIndex: Int = 0
3232
var suggestionSourceSnapshot: Snapshot = .init(linesHash: -1, cursorPosition: .outOfScope)
33-
var presentingSuggestion: CopilotCompletion? {
33+
var presentingSuggestion: CodeSuggestion? {
3434
guard suggestions.endIndex > suggestionIndex, suggestionIndex >= 0 else { return nil }
3535
return suggestions[suggestionIndex]
3636
}
@@ -193,7 +193,7 @@ extension Workspace {
193193
forFileAt fileURL: URL,
194194
editor: EditorContent,
195195
shouldcancelInFlightRealtimeSuggestionRequests: Bool = true
196-
) async throws -> [CopilotCompletion] {
196+
) async throws -> [CodeSuggestion] {
197197
if shouldcancelInFlightRealtimeSuggestionRequests {
198198
cancelInFlightRealtimeSuggestionRequests()
199199
}
@@ -276,7 +276,7 @@ extension Workspace {
276276
filespaces[fileURL]?.reset(resetSnapshot: false)
277277
}
278278

279-
func acceptSuggestion(forFileAt fileURL: URL, editor: EditorContent?) -> CopilotCompletion? {
279+
func acceptSuggestion(forFileAt fileURL: URL, editor: EditorContent?) -> CodeSuggestion? {
280280
cancelInFlightRealtimeSuggestionRequests()
281281
refreshUpdateTime()
282282
guard let filespace = filespaces[fileURL],

Core/Sources/SuggestionInjector/SuggestionInjector.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public struct SuggestionInjector {
6161

6262
public func proposeSuggestion(
6363
intoContentWithoutSuggestion content: inout [String],
64-
completion: CopilotCompletion,
64+
completion: CodeSuggestion,
6565
index: Int,
6666
count: Int,
6767
extraInfo: inout ExtraInfo
@@ -131,7 +131,7 @@ public struct SuggestionInjector {
131131
public func acceptSuggestion(
132132
intoContentWithoutSuggestion content: inout [String],
133133
cursorPosition: inout CursorPosition,
134-
completion: CopilotCompletion,
134+
completion: CodeSuggestion,
135135
extraInfo: inout ExtraInfo
136136
) {
137137
extraInfo.didChangeContent = true

Core/Tests/ServiceTests/Environment.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import XPCShared
3333
Environment.triggerAction = { _ in }
3434
}
3535

36-
func completion(text: String, range: CursorRange, uuid: String = "") -> CopilotCompletion {
36+
func completion(text: String, range: CursorRange, uuid: String = "") -> CodeSuggestion {
3737
.init(text: text, position: range.start, uuid: uuid, range: range, displayText: text)
3838
}
3939

@@ -54,11 +54,11 @@ class MockSuggestionService: CopilotSuggestionServiceType {
5454
fatalError()
5555
}
5656

57-
var completions = [CopilotCompletion]()
57+
var completions = [CodeSuggestion]()
5858
var accepted: String?
5959
var rejected: [String] = []
6060

61-
init(completions: [CopilotCompletion]) {
61+
init(completions: [CodeSuggestion]) {
6262
self.completions = completions
6363
}
6464

@@ -70,15 +70,15 @@ class MockSuggestionService: CopilotSuggestionServiceType {
7070
indentSize: Int,
7171
usesTabsForIndentation: Bool,
7272
ignoreSpaceOnlySuggestions: Bool
73-
) async throws -> [CopilotModel.CopilotCompletion] {
73+
) async throws -> [CopilotModel.CodeSuggestion] {
7474
completions
7575
}
7676

77-
func notifyAccepted(_ completion: CopilotCompletion) async {
77+
func notifyAccepted(_ completion: CodeSuggestion) async {
7878
accepted = completion.uuid
7979
}
8080

81-
func notifyRejected(_ completions: [CopilotCompletion]) async {
81+
func notifyRejected(_ completions: [CodeSuggestion]) async {
8282
rejected = completions.map(\.uuid)
8383
}
8484
}

Core/Tests/SuggestionInjectorTests/AcceptSuggestionTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class AcceptSuggestionTests: XCTestCase {
1414
var name: String
1515
var age: String
1616
"""
17-
let suggestion = CopilotCompletion(
17+
let suggestion = CodeSuggestion(
1818
text: text,
1919
position: .init(line: 0, character: 1),
2020
uuid: "",
@@ -56,7 +56,7 @@ final class AcceptSuggestionTests: XCTestCase {
5656
var name: String
5757
var age: String
5858
"""
59-
let suggestion = CopilotCompletion(
59+
let suggestion = CodeSuggestion(
6060
text: text,
6161
position: .init(line: 0, character: 12),
6262
uuid: "",
@@ -99,7 +99,7 @@ final class AcceptSuggestionTests: XCTestCase {
9999
var name: String
100100
var age: String
101101
"""
102-
let suggestion = CopilotCompletion(
102+
let suggestion = CodeSuggestion(
103103
text: text,
104104
position: .init(line: 1, character: 12),
105105
uuid: "",
@@ -143,7 +143,7 @@ final class AcceptSuggestionTests: XCTestCase {
143143
print(array)
144144
}
145145
"""
146-
let suggestion = CopilotCompletion(
146+
let suggestion = CodeSuggestion(
147147
text: text,
148148
position: .init(line: 0, character: 18),
149149
uuid: "",
@@ -190,7 +190,7 @@ final class AcceptSuggestionTests: XCTestCase {
190190
print(array)
191191
}
192192
"""
193-
let suggestion = CopilotCompletion(
193+
let suggestion = CodeSuggestion(
194194
text: text,
195195
position: .init(line: 0, character: 18),
196196
uuid: "",
@@ -240,7 +240,7 @@ final class AcceptSuggestionTests: XCTestCase {
240240
}
241241
}
242242
"""
243-
let suggestion = CopilotCompletion(
243+
let suggestion = CodeSuggestion(
244244
text: text,
245245
position: .init(line: 0, character: 7),
246246
uuid: "",
@@ -287,7 +287,7 @@ final class AcceptSuggestionTests: XCTestCase {
287287
print("woof")
288288
}
289289
"""
290-
let suggestion = CopilotCompletion(
290+
let suggestion = CodeSuggestion(
291291
text: text,
292292
position: .init(line: 5, character: 34),
293293
uuid: "",

Core/Tests/SuggestionInjectorTests/ProposeSuggestionTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class ProposeSuggestionTests: XCTestCase {
1414
var name: String
1515
var age: String
1616
"""
17-
let suggestion = CopilotCompletion(
17+
let suggestion = CodeSuggestion(
1818
text: text,
1919
position: .init(line: 2, character: 19),
2020
uuid: "",
@@ -61,7 +61,7 @@ final class ProposeSuggestionTests: XCTestCase {
6161
var name: String
6262
var age: String
6363
"""
64-
let suggestion = CopilotCompletion(
64+
let suggestion = CodeSuggestion(
6565
text: text,
6666
position: .init(line: 1, character: 0),
6767
uuid: "",
@@ -104,7 +104,7 @@ final class ProposeSuggestionTests: XCTestCase {
104104
var name: String
105105
var age: String
106106
"""
107-
let suggestion = CopilotCompletion(
107+
let suggestion = CodeSuggestion(
108108
text: text,
109109
position: .init(line: 1, character: 0),
110110
uuid: "",
@@ -148,7 +148,7 @@ final class ProposeSuggestionTests: XCTestCase {
148148
var name: String
149149
var age: String
150150
"""
151-
let suggestion = CopilotCompletion(
151+
let suggestion = CodeSuggestion(
152152
text: text,
153153
position: .init(line: 1, character: 0),
154154
uuid: "",
@@ -196,7 +196,7 @@ final class ProposeSuggestionTests: XCTestCase {
196196
quickSort(&array, left, right)
197197
print(array)
198198
"""
199-
let suggestion = CopilotCompletion(
199+
let suggestion = CodeSuggestion(
200200
text: text,
201201
position: .init(line: 1, character: 0),
202202
uuid: "",
@@ -246,7 +246,7 @@ final class ProposeSuggestionTests: XCTestCase {
246246
print(array)
247247
}
248248
"""
249-
let suggestion = CopilotCompletion(
249+
let suggestion = CodeSuggestion(
250250
text: text,
251251
position: .init(line: 0, character: 0),
252252
uuid: "",
@@ -293,7 +293,7 @@ final class ProposeSuggestionTests: XCTestCase {
293293
}
294294
"""
295295
let text = "} else {\n"
296-
let suggestion = CopilotCompletion(
296+
let suggestion = CodeSuggestion(
297297
text: text,
298298
position: .init(line: 2, character: 0),
299299
uuid: "",

0 commit comments

Comments
 (0)