为什么 Visual C++ 缺乏重构功能?
在 Visual Studio 2008 中使用 C++ 编程时,为什么在使用 C# 时没有在重构菜单中看到的类似功能?
When programming in C++ in Visual Studio 2008, why is there no functionality like that seen in the refactor menu when using C#?
我经常使用重命名,但当它不存在时,您真的很想念它.我确定您可以获得提供此功能的插件,但为什么在使用 C++ 时不将其集成到 IDE 中?这是因为必须解析 C++ 的方式存在一些问题吗?
I use Rename constantly and you really miss it when it's not there. I'm sure you can get plugins that offer this, but why isn't it integrated in to the IDE when using C++? Is this due to some gotcha in the way that C++ must be parsed?
推荐答案
C++ 的语法和语义使得正确实现重构功能极其困难.实现一些相对简单的方法来覆盖 90% 的情况是可能的,但在剩下的 10% 的情况下,这个简单的解决方案会通过更改您不想更改的内容来严重破坏您的代码.
The syntax and semantics of C++ make it incredibly difficult to correctly implement refactoring functionality. It's possible to implement something relatively simple to cover 90% of the cases, but in the remaining 10% of cases that simple solution will horribly break your code by changing things you never wanted to change.
阅读http://yosefk.com/c++fqa/defective.html#defect-8 简要讨论 C++ 中的任何重构代码必须处理的困难.
Read http://yosefk.com/c++fqa/defective.html#defect-8 for a brief discussion of the difficulties that any refactoring code in C++ has to deal with.
微软显然已决定为 C++ 开发这一特殊功能,让第三方开发人员尽其所能.
Microsoft has evidently decided to punt on this particular feature for C++, leaving it up to third-party developers to do what they can.
相关文章