-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathSuggestionWidgetDataSource.swift
More file actions
44 lines (40 loc) · 1.28 KB
/
SuggestionWidgetDataSource.swift
File metadata and controls
44 lines (40 loc) · 1.28 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
import Foundation
public protocol SuggestionWidgetDataSource {
func suggestionForFile(at url: URL) async -> CodeSuggestionProvider?
func nesSuggestionForFile(at url: URL) async -> NESCodeSuggestionProvider?
}
struct MockWidgetDataSource: SuggestionWidgetDataSource {
func suggestionForFile(at url: URL) async -> CodeSuggestionProvider? {
return CodeSuggestionProvider(
code: """
func test() {
let x = 1
let y = 2
let z = x + y
}
""",
language: "swift",
startLineIndex: 1,
suggestionCount: 3,
currentSuggestionIndex: 0
)
}
func nesSuggestionForFile(at url: URL) async -> NESCodeSuggestionProvider? {
return NESCodeSuggestionProvider(
fileURL: URL(fileURLWithPath: "the/file/path.swift"),
code: """
func test() {
let x = 1
let y = 2
let z = x + y
}
""",
sourceSnapshot: .init(
lines: [""],
cursorPosition: .init(line: 0, character: 0)
),
range: .init(startPair: (1, 0), endPair: (2, 0)),
language: "swift"
)
}
}