我有一些方法在我的代码库中不推荐使用,我知道应该如何替换它们,有没有办法自动执行此操作?我使用Visual Studio 2015年更新3,但我愿意用其他文本编辑器...更改对已弃用方法的引用C++
的代码看起来是这样的:
// Deprecated method
myFunction(char* firstParam, char* secondParam = NULL);
// New method, same name, different params
myFunction(char* firstParam, bool flag, char* secondParam = NULL);
我想要的东西,可以取代的所有引用第一个功能与第二个功能相关。 即:
myFunction("hello", "world");
// Replace with
myFunction("hello", true, "world");
和
myFunction("hello");
// Replace with
myFunction("hello", true);
和
myFunction("hello", isTrue); // isTrue is a bool here
// Do not replace with anything
和
myFunction("hello", world); //world is a char* here
// Replace with
myFunction("hello", true, world);
我打开使用Visual Studio或甚至其他文本编辑器解决方案。我没有手动做这件事的原因是因为代码库太大。
使用编辑器的搜索和替换功能?不知道我是否理解这个问题 – user463035818
我不确定我是否理解,因为这些是具有不同签名的截然不同的方法。您不仅需要修改签名,而且在您调用原始方法的每个地方,您都需要更新代码以支持新签名。 –
像使用正则表达式?因为使用正则表达式很难捕获变量类型。 (或者,也许我只是不知道如何) –