Search for a struct/enum across multiple workspaces; open multiple workspaces in IntelliIJ

Two related problems from the same context. I recently split a single workspace into multiple workspaces. This has made it a bit difficult with "goto-class" (an IntelliJ feature where as you type fragments of a struct/enum name, it shows all potential matches in the current workspace.)

Right now, to find a struct/enum, I'm running

rg /path-to-ws1 /path-to-ws2 ...

Also, when I try to open multiple workspaces in IntelliJ, it opens it in a separate IntelliJ window.

There are two obvious solutions to my problem:

  1. Is there a way to open multiple Rust workspaces inside a single IntelliJ IDE window ?

  2. Is there some tool I can run in the background which will index multiple workspaces and gives me a nice search interface for class/struct/traits.

I've used Intellij IDEA and that was able to have multiple modules (Intellij term) added to a single project. I expect something similar ought to be possible for Rust projects.

If you ctrlaltshifts to bring up project structure you should be able to see your modules and add a new one. This allowed double shift searching for things across all modules in the project, ctrl-click to follow things also worked across modules.

Having said that I ended up going back to modules in separate projects across multiple windows because indexing was too slow for me. You might have better luck.

1 Like

I'm confirming this works.

There is one small minor issue where the src directories are "white" instead of "light blue" which indicates something in IntelliJ IDEA (but I'm not sure what).

For reasons I have not quite figured out why, it feels a bit clunky compared to single workspace [again, I'm not sure why / can't pinpoint the exact issue yet].

Glad I could help :slight_smile:

I know how you feel with the src directories changing colors. Intellij can be very confusing, I am still frequently confused when it can't find things I think it should be able to.

My current understanding for white/blue is:

For single workspace:

  1. Let S = set of all crates mentioned in workspace/Cargo.toml

  2. Let R = transitive closure of S under "|x| -> all dependencies of x"

  3. For all p in R, p/src is marked "blue"

  4. All other .../src directories marked "white"

For project w/ multiple modules:

No idea wtf is happening.

The really crazy thing is: in the multiple module case, it appears to be indexing everything, even if the colors indicate otherwise. I dunno what's going on.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.