Skip to content

Commit f10e5c5

Browse files
committed
Send token with WorkDoneProgress
1 parent 1065122 commit f10e5c5

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

Sources/LanguageServerProtocol/Notifications/WorkDoneProgress.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,22 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
public enum WorkDoneProgress: NotificationType, Hashable {
13+
public struct WorkDoneProgress: NotificationType, Hashable {
1414
public static var method: String = "$/progress"
1515

16+
/// The progress token provided by the client or server.
17+
public var token: ProgressToken
18+
19+
/// The progress data.
20+
public var value: WorkDoneProgressKind
21+
22+
public init(token: ProgressToken, value: WorkDoneProgressKind) {
23+
self.token = token
24+
self.value = value
25+
}
26+
}
27+
28+
public enum WorkDoneProgressKind: Codable, Hashable {
1629
case begin(WorkDoneProgressBegin)
1730
case report(WorkDoneProgressReport)
1831
case end(WorkDoneProgressEnd)

Tests/LanguageServerProtocolTests/CodingTests.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,21 +1034,33 @@ final class CodingTests: XCTestCase {
10341034
}
10351035

10361036
func testWorkDoneProgress() {
1037-
checkCoding(WorkDoneProgress.begin(WorkDoneProgressBegin(title: "My Work")), json: """
1037+
checkCoding(WorkDoneProgress(token: ProgressToken.integer(3), value: WorkDoneProgressKind.begin(WorkDoneProgressBegin(title: "My Work"))), json: """
1038+
{
1039+
"token" : 3,
1040+
"value" : {
1041+
"kind" : "begin",
1042+
"title" : "My Work"
1043+
}
1044+
}
1045+
""")
1046+
}
1047+
1048+
func testWorkDoneProgressType() {
1049+
checkCoding(WorkDoneProgressKind.begin(WorkDoneProgressBegin(title: "My Work")), json: """
10381050
{
10391051
"kind" : "begin",
10401052
"title" : "My Work"
10411053
}
10421054
""")
10431055

1044-
checkCoding(WorkDoneProgress.report(WorkDoneProgressReport(message: "Still working")), json: """
1056+
checkCoding(WorkDoneProgressKind.report(WorkDoneProgressReport(message: "Still working")), json: """
10451057
{
10461058
"kind" : "report",
10471059
"message" : "Still working"
10481060
}
10491061
""")
10501062

1051-
checkCoding(WorkDoneProgress.end(WorkDoneProgressEnd()), json: """
1063+
checkCoding(WorkDoneProgressKind.end(WorkDoneProgressEnd()), json: """
10521064
{
10531065
"kind" : "end"
10541066
}

0 commit comments

Comments
 (0)