Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Corbat2015-01-12 16:26:26 +0000
committerThomas Corbat2015-01-16 14:26:19 +0000
commit786e2137ebbb7679d12ade0ccec08c252400f7cc (patch)
tree8e0c4b55224cc76cacbe7b5ca4e66820706fc367
parentef004692928ae79534da675531a4f1c421ddb055 (diff)
downloadorg.eclipse.cdt-786e2137ebbb7679d12ade0ccec08c252400f7cc.tar.gz
org.eclipse.cdt-786e2137ebbb7679d12ade0ccec08c252400f7cc.tar.xz
org.eclipse.cdt-786e2137ebbb7679d12ade0ccec08c252400f7cc.zip
Bug 399215 - Toggle Function breaks the code...
- Test case for reproducing the problem. - The code is lost because a copy of the body, which contains macro references is not rewritten, but its raw signature is taken. The raw signature of a copy is empty in this case. I've solved this issue by using the raw signature of the original node for get raw signature. This is a fundamental change of ASTNode.getRawSignature(). We could also solve this in the StatementWriter to get the original node before accessing the raw signature. Change-Id: I64b408b09444df818d30d99d99de4a1974eacf93 Signed-off-by: Thomas Corbat <tcorbat@hsr.ch> Reviewed-on: https://git.eclipse.org/r/39406 Tested-by: Hudson CI Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java5
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/togglefunction/ToggleRefactoringTest.java20
2 files changed, 23 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java
index 189031670be..c1a5ad2c70c 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java
@@ -161,8 +161,9 @@ public abstract class ASTNode implements IASTNode {
}
protected char[] getRawSignatureChars() {
- final IASTFileLocation floc= getFileLocation();
- final IASTTranslationUnit ast = getTranslationUnit();
+ final IASTNode originalNode = getOriginalNode();
+ final IASTFileLocation floc= originalNode.getFileLocation();
+ final IASTTranslationUnit ast = originalNode.getTranslationUnit();
if (floc != null && ast != null) {
ILocationResolver lr= (ILocationResolver) ast.getAdapter(ILocationResolver.class);
if (lr != null) {
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 0aa964d016f..37598c4125e 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
@@ -2863,4 +2863,24 @@ public class ToggleRefactoringTest extends RefactoringTestBase {
public void testImplToHeaderTopCommentWithoutDeclaration() throws Exception {
assertRefactoringSuccess();
}
+
+ //A.h
+ //#define MACRO 1
+ //int /*$*/freefunction/*$$*/() {
+ // return MACRO;
+ //}
+ //====================
+ //#define MACRO 1
+ //int freefunction();
+
+ //A.cpp
+ //====================
+ //#include "A.h"
+ //
+ //int freefunction() {
+ // return MACRO;
+ //}
+ public void testFunctionWithMacroReference_399215() throws Exception {
+ assertRefactoringSuccess();
+ }
}

Back to the top