Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] How to use ASTRewrite insertBefore() properly
  • From: Ming Cheng <chengm349@xxxxxxxxxxx>
  • Date: Wed, 11 Mar 2020 07:26:30 +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=rtgV+HbWqDdRnL/U+dzvf+W0kwueli37PDy65/5Ddtk=; b=WrFhPYQJIu8SpLnFGFherU1QTQYWC7WiYmV7hPFwLuRPSINMqIG/HEb7p7Q+h1vlyH4md0S5bjGc0U4O4inS22JQ7m1L3R9ujRU7CyLAWzAgWR9JIyzGTyienqH1EQ855epT3R11GtAtygCrv7JgLw92oxlCc7ldTcLWK61vRn0qVxw80M+wnjRO7tJpJbZuFKmmsP3k1Qmt1i/3kC3xslewVQ6f6DmWyTNWkDJRaXIE+BUcpR6o6KMEzzOnCw/gsdzB4p+1G60q6Kdt9VWRscwFVveW3/jT6mWD7+TUvGTFGL2+1g3wmUQSaQqSpaKHF3EN65gwc9cttcRyFZ/svw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HqjhEIdfP9xTAXY4TEsAyQz2/jjBEAgB94VJQYBweXBiv9xpBydgSSPHR5bgQw4HQT7Z2fRj0CC2FTZn9hzSETbZCYG6+1c8vwn2ckgHCphjQvhGl+lkpvqbdXbqVPH/9gh5SRO9kHB08LrKTLMYrbI91buImh9R8OMwKvakdWRFsAEKNy/fqwnfGhXoJEtfqGEOlUBNi3TJT2/vghjThp99L6leMGur3Tx1MeBahWMRavOSA3W1l3L64njoizbZHtXBPg5w1NwoRR5hc19i2g9wQTuNMueuAUmyzehhxbi1Tf4bRgfAT5KnGFBIZlNMQppTCbTmRMy4UqhqynlUDQ==
  • 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: AQHV93U0476vjFwQMkeJAKzlx2vIpQ==
  • Thread-topic: 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