Adding elements to PSI in PhpStorm

I would like to add elements to PSI in PhpStorm (class field, php doc comment).
I've seen examples I've tried to bas me on, but the use PsiManager.getElementFactory(), which is missing in my version.
I've also found methods like createMethodFromText(), createFieldFromText() ... but they are all part of Java-langugage classes.
Anyone would have a hint, a sample? :)

2 comments
Comment actions Permalink

I have no experience with PHP but I guess the principle is the same as with Python.

Have a look at PsiFileFactory.createFileFromText(filename, filetype, content,..). Pass a dummy php filename, an instance of php LanguageFileType and your php code snippet and it will return the PSI file element from which you can get children of.

Good luck!

0
Comment actions Permalink

Thanks, works fine :)

0

Please sign in to leave a comment.