I develop a sonar plugin for intellij and want also get it work for phpstorm. To calculate file pathes correctly I need to know, what is the source root of each source code file.
For Intellij Idea I do it this way:
VirtualFile sourceRootForFile = ProjectFileIndex.SERVICE.getInstance(file.getProject()).getSourceRootForFile(virtualFile);
But for phpstorm this returns null, thus I workaround it currently by:
sourceRootForFile = ProjectFileIndex.SERVICE.getInstance(file.getProject()).getContentRootForFile(virtualFile);
This gets my approach working somehow, but is not a fully correct way, because php source files are also located in "src" directory and not in root directory of the project.
So how do I get the correct source root for a file in phpstorm?
phpstorm 6.0.2, intellij idea 12.x