PsiClass -> Source Root -> file ?

Another question on my way to a seam plugin:
If I have a PsiClass: How do I check if there's a file seam.properties
in the root of any source folder of the class's module?
(So that it gets packaged in the root of the module's jar file.)

Thanks for any help!
I am currently a little confused with virtual and psi files, filesystems
and search helpers...

3 comments

Some things that may help:

- PsiClass.getContainingFile().getVirtualFile() gets the VirtualFile instance of your PsiClass.

- VfsUtil.getModuleForFile() will find the Module for a VirtualFile instance.

- To get all Source Roots for a specific Module, use ModuleRootManager.getFiles(RootOrderType.SOURCES). Once you got the roots, you can check whether they contain the file you're looking for using VirtualFile.findChild(name).

- If you want to find the file on any directory/package level, PsiShortNamesCache.getFilesByName() might help to efficiently find the all files with the name you're looking for instead of traversing the roots.

HTH,
Sascha

0

Stephen Kelvin wrote:

Another question on my way to a seam plugin:
If I have a PsiClass: How do I check if there's a file seam.properties
in the root of any source folder of the class's module?
(So that it gets packaged in the root of the module's jar file.)

Thanks for any help!
I am currently a little confused with virtual and psi files, filesystems
and search helpers...


I believe the basic idea is:
1. get vfile from PsiClass.getContainingFile().getVirtualkFile()
2. get module from ModuleRootManager maybe?
3. get sourcepaths from module or modulerootmanager
4. check for that file with findChild or getChild or whatever on each
sourcepath

0

Stupid Web->NNTP sync seems to be broken:
http://intellij.net/forums/message.jspa?messageID=5083956#5083984 though there's not much
to add to what Keith wrote anyway...

Sascha

0

Please sign in to leave a comment.