How to change the return type of a method

Hi,

Does anyone a way to change the return type of a PsiMethod?

Thanks in advance.

-Rubén

3 comments
Comment actions Permalink

Hello Rubén,

Does anyone a way to change the return type of a PsiMethod?


method.getReturnTypeElement().replace(PsiElementFactory.createTypeElement(PsiElementFactory.createTypeByFQClassName(...)))

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


0
Comment actions Permalink

Hi Dmitry,

Turns out that PsiElementFactory is an interface, at least in the version of the Plugin Dev API I'm working with. And I cannot find any implementing class for it. Is there any other easy way to achieve this?

Thanks so much in advance.
-Rubén

0
Comment actions Permalink

Hello Rubén,

Turns out that PsiElementFactory is an interface, at least in the
version of the Plugin Dev API I'm working with. And I cannot find any
implementing class for it. Is there any other easy way to achieve
this?


I didn't spell out the way of getting PsiElementFactory because it differs
between IDEA 7 and 8. In IDEA 7, you use PsiManager.getInstance(project).getElementFactory().

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


0

Please sign in to leave a comment.