Bug 118344 - 'Add unimplemented methods' quick-fix adds the wrong methods
Summary: 'Add unimplemented methods' quick-fix adds the wrong methods
Status: VERIFIED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M6   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 118349 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-11-28 21:31 EST by Matt Lavin CLA
Modified: 2007-03-21 05:37 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Lavin CLA 2005-11-28 21:31:48 EST
Using 3.2M3, the following steps cause the 'Add unimplemented methods' quick fix to add the wrong methods to my class.

1.  Create a new plug-in project
2.  Add a plugin dependency to 'org.eclipse.team.ui' and save the change.
3.  Add a new class that subclasses 'org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant' and be sure to un-check the 'Inherited abstract methods' checkbox so that an empty class is created.
4.  Notice that a problem is associated with the file that mentions the missing required methods (this is expected).
5.  Put the cursor on the classname in the editor and use 'Ctrl-1' to bring up the quick fixes and select 'Add unimplemented methods'.

When I follow those steps I get a single method, 'setInitializationData', added to the class which is not the only required method.  'setInitializationData' is actually already implemented by the parent class so it should not be added at all. 

There are other ways to demonstate this problem:

1.  Instead of using the 'Ctrl-1' quickfix thing you can also try to use the Source-> 'Override/Implement Methods...' and notice that the wrong methods are pre-selected (actually even the wrong classes are listed in the dialog, which might be the root of this problem).
2.  Instead of un-selecting the 'Inherited abstract methods' checkbox when the class is created you can leave it selected and notice that it does not create the class with the right methods.

I didn't spend anytime checking whether the problem is related to the project being a plug-in project.  These steps just reflect how I found the problem, so a simpler testcase is probably possible.
Comment 1 Matt Lavin CLA 2005-11-28 22:25:46 EST
*** Bug 118349 has been marked as a duplicate of this bug. ***
Comment 2 Martin Aeschlimann CLA 2005-12-01 06:15:41 EST
To get the problem marker in step 4. I have to additionally add plugin dependencied to
 org.eclipse.compare,
 org.eclipse.team.core

In my case the correct 4 methods were implemented.
Comment 3 Matt Lavin CLA 2005-12-01 08:19:02 EST
Ok, that's interesting... 

Were you testing this on 3.2M3?  

Also, if you added a subclass of 'AbstractSynchronizeParticipant' without inheritied methods, how did you not have compile problems in the class?
Comment 4 Martin Aeschlimann CLA 2005-12-01 11:05:08 EST
Yes on I2005113-1215

I later removed the two dependencies again, but to my surpise did not get the compile error back, every compiled fine. Adding the unimplemented methods resulted in the bug you originally described.

Seems to be an inconsistency in jdt.core. The inconsistent hierarchy is not always reported and the hierarchy (we use ITypeBindings) must contain abstract methods that aren't abstract.
Comment 5 Olivier Thomann CLA 2007-02-09 11:37:46 EST
Kent, this seems to be a case where we don't report an inconsistent hierarchy.
Comment 6 Kent Johnson CLA 2007-02-15 13:13:45 EST
I tried this with the latest & it works fine for me.

Adding/removing the 2 missing plugins causes the correct compiler errors to appear & disappear.

With the necessaray plugin dependencies, adding the unimplemented method works correctly.
Comment 7 Eric Jodet CLA 2007-03-21 04:54:13 EDT
Verified for 3.3 M6 using build I20070320-0010