How to use PsiDirectory.createClass(String name, String templateName)?

Trying to create a class from a custom template but *PsiDirectorycreateClass(newName, "foobar") *always fails with "Cannot create foobar - incorrect foobar template". As a test I have created a usable foobar template, which can be accessed via the standard "New->foobar" command. Apparently I'm getting the templateName parameter wrong?

5 comments
Comment actions Permalink

This error is indeed caused by incorrect template. Can you post the template text here?

0
Comment actions Permalink

This error is indeed caused by incorrect template. Can you post the template text here?

0
Comment actions Permalink

I have copied the standard class template for this test. I can run it manually and it works correctly. But I get the error if I try to run the same template via the Open API.

0
Comment actions Permalink

Do you set all variables mentioned in template text? If not the text is lekely to be nonparsable.

0
Comment actions Permalink

Oh, now I see, this method is not interactive. How can I programmatically launch the "create class from template" function? Also, is it possible to place the template in a location that's not visible to the user?

0

Please sign in to leave a comment.