mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 10:46:02 +02:00
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>
This commit is contained in:
parent
ef00469292
commit
786e2137eb
2 changed files with 23 additions and 2 deletions
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue