-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathSuggestionServiceProvider.swift
More file actions
83 lines (76 loc) · 2.6 KB
/
SuggestionServiceProvider.swift
File metadata and controls
83 lines (76 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import AppKit
import struct CopilotForXcodeKit.SuggestionServiceConfiguration
import struct CopilotForXcodeKit.WorkspaceInfo
import Foundation
import Preferences
import SuggestionBasic
import UserDefaultsObserver
public struct SuggestionRequest {
public var fileURL: URL
public var relativePath: String
public var content: String
public var originalContent: String
public var lines: [String]
public var cursorPosition: CursorPosition
public var cursorOffset: Int
public var tabSize: Int
public var indentSize: Int
public var usesTabsForIndentation: Bool
public var relevantCodeSnippets: [RelevantCodeSnippet]
public init(
fileURL: URL,
relativePath: String,
content: String,
originalContent: String,
lines: [String],
cursorPosition: CursorPosition,
cursorOffset: Int,
tabSize: Int,
indentSize: Int,
usesTabsForIndentation: Bool,
relevantCodeSnippets: [RelevantCodeSnippet]
) {
self.fileURL = fileURL
self.relativePath = relativePath
self.content = content
self.originalContent = content
self.lines = lines
self.cursorPosition = cursorPosition
self.cursorOffset = cursorOffset
self.tabSize = tabSize
self.indentSize = indentSize
self.usesTabsForIndentation = usesTabsForIndentation
self.relevantCodeSnippets = relevantCodeSnippets
}
}
public struct RelevantCodeSnippet: Codable {
public var content: String
public var priority: Int
public var filePath: String
public init(content: String, priority: Int, filePath: String) {
self.content = content
self.priority = priority
self.filePath = filePath
}
}
public protocol SuggestionServiceProvider {
func getSuggestions(
_ request: SuggestionRequest,
workspaceInfo: CopilotForXcodeKit.WorkspaceInfo
) async throws -> [CodeSuggestion]
func getNESSuggestions(
_ request: SuggestionRequest,
workspaceInfo: CopilotForXcodeKit.WorkspaceInfo,
) async throws -> [CodeSuggestion]
func notifyAccepted(
_ suggestion: CodeSuggestion,
workspaceInfo: CopilotForXcodeKit.WorkspaceInfo
) async
func notifyRejected(
_ suggestions: [CodeSuggestion],
workspaceInfo: CopilotForXcodeKit.WorkspaceInfo
) async
func cancelRequest(workspaceInfo: CopilotForXcodeKit.WorkspaceInfo) async
var configuration: SuggestionServiceConfiguration { get async }
}
public typealias SuggestionServiceConfiguration = CopilotForXcodeKit.SuggestionServiceConfiguration