Skip to content

Send token with WorkDoneProgress #732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@
//
//===----------------------------------------------------------------------===//

public enum WorkDoneProgress: NotificationType, Hashable {
public struct WorkDoneProgress: NotificationType, Hashable {
public static var method: String = "$/progress"

/// The progress token provided by the client or server.
public var token: ProgressToken

/// The progress data.
public var value: WorkDoneProgressKind

public init(token: ProgressToken, value: WorkDoneProgressKind) {
self.token = token
self.value = value
}
}

public enum WorkDoneProgressKind: Codable, Hashable {
case begin(WorkDoneProgressBegin)
case report(WorkDoneProgressReport)
case end(WorkDoneProgressEnd)
Expand Down
18 changes: 15 additions & 3 deletions Tests/LanguageServerProtocolTests/CodingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1034,21 +1034,33 @@ final class CodingTests: XCTestCase {
}

func testWorkDoneProgress() {
checkCoding(WorkDoneProgress.begin(WorkDoneProgressBegin(title: "My Work")), json: """
checkCoding(WorkDoneProgress(token: ProgressToken.integer(3), value: WorkDoneProgressKind.begin(WorkDoneProgressBegin(title: "My Work"))), json: """
{
"token" : 3,
"value" : {
"kind" : "begin",
"title" : "My Work"
}
}
""")
}

func testWorkDoneProgressType() {
checkCoding(WorkDoneProgressKind.begin(WorkDoneProgressBegin(title: "My Work")), json: """
{
"kind" : "begin",
"title" : "My Work"
}
""")

checkCoding(WorkDoneProgress.report(WorkDoneProgressReport(message: "Still working")), json: """
checkCoding(WorkDoneProgressKind.report(WorkDoneProgressReport(message: "Still working")), json: """
{
"kind" : "report",
"message" : "Still working"
}
""")

checkCoding(WorkDoneProgress.end(WorkDoneProgressEnd()), json: """
checkCoding(WorkDoneProgressKind.end(WorkDoneProgressEnd()), json: """
{
"kind" : "end"
}
Expand Down