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

Bug 323780

Summary: "Generate Getters and Setters..." crashes
Product: [Tools] CDT Reporter: David E. Narvaez <david.narvaez>
Component: cdt-refactoringAssignee: Emanuel Graf <emanuel>
Status: RESOLVED FIXED QA Contact: Emanuel Graf <emanuel>
Severity: major    
Priority: P3 CC: malaperle
Version: 7.0   
Target Milestone: 7.0.1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Error log
none
Bugfix and test case emanuel: iplog-

Description David E. Narvaez CLA 2010-08-27 00:46:25 EDT
Build Identifier: I20100608-0911

Hi guys, 

I'm sorry if this is already reported: I did a quick scan and couldn't find anything but I'm currently in a hurry. Anyhow, just wanted to report this problem with the refactoring functionality (see the steps below).

Some clues may be that it happened to me twice on two attributes that were inside namespaces (on different classes). I'll be attaching the error log.

Reproducible: Always

Steps to Reproduce:
1. Create a C++ class
2. Create an attribute of the class
3. Try to generate Getters and Setters for that attribute (Right Click on the attribute name -> Source -> Generate Getters and Setters...)
Comment 1 David E. Narvaez CLA 2010-08-27 00:47:37 EDT
Created attachment 177582 [details]
Error log

This is what I got after trying to refactor the attributes (see original bug report)
Comment 2 Marc-André Laperle CLA 2010-08-27 02:31:24 EDT
I can reproduce that with fields in OgreMesh.h in the Ogre source code. I'll try to create a simpler example.
Comment 3 Marc-André Laperle CLA 2010-08-27 13:07:35 EDT
Test.h:

#ifndef TEST_H_
#define TEST_H_

namespace foo
{
class Test
{
    int testField;
    void foo();
};
}

#endif

Test.cpp:

#include "Test.h"
namespace foo
{
void Test::foo()
{

}
}


I think Generate Getters and Setters should handle scope like Implement method, using NameHelper.createQualifiedNameFor. This is related to bug 316083.
Comment 4 David E. Narvaez CLA 2010-09-05 19:34:00 EDT
So, what's the status on this?
Comment 5 Emanuel Graf CLA 2010-09-14 04:22:48 EDT
The cause for this is the ContainerNode in the modifacation adding the definitions. The ContainerNode can't be casted to IASTFunctionDefinition.
Comment 6 Emanuel Graf CLA 2010-09-14 06:59:41 EDT
Created attachment 178797 [details]
Bugfix and test case
Comment 7 Emanuel Graf CLA 2010-09-14 07:00:22 EDT
Fixed in HEAD and 7.0 > 20100914
Comment 8 CDT Genie CLA 2010-09-14 07:23:03 EDT
*** cdt cvs genie on behalf of egraf ***
Bug 323780: &quot;Generate Getters and Setters...&quot; crashes
<a  href=https://bugs.eclipse.org/bugs/show_bug.cgi?id=323780>https://bugs.eclipse.org/bugs/show_bug.cgi?id=323780</a> FIXED

[*] ASTModificationHelper.java 1.4.14.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ASTModificationHelper.java?root=Tools_Project&r1=1.4&r2=1.4.14.1

[*] GenerateGettersAndSettersRefactoring.java 1.11.2.1 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java?root=Tools_Project&r1=1.11&r2=1.11.2.1

[*] GenerateGettersAndSetters.rts 1.6.4.1 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.6&r2=1.6.4.1

[*] GenerateGettersAndSetters.rts 1.9 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.8&r2=1.9

[*] GenerateGettersAndSettersRefactoring.java 1.13 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java?root=Tools_Project&r1=1.12&r2=1.13

[*] ASTModificationHelper.java 1.5 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/all/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ASTModificationHelper.java?root=Tools_Project&r1=1.4&r2=1.5