Change signature of method

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

5 comments
Comment actions Permalink

Hello J,

The getParameterList() method allows you to add the parameters as well. Use
getParameterList().add(), .addBefore() or any similar modification methods.

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?


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


0
Comment actions Permalink

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:

Assertion failed: Write access is allowed inside write-action only (see com.intellij.openapi.application.Application.runWriteAction()) 
java.lang.Throwable


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.

0
Comment actions Permalink

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.

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:

 access is allowed inside write-action only (see
> com.intellij.openapi.application.Application.runWriteAction())
> java.lang.Throwable]]>


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.


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


0
Comment actions Permalink

that link is dead x]

[up]
found the page. Thanks

0
Comment actions Permalink

Hello J,

It's not; it's probably crippled by the NNTP/forum gate. Try http://confluence.jetbrains.net/x/nl
instead

that link is dead x]


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


0

Please sign in to leave a comment.