mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Bug 323780: "Generate Getters and Setters..." crashes
https://bugs.eclipse.org/bugs/show_bug.cgi?id=323780 FIXED
This commit is contained in:
parent
82850038be
commit
96b0cc259d
3 changed files with 88 additions and 6 deletions
|
@ -76,11 +76,14 @@ public class ASTModificationHelper {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INSERT_BEFORE:
|
case INSERT_BEFORE:
|
||||||
T insertedTNode = cast(parentModification.getNewNode(), clazz);
|
newNode = parentModification.getNewNode();
|
||||||
|
if (newNode instanceof ContainerNode) {
|
||||||
int targetNodeIndex = modifiedChildren.indexOf(parentModification.getTargetNode());
|
ContainerNode contNode = (ContainerNode) newNode;
|
||||||
if(targetNodeIndex >= 0){
|
for (IASTNode node : contNode.getNodes()) {
|
||||||
modifiedChildren.add(targetNodeIndex, insertedTNode);
|
insertNode(clazz, modifiedChildren, parentModification, node);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
insertNode(clazz, modifiedChildren, parentModification, newNode);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -92,6 +95,16 @@ public class ASTModificationHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private <T> void insertNode(Class<T> clazz, ArrayList<T> modifiedChildren,
|
||||||
|
ASTModification parentModification, IASTNode newNode) {
|
||||||
|
T insertedTNode = cast(newNode, clazz);
|
||||||
|
|
||||||
|
int targetNodeIndex = modifiedChildren.indexOf(parentModification.getTargetNode());
|
||||||
|
if (targetNodeIndex >= 0) {
|
||||||
|
modifiedChildren.add(targetNodeIndex, insertedTNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private <T> T[] newArrayInstance(Class<T> clazz, int size) {
|
private <T> T[] newArrayInstance(Class<T> clazz, int size) {
|
||||||
return (T[]) Array.newInstance(clazz, size);
|
return (T[]) Array.newInstance(clazz, size);
|
||||||
|
|
|
@ -1406,3 +1406,72 @@ void test::setI(int i)
|
||||||
|
|
||||||
#endif /* TEST_H_ */
|
#endif /* TEST_H_ */
|
||||||
|
|
||||||
|
//!Bug 323780 "Generate Getters and Setters..." crashes
|
||||||
|
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
|
||||||
|
//@.config
|
||||||
|
filename=Test.h
|
||||||
|
getters=testField
|
||||||
|
setters=testField
|
||||||
|
|
||||||
|
//@Test.h
|
||||||
|
#ifndef TEST_H_
|
||||||
|
#define TEST_H_
|
||||||
|
|
||||||
|
namespace foo
|
||||||
|
{
|
||||||
|
class Test
|
||||||
|
{
|
||||||
|
int /*$*/testField/*$$*/;
|
||||||
|
void foo();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
//=
|
||||||
|
#ifndef TEST_H_
|
||||||
|
#define TEST_H_
|
||||||
|
|
||||||
|
namespace foo
|
||||||
|
{
|
||||||
|
class Test
|
||||||
|
{
|
||||||
|
int testField;
|
||||||
|
void foo();
|
||||||
|
public:
|
||||||
|
int getTestField() const;
|
||||||
|
void setTestField(int testField);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
//@Test.cpp
|
||||||
|
#include "Test.h"
|
||||||
|
|
||||||
|
namespace foo
|
||||||
|
{
|
||||||
|
|
||||||
|
void Test::foo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=
|
||||||
|
#include "Test.h"
|
||||||
|
|
||||||
|
namespace foo
|
||||||
|
{
|
||||||
|
int Test::getTestField() const
|
||||||
|
{
|
||||||
|
return testField;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Test::setTestField(int testField)
|
||||||
|
{
|
||||||
|
this->testField = testField;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Test::foo()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue