Author Topic: [Eclipse] Change method signature  (Read 2488 times)

0 Members and 1 Guest are viewing this topic.

Offline Camel

  • Hero Member
  • *****
  • Posts: 1705
    • View Profile
    • BNU Bot
[Eclipse] Change method signature
« on: December 08, 2007, 06:19:40 PM »
Today, I realized that I had a fatal flaw in my plugin system: I needed to add a parameter to every event to indicate what the source of the event was.

Crap. There are 27 event methods defined in the interface, and the interface is implemented many times in my codebase. Rewriting this by hand was going to suck, so I started looking for a way to cheat. I found it.

I opened up my interface, right clicked on the first method > refactor > change method signature. A dialog pops up with all of the existing parameters; it allows you to add new fields, and a defualt value. When you click OK, it goes through your entire codebase and changes references to that method, using the default value for new fields.

What I estimated to be a couple of hours of work was compressed in to approximately ten minutes.

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!

Offline Newby

  • x86
  • Hero Member
  • *****
  • Posts: 10880
  • Thrash!
    • View Profile
Re: [Eclipse] Change method signature
« Reply #1 on: February 04, 2008, 07:15:18 PM »
Well done. Did you go through and verify by hand afterwards that everything was correct?
- Newby
http://www.x86labs.org

Quote
[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

I'd bet that you're currently bloated like a water ballon on a hot summer's day.

That analogy doesn't even make sense.  Why would a water balloon be especially bloated on a hot summer's day? For your sake, I hope there wasn't too much logic testing on your LSAT. 

Offline Camel

  • Hero Member
  • *****
  • Posts: 1705
    • View Profile
    • BNU Bot
Re: [Eclipse] Change method signature
« Reply #2 on: February 04, 2008, 09:38:12 PM »
I always look at a diff before I commit to SVN.

<Camel> i said what what
<Blaze> in the butt
<Camel> you want to do it in my butt?
<Blaze> in my butt
<Camel> let's do it in the butt
<Blaze> Okay!