Is it possible to create a java class with JCodeModel in a plugin?
Answered
Hello everyone,
This may be a stupid question, but is it possible to write JCodeModel to a PSI File?
I know that I can do: codeModel.build(codeWriter)
, but in Idea Plugin all work with files
does it happen via VirtualFile or PsiFile?
Perhaps I should generate a Java class using Psi?
Please sign in to leave a comment.
Hi Anastasiia,
You can generate a class with an external library and create a file from a text.
See https://plugins.jetbrains.com/docs/intellij/psi-files.html#how-do-i-create-a-psi-file
Hi Karol Lewandowski thank you! I used it
Hi,
It is better to use PSI API (
PsiFileFactory.createFileFromText()
I linked). VirtualFile is a low-level API.