How to create PsiMethod constructor

I am writing a plugin that generates in one action empty constructor, getters, setters and a constructor that initializes all fields from arguments.

I figured how to create getters, setters and the empty constructor (by using PropertyUtil and PsiElementFactory).

How can I create a constructor (PsiMethod) that initializes all the fields ?
Implementing PsiMethod seems a little tough especially the find* methods.

1 comment

Hello Alexander,

I am writing a plugin that generates in one action empty constructor,
getters, setters and a constructor that initializes all fields from
arguments.

I figured how to create getters, setters and the empty constructor (by
using PropertyUtil and PsiElementFactory).

How can I create a constructor (PsiMethod) that initializes all the
fields ? Implementing PsiMethod seems a little tough especially the
find* methods.


You don't need to implement PsiMethod at all. Just add the necessary statements,
created with PsiElementFactory.createStatementFromText(), to the method body
using PsiElement.add().

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please sign in to leave a comment.