diff --git a/Common/src/main/java/com/tabnineCommon/chat/commandHandlers/WorkspaceFoldersHandler.kt b/Common/src/main/java/com/tabnineCommon/chat/commandHandlers/WorkspaceFoldersHandler.kt index 48aeaf5a..f54a2d0f 100644 --- a/Common/src/main/java/com/tabnineCommon/chat/commandHandlers/WorkspaceFoldersHandler.kt +++ b/Common/src/main/java/com/tabnineCommon/chat/commandHandlers/WorkspaceFoldersHandler.kt @@ -11,7 +11,7 @@ class WorkspaceFoldersHandler(gson: Gson) : ChatMessageHandler? { - val project = ProjectManager.getInstance().openProjects.firstOrNull() ?: return null + private fun updateWorkspaceRootPaths() { + val rootPaths = ProjectManager.getInstance() + .openProjects + .map { getWorkspaceRootPaths(it) ?: emptyList() } + .reduceOrNull { acc, cur -> acc.plus(cur) } + + if (rootPaths.isNullOrEmpty()) return + Logger.getInstance(javaClass).info("All root paths collected: $rootPaths") + + binaryRequestFacade.executeRequest(Workspace(rootPaths)) + } + + fun getWorkspaceRootPaths(project: Project): List? { if (project.isDisposed) { - Logger.getInstance(javaClass).warn("Project ${project.name} is disposed, skipping workspace update") + Logger.getInstance(javaClass).warn("Project ${project.name} is disposed, skipping root paths resolution") return null } @@ -40,7 +54,7 @@ class WorkspaceListenerService { for (contentRootUrl in ProjectRootManager.getInstance(project).contentRootUrls) { val url = URL(contentRootUrl) if (url.protocol != "file") { - Logger.getInstance(javaClass).debug("Skipping workspace update for project ${project.name}, unsupported protocol ${url.protocol}") + Logger.getInstance(javaClass).debug("$url in project ${project.name} has unsupported protocol (${url.protocol})") continue } rootPaths.add(url.path)