Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java8
-rw-r--r--core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/InsertLocation.java2
3 files changed, 18 insertions, 14 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java
index 5aa35c3d718..44ac7d9f4bd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java
@@ -181,7 +181,6 @@ public class ChangeGenerator extends CPPASTVisitor {
fileLocation = node.getTranslationUnit().flattenLocationsToFile(node.getNodeLocations());
}
}
-
return fileLocation;
}
@@ -259,8 +258,13 @@ public class ChangeGenerator extends CPPASTVisitor {
newNodeCode));
break;
case APPEND_CHILD:
+ if(modification.getTargetNode() instanceof IASTTranslationUnit && ((IASTTranslationUnit)modification.getTargetNode()).getDeclarations().length > 0) {
+ IASTTranslationUnit tu = (IASTTranslationUnit)modification.getTargetNode();
+ IASTDeclaration lastDecl = tu.getDeclarations()[tu.getDeclarations().length -1];
+ targetLocation = lastDecl.getFileLocation();
+ }
String lineDelimiter = FileHelper.determineLineDelimiter(FileHelper.getIFilefromIASTNode(modification.getTargetNode()));
- edit.addChild(new InsertEdit(targetLocation.getNodeOffset()
+ edit.addChild(new InsertEdit(targetLocation.getNodeOffset()
+ targetLocation.getNodeLength(),lineDelimiter + lineDelimiter + newNodeCode));
break;
}
diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts
index 0f93171e49e..b37756e99be 100644
--- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts
+++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts
@@ -127,12 +127,12 @@ class Demo
//=
#include "A.h"
+
+
void Demo::SubClass::test()
{
}
-
-
//!method declared in otherwise empty class without cpp file
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@@ -180,11 +180,11 @@ public:
//=
+
void A::test()
{
}
-
//!implement in existing namespace
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@@ -633,12 +633,12 @@ public:
//=
#include "A.h"
+
+
void Class::test(int param1, int param2, int param3)
{
}
-
-
//!static method
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@@ -658,12 +658,12 @@ public:
//=
#include "A.h"
+
+
void Class::test()
{
}
-
-
//! Bug 238253 Pointer refence of the return value lost
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@@ -682,12 +682,12 @@ public:
//=
#include "A.h"
+
+
int *TestClass::get(char *val)
{
}
-
-
//! Bug 238554 void parameters
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@@ -707,12 +707,12 @@ class Test
//=
#include "A.h"
+
+
void Test::doNothing(void)
{
}
-
-
//! Bug 282989 Refactor->Implement method option doesn't qualify the name in the method definition with a fully qualified container class name
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/InsertLocation.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/InsertLocation.java
index c584f626dc5..8aa813116be 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/InsertLocation.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/implementmethod/InsertLocation.java
@@ -84,7 +84,7 @@ public class InsertLocation {
if(affectedNode != null) {
targetTranslationUnit = affectedNode.getTranslationUnit();
} else if(hasFile()) {
- targetTranslationUnit = TranslationUnitHelper.loadTranslationUnit(insertFile, false);
+ targetTranslationUnit = TranslationUnitHelper.loadTranslationUnit(insertFile, true);
}
}

Back to the top