Community
Participate
Working Groups
Build Identifier: I20100312-1448 The refactoring assumes in several places that every field's ASTName can be accessed by IASTDeclarator.getName(), which actually returns an empty name in case of complex types. This leads to an exception when trying to generate a getter or setter for those. Reproducible: Always Steps to Reproduce: 1. Create new .cpp file with code: class X { int (*(*funcptr)())[2]; }; 2. Select the class name, run Refactoring -> Generate getters and setters 3. Mark both getter and setter, click 'Finish' 4. Observe StringIndexOutOfBoundsException exception
Created attachment 173638 [details] bugfix Made the refactoring receive the name from the innermost declarator
Your patch only fixes the exception the generated code is wrong. I'm opend bug 319273 for this issue.
Not only exception - the declarator name was retrieved incorrectly in many places, causing this exception but also statements like "this-> = ;" and AFAICR wrong getter/setter names. But yes, this refactoring needs more changes - invalid return type deduction (bug 319273) is one thing and there are some special cases to consider in bug 319278 and bug 319279.
fix applied on head cdt 8.0, thanks
*** cdt cvs genie on behalf of elaskavaia *** Bug 319111 - Generate getters and setters fails on complex field types [*] FunctionFactory.java 1.8 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java?root=Tools_Project&r1=1.7&r2=1.8 [*] GetterSetterInsertEditProvider.java 1.5 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java?root=Tools_Project&r1=1.4&r2=1.5 [*] GetterAndSetterContext.java 1.6 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterAndSetterContext.java?root=Tools_Project&r1=1.5&r2=1.6
*** cdt cvs genie on behalf of elaskavaia *** Bug 319111 - revert test patch - not working yet [*] GenerateGettersAndSetters.rts 1.8 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.ui.tests/resources/refactoring/GenerateGettersAndSetters.rts?root=Tools_Project&r1=1.7&r2=1.8