如何在Eclipse中区分同一文件的两个区域 [英] How to diff two regions of the same file in Eclipse

查看:163
本文介绍了如何在Eclipse中区分同一文件的两个区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个TDDer,经常需要重构常见或类似的代码。类似的代码并不总是复制和粘贴的结果。

I'm a TDDer and often have a need to refactor out common or similar code. Similar code is not always a result of copy and paste.

我不是在寻找识别区域或疑似重复的工具,还有一些工具要做那。如果代码完全一样,没有什么大问题,Eclipse几乎可以自动执行。

I'm not looking for tools to identify the regions or suspected duplications, there are a number of tools to do that. And if the code is exactly the same there is no big problem, Eclipse can almost always do that by itself.

我正在寻找可视化截然不同的代码段的工具,但我的人眼可以看到结构上的相似之处,可能会变得更加相似,所以通用代码最终可以被解释出来。

I am looking for tools to visualize differences of sections of code that are radically different, but my human eye can see the structural similarities, and could possibly be made even more similar, so that the common code eventually could be factored out.

如果有可能标记两个区域并获取Eclipse(或其他一些工具),这将非常方便。标记差异。有了这个信息,迭代地移动这些区域直到它们相同,然后激活提取方法重构将变得更简单。

It would be very handy if there was a possibility to mark two regions and get Eclipse (or some other tool) to mark the differences. With this information it would be much simpler to iteratively move the regions closer until they are the same and then activate the Extract Method refactoring.

可以在Emacs中完成,但是我希望能够从Eclipse中获得。任何指针?

It can be done in Emacs of course, but I'd like to have this readily available from Eclipse. Any pointers?

推荐答案

似乎有一些有用的答案在这个问题中,一个表达同样需求的问题。但是,再次,这些答案专注于发现重复,而不是vizualising它。

Seems there was somewhat usable answers in this question, a question articulating the same need. But, again those answers focus on finding duplications, not vizualising it.

两个建议,工作原理是 KDiff3 Diffuse 。两者都允许您打开相同的文件两次或在窗格中粘贴不同的部分。似乎没有办法从Eclipse中使用它们。

Two suggestions that works are KDiff3 and Diffuse. Both allow you to open up the same file twice or paste different sections in the panes. There seems to be no way to use them from Eclipse though.

这篇关于如何在Eclipse中区分同一文件的两个区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆