forked from github/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeSuggestionProvider.swift
More file actions
60 lines (52 loc) · 2.34 KB
/
CodeSuggestionProvider.swift
File metadata and controls
60 lines (52 loc) · 2.34 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
import Combine
import Foundation
import Perception
import SharedUIComponents
import SwiftUI
import XcodeInspector
@Perceptible
public final class CodeSuggestionProvider: Equatable {
public static func == (lhs: CodeSuggestionProvider, rhs: CodeSuggestionProvider) -> Bool {
lhs.code == rhs.code && lhs.language == rhs.language
}
public var code: String = ""
public var language: String = ""
public var startLineIndex: Int = 0
public var suggestionCount: Int = 0
public var currentSuggestionIndex: Int = 0
public var extraInformation: String = ""
@PerceptionIgnored public var onSelectPreviousSuggestionTapped: () -> Void
@PerceptionIgnored public var onSelectNextSuggestionTapped: () -> Void
@PerceptionIgnored public var onRejectSuggestionTapped: () -> Void
@PerceptionIgnored public var onAcceptSuggestionTapped: () -> Void
@PerceptionIgnored public var onDismissSuggestionTapped: () -> Void
public init(
code: String = "",
language: String = "",
startLineIndex: Int = 0,
startCharacerIndex: Int = 0,
suggestionCount: Int = 0,
currentSuggestionIndex: Int = 0,
onSelectPreviousSuggestionTapped: @escaping () -> Void = {},
onSelectNextSuggestionTapped: @escaping () -> Void = {},
onRejectSuggestionTapped: @escaping () -> Void = {},
onAcceptSuggestionTapped: @escaping () -> Void = {},
onDismissSuggestionTapped: @escaping () -> Void = {}
) {
self.code = code
self.language = language
self.startLineIndex = startLineIndex
self.suggestionCount = suggestionCount
self.currentSuggestionIndex = currentSuggestionIndex
self.onSelectPreviousSuggestionTapped = onSelectPreviousSuggestionTapped
self.onSelectNextSuggestionTapped = onSelectNextSuggestionTapped
self.onRejectSuggestionTapped = onRejectSuggestionTapped
self.onAcceptSuggestionTapped = onAcceptSuggestionTapped
self.onDismissSuggestionTapped = onDismissSuggestionTapped
}
func selectPreviousSuggestion() { onSelectPreviousSuggestionTapped() }
func selectNextSuggestion() { onSelectNextSuggestionTapped() }
func rejectSuggestion() { onRejectSuggestionTapped() }
func acceptSuggestion() { onAcceptSuggestionTapped() }
func dismissSuggestion() { onDismissSuggestionTapped() }
}