R1234
R1234

Reputation: 484

Replacing a method with only particular types of parameter in Eclipse

In the code I'm debugging right now, I see the append method for Stringbuilder being called repeatedly.

I want to replace all occurennces of append which are passed any String arguments append(String str) by append(Mycustomfunction(String str))

Also append can take multiple types of arguments, but I just want to change those which have a String argument.

Anyway to do this more efficiently then inserting this line manually at 1000+ occurences?

EDIT : Adding an example Example

a.append("My Name")
a.append(result.getString("something"))
a.append(2)
a.append(true)

I want to change the first two occurences only to

a.append(Myfunction("My Name"));
a.append(Myfunction(result.getString("something")));
a.append(2);
a.append(true);

Upvotes: 1

Views: 113

Answers (2)

Juned Ahsan
Juned Ahsan

Reputation: 68715

How about using 2 replace commands

1) replace a.append(" with a.append(Myfunction("

2) replace a.append(result.getString with a.append(Myfunction(result.getString(

Upvotes: 0

chandan Singh
chandan Singh

Reputation: 67

Did you try replace functionality(Ctrl+F) of eclipse? And click the regex checkbox, then define the appropriate regular expression in the find textbox.

Upvotes: 1

Related Questions