@@ -30,10 +30,12 @@ class KotlinLanguageServer : LanguageServer, LanguageClientAware, Closeable {
30
30
private val workspaces = KotlinWorkspaceService (sourceFiles, sourcePath, classPath, textDocuments, config)
31
31
private val protocolExtensions = KotlinProtocolExtensionService (uriContentProvider)
32
32
33
+ private lateinit var client: LanguageClient
33
34
private val async = AsyncExecutor ()
34
35
35
36
override fun connect (client : LanguageClient ) {
36
- connectLoggingBackend(client)
37
+ this .client = client
38
+ connectLoggingBackend()
37
39
38
40
workspaces.connect(client)
39
41
textDocuments.connect(client)
@@ -70,12 +72,22 @@ class KotlinLanguageServer : LanguageServer, LanguageClientAware, Closeable {
70
72
val clientCapabilities = params.capabilities
71
73
config.completion.snippets.enabled = clientCapabilities?.textDocument?.completion?.completionItem?.snippetSupport ? : false
72
74
73
- if (params.rootUri != null ) {
74
- LOG .info(" Adding workspace {} to source path" , params.rootUri)
75
+ val folders = params.workspaceFolders
76
+ client.notifyProgress(ProgressParams (params.workDoneToken, WorkDoneProgressBegin ().apply {
77
+ title = " Adding workspace folders"
78
+ percentage = 0
79
+ }))
75
80
76
- val root = Paths .get(parseURI(params.rootUri))
81
+ folders.forEachIndexed { i, folder ->
82
+ LOG .info(" Adding workspace {} to source path" , params.rootUri)
83
+ client.notifyProgress(ProgressParams (params.workDoneToken, WorkDoneProgressReport ().apply {
84
+ message = " [${i + 1 } /${folders.size} ] ${folder.name} "
85
+ percentage = (100 * i) / folders.size
86
+ }))
77
87
88
+ val root = Paths .get(parseURI(folder.uri))
78
89
sourceFiles.addWorkspaceRoot(root)
90
+
79
91
val refreshed = classPath.addWorkspaceRoot(root)
80
92
if (refreshed) {
81
93
sourcePath.refresh()
@@ -85,7 +97,7 @@ class KotlinLanguageServer : LanguageServer, LanguageClientAware, Closeable {
85
97
InitializeResult (serverCapabilities)
86
98
}
87
99
88
- private fun connectLoggingBackend (client : LanguageClient ) {
100
+ private fun connectLoggingBackend () {
89
101
val backend: (LogMessage ) -> Unit = {
90
102
client.logMessage(MessageParams ().apply {
91
103
type = it.level.toLSPMessageType()
0 commit comments