Toolwindow support for Multi-project workspaces?

I’d like to be able to use the multi-project workspaces feature, I think it would be really handy. However, I’m unsure how to support tool windows in my plugins. It’s not at all clear from the documentation if workspaces provide a way to use the tool windows from the aggregated projects. It seems that e.g. Maven/Gradle have special support for this. Is it possible to add this support for third-party plugins, and if so, how?

Do you mean this Workspace?

I think workspaces do not affect tool windows now and each subsystem must deal with multiple content roots and implement their support in UI. Multiple content roots for projects are supported for more than 10 years, the plugin just makes it convenient to import projects and customizes the Project view.

It should work fine in most cases. If you have any issues with your custom plugin, let us know, there might be wrong API usage when a plugin finds workspace as project root instead of the current project itself.

In my plugin, if the user has a workspace open, what is the model it should use? Is there a single Project for the whole workspace, and the individual modules from the projects the user has open appear in that? Or is there some sort of sub-project concept?

My plugin supports several Maven/Gradle style JVM build tools. These would normally have a toolwindow per project, but should they have a single unified view in a workspace?

This is not true, if you had a monorepo in the past with multiple Gradle projects they could be imported all in single Gradle tool window as multiple nodes.

The model has not changed since then:

  • Project == Workspace is a single entity for the IJ window
  • Gradle/Maven imports multiple Module instances per each big project
  • Each Gradle project (big one with subprojects) has com.intellij.ide.workspace.Subproject instance

Example for actions to get access:


fun getSelectedSubprojects(e: AnActionEvent): List<Subproject> {
  val data = LangDataKeys.SELECTED_ITEMS.getData(e.dataContext) ?: return emptyList()
  return data.filterIsInstance<com.intellij.ide.workspace.projectView.SubprojectNode>().map { it.subproject }
}

Unfortunately, we have not bundled the plugin yet and many APIs may change in the future when we will

I can’t find com.intellij.ide.workspace.Subproject in the community source, the only related-looking thing is com.intellij.openapi.project.workspace.SubprojectInfoProvider (internal). Is that in the plugin rather than the platform? If so, that will make adding support for things that need to be subproject-aware quite difficult. I’ll need to think about how to make this work, especially for build systems.

How does this work with search scopes, for example? If I get `ProjectScope.getAllScope()`, will that now return results across the whole workspace?

The plugin is closed source so far and you need to depend on it to get its APIs.

Scopes will work with the Project as before, just as if all Modules reside in one big project.

Ok. It seems like it might be a bit early to try to integrate with this. But I’m looking forward to it when it’s possible!

You may start with supporting just many content roots of Project. And never assume a Project has a root directory, there are many. All APIs for that exist for many years in the platform

Yes, I already do all that.