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

Bug 334077

Summary: [QuickFix] Adding missing methods with UnsupportedOperationException as body
Product: [Eclipse Project] JDT Reporter: Aaron Digulla <digulla>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: enhancement    
Priority: P3 CC: markus.kell.r
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Aaron Digulla CLA 2011-01-12 07:37:26 EST
Build Identifier: 3.6.1

Please add an option to the QuickFix "Implement missing methods" that allows to generate the missing methods with a body that throws an UnsupportedOperationException.

That would make it much more safe to implement huge interfaces like ResultSet partially.

Reproducible: Always
Comment 1 Markus Keller CLA 2011-01-17 10:07:03 EST
You can configure the body of generated methods in Preferences > Java > Code Style > Code Templates. Edit "Method Body" and use a pattern like this:

// ${todo} Auto-generated method stub
throw new UnsupportedOperationException("${enclosing_method}");
${body_statement}
Comment 2 Aaron Digulla CLA 2011-01-21 22:32:50 EST
The workaround works for me, too. It's just a bit tedious to change the body all the time. Is it possible to change the UI so I can assign *several* templates and then select them in the quick fix?

Might be useful for other things as well, like when you work on different projects (say OSS ones and for your company). You probably don't want the EPL header in your company's sources...
Comment 3 Markus Keller CLA 2011-01-24 05:29:00 EST
(In reply to comment #2)
You can set project-specific code templates.