Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 321071 - ChangeGenerator deforms the code after refactoring
Summary: ChangeGenerator deforms the code after refactoring
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 7.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-27 17:58 EDT by Tomasz Wesolowski CLA
Modified: 2020-09-04 15:17 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Wesolowski CLA 2010-07-27 17:58:08 EDT
Reproduce:

1) apply patch for ASTWriter from bug 321069 if it's not yet committed 
2) apply patches for refactoring from bug 319111 and bug 319273
3) create a new C++ project and new class with class wizard' default settings, use this code:

class vprob {
public:
	int (*fp)();
	int (*(*aFunction())[2]);
};

4) run 'generate getters and setters', generate both for fp
5) observe the following code being generated in the header:

class vprob {
public:
	int (*fp)();
	int (*getFp() const)();
    void setFp(int(*fp)());
    int (*((*aFunction())[2]); // syntax error here
};

---

ASTWriter generates correct code, but it gets malformed somehow in ChangeGenerator. Go to:
org.eclipse.cdt.internal.core.dom.rewrite.changegenerator.ChangeGenerator.reformatSynthCode(IASTNode, String)
Put a breakpoint on that method, reproduce the problem again and observe how the extra '(' is created. Some arcane magic is done there.

This needs to be fixed or we'll have some more random unpredictable syntax errors after refactoring.