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

Bug 319111

Summary: Generate getters and setters fails on complex field types
Product: [Tools] CDT Reporter: Tomasz Wesolowski <kosashi>
Component: cdt-refactoringAssignee: Elena Laskavaia <elaskavaia.cdt>
Status: RESOLVED FIXED QA Contact: Emanuel Graf <emanuel>
Severity: normal    
Priority: P3 CC: elaskavaia.cdt, yevshif
Version: 7.0   
Target Milestone: 8.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 319273    
Attachments:
Description Flags
bugfix elaskavaia.cdt: iplog+

Description Tomasz Wesolowski CLA 2010-07-07 07:57:06 EDT
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
Comment 1 Tomasz Wesolowski CLA 2010-07-07 07:57:59 EDT
Created attachment 173638 [details]
bugfix

Made the refactoring receive the name from the innermost declarator
Comment 2 Emanuel Graf CLA 2010-07-08 10:14:30 EDT
Your patch only fixes the exception the generated code is wrong. I'm opend bug 319273 for this issue.
Comment 3 Tomasz Wesolowski CLA 2010-07-08 11:06:58 EDT
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.
Comment 4 Elena Laskavaia CLA 2010-08-10 22:38:16 EDT
fix applied on head cdt 8.0, thanks
Comment 6 CDT Genie CLA 2010-08-18 21:23:01 EDT
*** 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