IntelliJ IDEA Open API and Plugin Development Is Deprecated. Join our JetBrains Platform Community.

How to get the test sources directories of the module of given virtualfile

Answered

That's it, my pluging generates test objectmother for java classes so, when selected that classes, I would like to generate their correponding object mothers in the same package in its corresponding testsource directory.

How can I get the testsource directory(or directories) from the virtualfile selected by user?

0
2 comments

Via com.intellij.openapi.roots.ModuleRootManager#getInstance, obtain com.intellij.openapi.roots.ModuleRootModel#getSourceRoots(org.jetbrains.jps.model.module.JpsModuleSourceRootType<?>) that allows querying Module's source/content roots etc. You can use com.intellij.psi.JavaDirectoryService to create class.

1

Thanks, works flawlessly :D

0

Please sign in to leave a comment.