com.intellij.psi.PsiElementFactory not available in PhpStorm SDK (EAP)

Hi,

can somebody tell me, why com.intellij.psi.PsiElementFactory is not available in PhpStorm JDK (maybe also in others, but I just got an issue for PhpStorm)?

Thanks,

Martin

 

0

Hi Martin. It should be available. Could you please describe in details what difficulties do you encounter?

0

Hi Artem,

I used this class in a CSV plugin for Intellij. Some days ago an issue was opened by a PhpStorm user, that this exception would appear:

java.lang.NoClassDefFoundError: com/intellij/psi/PsiElementFactory$SERVICE

So I downloaded the latest EAP version and gave it a try - and the exception occured for me as well.

Therefore, I pointed the SDK for the plugin to the PhpStorm directory, and the Java compiler also complained that this class was not found. My first reaction was like yours: “It should be available” - and I opened this thread...

0

Despite its name, the class belongs to the Java language API. I'm sorry, I had to check it before asking you for details. And Java is not available in PhpStorm. You can use com.intellij.psi.PsiFileFactory as a replacement. Just create a dummy file of desired type and traverse it using #getChildren()/#getNextSibling() or com.intellij.psi.PsiElementVisitor to find a needed element.

0

But then the package for this class is very confusing when developing a plugin, especially because the class name itself (and the general purpose of PsiElement) does not indicate any dependency to Java as well. And it is hard to check against all IntelliJ IDEs, especially without owning the suite.

Nevertheless, thanks a lot for the information and your tips!

0

I totally agree with you. I think this is an artifact of the past when IDEA was the only JetBrains' IDE and Java was the only supported language. And no one is going to change the name due to backward compatibility. Still, JavaDoc gives a hint that the class belongs to the Java part.

/**
* Service for creating instances of Java, JavaDoc, JSP and XML PSI elements which don't have
* an underlying source code file.
*
* @see JavaPsiFacade#getElementFactory()
*/
0

请先登录再写评论。