Change signature of method Follow
hi
I'm trying to create a plugin which would at some point add parameters to constructor of some known class. Position of this class is also known. So finding this class and opening its file isn't a big challenge but now i've stopped at this adding parameter part.
I've looked for code of 'Change signature' option from intellij in git repository but couldn't find anything good.
I've tried to get PsiClass and then get constructor as PsiMethod. There is a method getParameterList() but this is only to read this parameters, not to change them.
Anyone knows good way to change/add parameters to class constructor?
Thanks in advance x]
J T
Please sign in to leave a comment.
Hello J,
The getParameterList() method allows you to add the parameters as well. Use
getParameterList().add(), .addBefore() or any similar modification methods.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Thanks! Haven't noticed that methods... really don't know how could I missed it... x]
But when I add some parameter, automatically IntelliJ /as I believe/ tries to save changes in file. Then I get many Assertion failed exceptions:
I know that it is possible to register pluigin with that method Application.runWriteAction() but is it neccesary? Why IntelliJ automatically wants to save changes after add() method? Is there a way to avoid it?
Perhaps it tries to save changes to file when it looses focus on file? I think I had simillar situation in the past.
Hello J,
The runWriteAction() method has nothing to do with saving changes. Please
refer to http://confluence.jetbrains.net/display/IDEADEV/IntelliJIDEAArchitectural+Overview
to find out what it actually does.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
that link is dead x]
[up]
found the page. Thanks
Hello J,
It's not; it's probably crippled by the NNTP/forum gate. Try http://confluence.jetbrains.net/x/nl
instead
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"