Skip to content

Commit b32f536

Browse files
committed
Add LanguageClientProgress.Factory
1 parent 275115f commit b32f536

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

server/src/main/kotlin/org/javacs/kt/progress/LanguageClientProgress.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import org.eclipse.lsp4j.WorkDoneProgressNotification
77
import org.eclipse.lsp4j.WorkDoneProgressBegin
88
import org.eclipse.lsp4j.WorkDoneProgressReport
99
import org.eclipse.lsp4j.WorkDoneProgressEnd
10+
import org.eclipse.lsp4j.WorkDoneProgressCreateParams
11+
import java.util.concurrent.CompletableFuture
12+
import java.util.UUID
1013

1114
class LanguageClientProgress(
1215
private val label: String,
@@ -34,4 +37,15 @@ class LanguageClientProgress(
3437
private fun reportProgress(notification: WorkDoneProgressNotification) {
3538
client.notifyProgress(ProgressParams(token, notification))
3639
}
40+
41+
class Factory(private val client: LanguageClient) : Progress.Factory {
42+
override fun create(label: String): CompletableFuture<Progress> {
43+
val token = Either.forLeft<String, Number>(UUID.randomUUID().toString())
44+
return client
45+
.createProgress(WorkDoneProgressCreateParams().also {
46+
it.token = token
47+
})
48+
.thenApply { LanguageClientProgress(label, token, client) }
49+
}
50+
}
3751
}

0 commit comments

Comments
 (0)