Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "CDT/Obsolete/C editor enhancements/Easy method override"
(Initial upload) |
(+references from bugzilla) |
||
Line 29: | Line 29: | ||
* Otherwise if there are any method definitions of this class in this module, insert the stub before them | * Otherwise if there are any method definitions of this class in this module, insert the stub before them | ||
* Otherwise insert the stub at the end of module. | * Otherwise insert the stub at the end of module. | ||
+ | |||
+ | ==References== | ||
+ | |||
+ | [https://bugs.eclipse.org/bugs/show_bug.cgi?id=303870 Bug 303870] requests some functionality to automate overriding virtual methods. |
Revision as of 14:44, 8 May 2010
This is a problem page. Please treat it as a discussion page and feel free to insert your comments anywhere. My open questions are in bold--Tomasz Wesołowski 11:32, 5 May 2010 (UTC)
Contents
Problem
Overriding a method from a base class is a very common scenario. The programmer has to do a lot of redundant activities to perform this task: look up and then either copy or rewrite the method signature both in the module and in its header file.
Solution
Idea
A simple and probably optimal solution to this problem is to introduce a feature analogous to JDT - give proposals for automatic method override in Context Assist. A proposal would look like in JDT - name of the method followed by a gray comment override method in XYZ.
Details
When Context Assist is invoked from the context of a class body, the proposals (preferably high-ranked proposals) of overriding would appear. Selection of a proposal would trigger the following: - Code generation of method declaration in the class body: the same declaration as in parent class and with the current access specifier (as access specifiers don't influcence the overriding rules) - Code generation of method stub in appropriate place.
Where is the place for the method stub?
File:
- If the context is a header and there exists a matching module (matching as in ctrl+tab), append the stub to that module.
- If the context is a header and there's no matching module: ask whether to create one, create inline method stub?
- If the context is a module: append the stub to that module.
Location in module:
- If there's a preceding method in the header and it has a definition in this module, insert the stub after that method
- Otherwise if there are any method definitions of this class in this module, insert the stub before them
- Otherwise insert the stub at the end of module.
References
Bug 303870 requests some functionality to automate overriding virtual methods.