Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 138130

Summary: [quick fix] create method in super types
Product: [Eclipse Project] JDT Reporter: Andrew Taylor <andy>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: enhancement    
Priority: P3 CC: jasonab, markus.kell.r, martinae, mn
Version: 3.2   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Andrew Taylor CLA 2006-04-23 00:13:14 EDT
When choosing quick fix where create method is an option, if the current class descends from another class, a choice should be offered to create in super.  Ie:

public class SpecializedSprocket extends Sprocket {
  public void something() {
    doSomethingElse();
//   ^-- quick fix on non-existant method here
  }
}

quick fix panel should contain
  - create doSomethingElse()
  - create Sprocket.doSomethingElse()

Created method should be protected, of course.

Thoughts?  

Thanks for making my life easier :)
Comment 1 Jerome Lanneluc CLA 2006-04-23 04:35:36 EDT
Moving to JDT UI
Comment 2 Mykola Nikishov CLA 2008-12-01 11:09:55 EST
Andrew, and what this quick fix should suggest for something like 'SpecializedSprocket extends Sprocket implements A, B, C, D'?
Comment 3 Andrew Taylor CLA 2008-12-01 11:48:30 EST
Hmmm, perhaps 
- create in Sprocket
- create in A
- create in B
- create in C
- create in D

If it's created in A-D (interfaces) it needs to be created in an impl, but that can be left, I think.  There will be another error to resolve but that is easy enough and can be done at the appropriate place (ie the root impl of the changed interface or descendants, mark abstract, etc).  If there are many interfaces, the quickfix could get ugly, but in reality, it's rare that I use more than 2, personally.
Comment 4 Andrew Taylor CLA 2008-12-01 11:49:52 EST
Hmm, more accurately:
- Create doSomethingElse()
- create Sprocket.doSomethingElse()
- create A.doSomethingElse()
- create B.doSomethingElse()
- create C.doSomethingElse()
- create D.doSomethingElse()

Comment 5 Jason Bennett CLA 2012-07-06 19:17:30 EDT
This bug appears to have been implemented in another one.
Comment 6 Markus Keller CLA 2012-07-09 14:42:50 EDT
(In reply to comment #5)
> This bug appears to have been implemented in another one.

I don't see the quick fix requested here. There is a quick fix for super.doSomethingElse(), but that's something else.

*** This bug has been marked as a duplicate of bug 50749 ***