Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] How to use ASTRewrite insertBefore() properly
  • From: Ming Cheng <chengm349@xxxxxxxxxxx>
  • Date: Sun, 15 Mar 2020 01:31:11 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2xwFxhtw1LQ+yJ/XsH3azjjbE8T+slJvAnVzBrjSyJ4=; b=Ju0gg7vfvJP/zk7szLyQ75hHjKtmmftUDQaKa+LxKWaPZdO2mW23v5INA3JZyZK+cdDXxososMfZ4QpsJYsWL6+ha3x/0nnlQ2Yn/EkR/n6R5CFwnzA2PJ9b5m66CAhQ0m/hkI8SV1kk0e/h5R8GoL7ew5sxB4SGcUZShEOrEZUbm8JTw4Z/xFX9MHoikkzHT6whyzS4rat4vk0xDX/492TxjFK1uo7cHMhY67hg7H2j+CiKPDD2NljQW2SwLp0TiRpEQyyQAaY446KZEGT6g8/z9tsiwvCBX5B0jUMmaOkx33pfe8pKr4ik3dLlwNeEgMDRZ6qUOPIpLs85ELX3Hw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mg5lCGby54m/VTZAD8akx+hS7v5QckTNO2PDuN+pqRp5+FgIh59HnIMIifu/VS+CKfKBmFejSzZWZ5H0k3JJxmLtYutmUJ8TgwOZzwMPGTydRsGFluN76H+RdkCRNLchvf7tOEcyexx3rh6t6c/NVcEgv6q7B/xRGtmQo49EP+ttt53VL+Ig2y/bRd2/89/gR4B/0ZWJ8H2Tr8oFm54wNZV6OmDu/uqaAoR+6BRwj30GJxLeo71jcsAwvRU55UkMWJeEy9VCwvR216ce+TGoEVwj+OoivrwTCT8F2SkTCc2jFRPnbGYSSZ8WS0PEVVev9FwgxvN9VPvfzT569Sat6A==
  • Delivered-to: cdt-dev@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/cdt-dev>
  • List-help: <mailto:cdt-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/cdt-dev>, <mailto:cdt-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/cdt-dev>, <mailto:cdt-dev-request@eclipse.org?subject=unsubscribe>
  • Thread-index: AQHV93U0476vjFwQMkeJAKzlx2vIpahI48Wv
  • Thread-topic: How to use ASTRewrite insertBefore() properly

Any suggestion is welcome.

thanks.


From: cdt-dev-bounces@xxxxxxxxxxx <cdt-dev-bounces@xxxxxxxxxxx> on behalf of Ming Cheng <chengm349@xxxxxxxxxxx>
Sent: Wednesday, March 11, 2020 7:26 AM
To: cdt-dev@xxxxxxxxxxx <cdt-dev@xxxxxxxxxxx>
Subject: [cdt-dev] How to use ASTRewrite insertBefore() properly
 
Hi,

I have a .cpp content originally  like this:

/*
 * TestCPlImplMsgCopy.cpp
 *
 *  Created on: Mar 11, 2020
 *      Author: mcheng
 */

struct TestCPlImplMsgCopy {
};

and I want to refactor it eventually like this:

/*
 * TestCPlImplMsgCopy.cpp
 *
 *  Created on: Mar 11, 2020
 *      Author: mcheng
 */

#include "TC_UTGlobal.h"
#include "CPlImplMsgCopy.h"
using namespace FT_ADP_LIBRARY;

struct TestCPlImplMsgCopy {
};

I think my code can find insert point before "struct TestCPlImplMsgCopy" correctly. But the actual result like this:

#include "TC_UTGlobal.h"
#include "CPlImplMsgCopy.h"
using namespace FT_ADP_LIBRARY;

/*
 * TestCPlImplMsgCopy.cpp
 *
 *  Created on: Mar 11, 2020
 *      Author: mcheng
 */

struct TestCPlImplMsgCopy {
};

Why I say my code can find the point correctly is bcos if I manually change the original .cpp file to be:

/*
 * TestCPlImplMsgCopy.cpp
 *
 *  Created on: Mar 11, 2020
 *      Author: mcheng
 */

using namespace FT_ADP_LIBRARY;

struct TestCPlImplMsgCopy {
};

Now the same code can happily change for me like this:

/*
 * TestCPlImplMsgCopy.cpp
 *
 *  Created on: Mar 11, 2020
 *      Author: mcheng
 */

using namespace FT_ADP_LIBRARY;

#include "TC_UTGlobal.h"
#include "CPlImplMsgCopy.h"

struct TestCPlImplMsgCopy {
};

It seems to me that insertBefore() does not treat IASTComment like other normal IASTNode?

Thanks.

Back to the top