Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319111 - Generate getters and setters fails on complex field types
Summary: Generate getters and setters fails on complex field types
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 7.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 8.0   Edit
Assignee: Elena Laskavaia CLA
QA Contact: Emanuel Graf CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 319273
  Show dependency tree
 
Reported: 2010-07-07 07:57 EDT by Tomasz Wesolowski CLA
Modified: 2010-08-18 21:23 EDT (History)
2 users (show)

See Also:


Attachments
bugfix (7.32 KB, patch)
2010-07-07 07:57 EDT, Tomasz Wesolowski CLA
elaskavaia.cdt: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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