sakthi
sakthi

Reputation: 339

How to get full method name in eclipse plugin application

For example my method name is

public static Address convert(final com.test.Address wsAddress)throws Exception

I want the whole line.

If I do

IMethod[] methods=type.getMethods();
IMethod method=methods[0];
String mname=method.toString();
mname=mname.substring(0, mname.indexOf(")")+1);

I get only

Address convert(com.test.Address)

Upvotes: 0

Views: 74

Answers (1)

Seelenvirtuose
Seelenvirtuose

Reputation: 20608

The interface IMethod extends the interface IMember. This interface provides a method called getFlags(), with which you can query the modifiers of the member in question. See this method's documentation for more details.

With the help of other query methods (e.g. getElementName(), getParameterNames(), getReturnType(), ...), you must assemble the whole method signature as it appears in the source. There is no way to call only one method and get the whole source declaration line.


EDIT

If you want to get the full method source code, you can also invoke the method getSource(). However, that will also provide the method's body. So the question should be: What are you trying to achieve?

Upvotes: 2

Related Questions