forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeiumModels.swift
More file actions
140 lines (123 loc) · 4.27 KB
/
CodeiumModels.swift
File metadata and controls
140 lines (123 loc) · 4.27 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import Foundation
import JSONRPC
import LanguageServerProtocol
import SuggestionModel
struct CodeiumCompletion: Codable {
var completionId: String
var text: String
var prefix: String?
var stop: String?
// var score: Double
// var tokens: [UInt64]
// var decodedTokens: [String]
// var probabilities: [Double]
// var adjustedProbabilities: [Double]
// var generatedLength: Int
}
struct CodeiumCompletionItem: Codable {
var completion: CodeiumCompletion
var suffix: Suffix?
var range: Range
var source: CompletionSource
var completionParts: [CompletionPart]?
}
struct Suffix: Codable {
/// Text to insert after the cursor when accepting the completion.
var text: String
/// Cursor position delta (as signed offset) from the end of the inserted
/// completion (including the suffix).
var deltaCursorOffset: String
}
struct Range: Codable {
var startOffset: String?
var endOffset: String?
var startPosition: DocumentPosition?
var endPosition: DocumentPosition?
}
enum CompletionSource: String, Codable {
case unspecified = "COMPLETION_SOURCE_UNSPECIFIED"
case typingAsSuggested = "COMPLETION_SOURCE_TYPING_AS_SUGGESTED"
case cache = "COMPLETION_SOURCE_CACHE"
case network = "COMPLETION_SOURCE_NETWORK"
}
/// Represents a contiguous part of the completion text that is not
/// already in the document.
struct CompletionPart: Codable {
enum CompletionPartType: String, Codable {
case unspecified = "COMPLETION_PART_TYPE_UNSPECIFIED"
/// Single-line completion parts that appear within an existing line of text.
case inline = "COMPLETION_PART_TYPE_INLINE"
/// Possibly multi-line completion parts that appear below an existing line of text.
case block = "COMPLETION_PART_TYPE_BLOCK"
/// Like COMPLETION_PART_TYPE_INLINE, but overwrites the existing text.
case inline_mask = "COMPLETION_PART_TYPE_INLINE_MASK"
}
var text: String
/// Offset in the original document where the part starts. For block
/// parts, this is always the end of the line before the block.
var offset: String
var type: CompletionPartType
/// The section of the original line that came before this part. Only valid for
/// COMPLETION_PART_TYPE_INLINE.
var prefix: String?
/// In the case of COMPLETION_PART_TYPE_BLOCK, represents the line it is below.
var line: String?
}
struct CodeiumDocument: Codable {
var absolute_path: String
// Path relative to the root of the workspace.
var relative_path: String
var text: String
// Language ID provided by the editor.
var editor_language: String
// Language enum standardized across editors.
var language: CodeiumSupportedLanguage
// Measured in number of UTF-8 bytes.
// var cursor_offset: UInt64?
// May be present instead of cursor_offset.
var cursor_position: DocumentCursorPosition?
// \n or \r\n, if known.
var line_ending: String = "\n"
}
struct DocumentPosition: Codable {
/// 0-indexed. Measured in UTF-8 bytes.
var row: String?
/// 0-indexed. Measured in UTF-8 bytes.
var col: String?
}
struct DocumentCursorPosition: Codable {
/// 0-indexed. Measured in UTF-8 bytes.
var row: Int
/// 0-indexed. Measured in UTF-8 bytes.
var col: Int
}
struct CodeiumEditorOptions: Codable {
var tab_size: Int
var insert_spaces: Bool
}
struct Metadata: Codable {
var ide_name: String
var ide_version: String
// var extension_name: String
var extension_version: String
var api_key: String
/// UID identifying a single session for the given user.
var session_id: String
/// Used purely in language server to cancel in flight requests.
/// If request_id is 0, then the request is not cancelable.
/// This should be a strictly monotonically increasing number
/// for the duration of a session.
var request_id: UInt64
}
enum CodeiumState: String, Codable {
case unspecified = "CODEIUM_STATE_UNSPECIFIED"
case inactive = "CODEIUM_STATE_INACTIVE"
case processing = "CODEIUM_STATE_PROCESSING"
case success = "CODEIUM_STATE_SUCCESS"
case warning = "CODEIUM_STATE_WARNING"
case error = "CODEIUM_STATE_ERROR"
}
struct State: Codable {
var state: CodeiumState
var message: String
}