CDT/Obsolete/C editor enhancements/Easy method override
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)
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.
5/5 Kirstin Weber
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.
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.
Jens Elmenthaler If I want to do that in JDT, I use Context Menu -> Source -> Override/implement method.
Where is the place for the method stub?
- 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.
Bug 303870 requests some functionality to automate overriding virtual methods.