mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[rdct] Provide access to project-level sessions from an app-level one. Should save people from ad-hoc project guessing and dealing with the default project
GitOrigin-RevId: 766f599d5a538f8b6a89571805dddc9bc51cdee5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4580cca2e5
commit
a0d2bd1d3a
@@ -52,7 +52,15 @@ interface ClientSession : ComponentManager {
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
@ApiStatus.Internal
|
||||
interface ClientAppSession : ClientSession
|
||||
interface ClientAppSession : ClientSession {
|
||||
/**
|
||||
* Clients may have access only to some of the projects.
|
||||
* Currently, there's a limitation in Code With Me (CWM-2149) because of the complexity with permissions and calls.
|
||||
*
|
||||
* For remote-dev having several projects, or not having one open is natural same as in a local setup
|
||||
*/
|
||||
val projectSessions: List<ClientProjectSession>
|
||||
}
|
||||
|
||||
/**
|
||||
* Project level [ClientSession]
|
||||
@@ -60,6 +68,15 @@ interface ClientAppSession : ClientSession
|
||||
@ApiStatus.Experimental
|
||||
@ApiStatus.Internal
|
||||
interface ClientProjectSession : ClientSession {
|
||||
/**
|
||||
* Project this session belongs to. Unlike sessions there's only one project,
|
||||
* independently of how many active users is operating with it.
|
||||
*/
|
||||
val project: Project
|
||||
|
||||
/**
|
||||
* Some features live on app-level (e.g., UI, actions, popups) this allows to get from project-level to app-level.
|
||||
* It's recommended to get session instead on manual [ClientId] manipulation
|
||||
*/
|
||||
val appSession: ClientAppSession
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.intellij.openapi.components.ServiceDescriptor
|
||||
import com.intellij.openapi.components.impl.stores.IComponentStore
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import com.intellij.openapi.project.impl.ProjectImpl
|
||||
import com.intellij.serviceContainer.ComponentManagerImpl
|
||||
import com.intellij.serviceContainer.PrecomputedExtensionModel
|
||||
@@ -152,6 +153,9 @@ open class ClientAppSessionImpl(
|
||||
return pluginDescriptor.appContainerDescriptor
|
||||
}
|
||||
|
||||
override val projectSessions: List<ClientProjectSession>
|
||||
get() = ProjectManager.getInstance().openProjects.mapNotNull { ClientSessionsManager.getProjectSession(it, this) }
|
||||
|
||||
init {
|
||||
@Suppress("LeakingThis")
|
||||
registerServiceInstance(ClientAppSession::class.java, this, fakeCorePluginDescriptor)
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.openapi.application.impl.ApplicationImpl
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import com.intellij.openapi.project.impl.ProjectImpl
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
@@ -26,6 +27,14 @@ sealed class ClientSessionsManager<T : ClientSession> {
|
||||
return getInstance(project).getSession(session.clientId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Clients may not have access to certain projects
|
||||
* @return a list of project-level sessions available to a certain [ClientAppSession]
|
||||
*/
|
||||
fun getAllProjectSession(session: ClientAppSession): List<ClientProjectSession> {
|
||||
return ProjectManager.getInstance().openProjects.mapNotNull { getProjectSession(it, session) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a project-level session for a particular client.
|
||||
* @see ClientProjectSession
|
||||
|
||||
Reference in New Issue
Block a user