简体   繁体   中英

Refactoring over multiple files Clang

I'm trying to automatically refactor code in multiple files in my project using the Clang Refactoring Tool. I start by adding the particular replacement in my MatchFinder callback like so:

Replacement Rep(*(Result.SourceManager), node->getBeginLoc().getLocWithOffset(5), 0, "replacement");

However, I find that my tool duplicates the replacement (ie it writes "replacementreplacement") even when the applyAllReplacements specifically mentions that **FileToReplaces will be deduplicated with groupReplacementsByFile before application.** .

Is there something I'm doing wrong? The documentation is clear enough on this part but I feel I'm missing something.

Also, the comments mention that to refactor multiple TUs we need to store the changes in "a SourceManager independent form, duplicate changes need to be removed, and all changes must be applied at once at the end of the refactoring so that the code is always parseable".

I'm not sure how to go on about doing this. Any help would be appreciated!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM