Bundled Rust bundled plugin not loaded in test environment

Hello,

I have started developing a simple plugin for RustRover (Should probably support any Intellij IDE with the Rust plugin in the future) which allows filtering out usages which are recognized as tests in the references window to remove visual bloat when doing code review. The branch I’m currently working on is usages_unit_tests.
While writing tests to expand the capabilities of the plugin which can just read the #[test] at the nearest parent element that is a function, what seemed to be an easy task turned into something very complex. That’s my first Kotlin project and Intellij plugin so that’s probably the reason too.

Here is the test: filter_out_rust_tests/src/test/kotlin/NotRustTestsUsafeFilteringRuleProviderTest.kt at usages_unit_tests · iFrostizz/filter_out_rust_tests · GitHub
It’s reading test data at: src/test/testData/cfg_test.toml and should assert that the usage at the <caret> location only has the usage in the fn main(), but not in the fn some_helper()which is part of the #[cfg(test)].
It’s relying on the bundled plugin com.jetbrains.rust to build the Rust lexical elements, and it’s going to need these Rust typed Psi elements to call the isVisble() on each usage. This way, it will be able to assert that the filtered out usages are the ones we expect.

The problem is that those Rust PsiElement types are not built, instead we have some plain text PsiPlainTextImpl etc types. And what’s strange is that PluginManagerCore.isLoaded(PluginId.getId("com.jetbrains.rust")) returns false, even after calling PluginManagerCore.enablePlugin(PluginId.getId("com.jetbrains.rust")).

An “old” Github issue explained that the platform-images dependency had to be added, but that didn’t worked.

Any help is appreciated!

Thanks

The reason was that the intellij.json.backend module wasn’t loading. This was logged in the idea.log file, and because of this the org.toml.lang module wasn’t loading which made the com.jetbrains.rust disabled.
The quirk though was to add those modules, but also the intellij.json as a bundled plugin.
See: filter_out_rust_tests/build.gradle.kts at master · iFrostizz/filter_out_rust_tests · GitHub

We have such an important issue on our radars

Could you please upvote / watch it?