Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarc-Andre Laperle2018-09-22 00:08:58 -0400
committerDoug Schaefer2018-10-06 11:36:37 -0400
commitd537c6030cabb87999a2a6617dcad948a70a5f7c (patch)
treedcbf3e7d145ad032dc89676035adf6d58d14de20 /core
parentdac83cdde6927711cc6b985f5e62e02193a7c4d5 (diff)
downloadorg.eclipse.cdt-d537c6030cabb87999a2a6617dcad948a70a5f7c.tar.gz
org.eclipse.cdt-d537c6030cabb87999a2a6617dcad948a70a5f7c.tar.xz
org.eclipse.cdt-d537c6030cabb87999a2a6617dcad948a70a5f7c.zip
Bug 486036 - Toggle Function Definition does not work when comment is involved
Change-Id: I77a2c2fe0607ce098da4a4e7679fc3999ea7ebbf Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromImplementationToHeaderOrClassStrategy.java4
2 files changed, 22 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java
index d41289a42e..77f4bee5d6 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java
@@ -3648,4 +3648,22 @@ public class ToggleRefactoringTest extends RefactoringTestBase {
public void testToggleWithLambdaExpression_518271() throws Exception {
assertRefactoringSuccess();
}
+
+ //Test.cpp
+ //class MyClass {
+ // void MyMethod();
+ //};
+ //
+ //void MyClass::/*$*/MyMethod/*$$*/() {
+ //// A comment
+ //}
+ //====================
+ //class MyClass {
+ // void MyMethod() {
+ // // A comment
+ // }
+ //};
+ public void testToggleWithCommentsInSameFile_486036() throws Exception {
+ assertRefactoringSuccess();
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromImplementationToHeaderOrClassStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromImplementationToHeaderOrClassStrategy.java
index 48ea14176d..a78096648d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromImplementationToHeaderOrClassStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromImplementationToHeaderOrClassStrategy.java
@@ -146,6 +146,10 @@ public class ToggleFromImplementationToHeaderOrClassStrategy implements IToggleR
}
private void copyAllCommentsToNewLocation(IASTNode node, final ASTRewrite oldRw, final ASTRewrite newRw) {
+ //Bug 486036: In case oldRw == newRw (same file), there's no need to copy anything, the comments will follow along.
+ if (oldRw == newRw) {
+ return;
+ }
node.accept(new CPPASTAllVisitor() {
@Override
public int visitAll(IASTNode node){

Back to the top