File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed
server/src/main/kotlin/org/javacs/kt/progress Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 1
1
package org.javacs.kt.progress
2
2
3
+ import org.eclipse.lsp4j.services.LanguageClient
4
+ import org.eclipse.lsp4j.jsonrpc.messages.Either
5
+ import org.eclipse.lsp4j.ProgressParams
6
+ import org.eclipse.lsp4j.WorkDoneProgressNotification
7
+ import org.eclipse.lsp4j.WorkDoneProgressBegin
8
+ import org.eclipse.lsp4j.WorkDoneProgressReport
9
+ import org.eclipse.lsp4j.WorkDoneProgressEnd
10
+
11
+ class LanguageClientProgress (
12
+ private val label : String ,
13
+ private val token : Either <String , Number >,
14
+ private val client : LanguageClient
15
+ ) : Progress {
16
+ init {
17
+ reportProgress(WorkDoneProgressBegin ().also {
18
+ it.title = " Kotlin: $label "
19
+ it.percentage = 0
20
+ })
21
+ }
22
+
23
+ override fun update (message : String? , percent : Int? ) {
24
+ reportProgress(WorkDoneProgressReport ().also {
25
+ it.message = message
26
+ it.percentage = percent
27
+ })
28
+ }
29
+
30
+ override fun close () {
31
+ reportProgress(WorkDoneProgressEnd ())
32
+ }
33
+
34
+ private fun reportProgress (notification : WorkDoneProgressNotification ) {
35
+ client.notifyProgress(ProgressParams (token, notification))
36
+ }
37
+ }
Original file line number Diff line number Diff line change 1
1
package org.javacs.kt.progress
2
2
3
3
import java.io.Closeable
4
+ import java.util.concurrent.CompletableFuture
4
5
5
6
/* * A facility for emitting progress notifications. */
6
7
interface Progress : Closeable {
7
8
/* *
8
9
* Updates the progress percentage. The
9
10
* value should be in the range [0, 100].
10
11
*/
11
- fun update (percent : Int ): Unit
12
+ fun update (message : String? = null, percent : Int? = null)
12
13
13
14
interface Factory {
14
15
/* *
15
16
* Creates a new progress listener with
16
17
* the given label. The label is intended
17
18
* to be human-readable.
18
19
*/
19
- fun create (label : String ): Progress
20
+ fun create (label : String ): CompletableFuture < Progress >
20
21
}
21
22
}
You can’t perform that action at this time.
0 commit comments