Modifying method parameters

Hello.

I'm making a plugin for ReSharper 4 to have better control of the method parameters (I need to modify spacing between the parameter type and name).
I would like it to run on code cleanup, so I made it implement ICodeCleanupModule.

My question is: how can I get a list of all the methods in a file? I saw from many examples that there is the ToTreeNode() method, however, is there a way to better navigate it?
Basically, I would like something like a List<IMethodDeclarationNode>.

Any advice for me?

Thanks in advance,
Igal.

3 comments

To get the full lust of methods in the file, traverse the AST tree and find
all elements whichimplement interface "IMethodDeclaration". But may be you
need not only methods, but all entities which could have parameters? Then do
find implementations of "IParametersOwnerDeclaration"

--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


"Igal Tabachnik" <no_reply@jetbrains.com> wrote in message
news:7327477.74381232319084219.JavaMail.clearspace@app4.labs.intellij.net...

Hello.

>

I'm making a plugin for ReSharper 4 to have better control of the method
parameters (I need to modify spacing between the parameter type and name).
I would like it to run on code cleanup, so I made it implement
ICodeCleanupModule.

>

My question is: how can I get a list of all the methods in a file? I saw
from many examples that there is the ToTreeNode() method, however, is
there a way to better navigate it?
Basically, I would like something like a List<IMethodDeclarationNode>.

>

Any advice for me?

>

Thanks in advance,
Igal.

>

---
Original message URL:
http://www.jetbrains.net/devnet/message/5230352#5230352



0

pasynkov wrote:

To get the full lust of methods in the file, traverse the AST tree and find
all elements whichimplement interface "IMethodDeclaration". But may be you
need not only methods, but all entities which could have parameters? Then do
find implementations of "IParametersOwnerDeclaration"


Thank you very much for the answer. I ended up doing just what you suggested! Also, thank you for the tip.
I do have another question, however. In my implementation, I use the TreeElementFactory to construct a new IWhitespaceNode element with appropriate padding, then use the LowLevelModificationUtil in order to replace the IWhitespaceElement, in the the IRegularParameterDeclarationNode.
Is this the correct way of doing it? I mean, this solution works - I have the required result, but I was wondering if that's the proper way to do it.
Just to make sure, I'm attempting to achieve the following result:

private void MethodName(string         parameter1,
                        ISomeInterface parameter2)
{
   ...
}

Thanks very much!

0

Yes, you've done right.
The high-level API exisits for semantic entities, but not for syntax one
(such as whitespace tuning).

--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


"Igal Tabachnik" <no_reply@jetbrains.com> wrote in message
news:12583621.4991232737633620.JavaMail.clearspace@app4.labs.intellij.net...

pasynkov wrote:
>
> To get the full lust of methods in the file, traverse the AST tree and
> find
> all elements whichimplement interface "IMethodDeclaration". But may be you
> need not only methods, but all entities which could have parameters? Then
> do
> find implementations of "IParametersOwnerDeclaration"
>

>

Thank you very much for the answer. I ended up doing just what you
suggested! Also, thank you for the tip.
I do have another question, however. In my implementation, I use the
TreeElementFactory to construct a new IWhitespaceNode element with
appropriate padding, then use the LowLevelModificationUtil in order to
replace the IWhitespaceElement, in the the
IRegularParameterDeclarationNode.
Is this the correct way of doing it? I mean, this solution works - I have
the required result, but I was wondering if that's the proper way to do
it.
Just to make sure, I'm attempting to achieve the following result:

>

private void MethodName(string parameter1,
ISomeInterface parameter2)
{
...
}

>

Thanks very much!

>

---
Original message URL:
http://www.jetbrains.net/devnet/message/5230747#5230747



0

Please sign in to leave a comment.