如何比较eclipse中的两种方法 [英] how to compare two methods in eclipse

查看:136
本文介绍了如何比较eclipse中的两种方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想比较两种我认为是相同的方法,但是eclipse重构器不会将其内容从一起提取出来。

I want to compare two methods that I think are the same, but the eclipse refactor won't make extract method from their content together.

我可以比较其中两个使用eclipse比较?

Can I compare the two of the them using eclipse compare?


  • 方法是同一个类。

推荐答案

我正在使用Eclipse开普勒,因此根据您的版本,您的里程可能会有所不同。

I'm using Eclipse Kepler, so depending on your version your mileage may vary.

要比较同一类中的两种方法,请执行以下操作:

To compare two methods in the same class, do the following:


  1. 打开课程。

  2. 显示大纲视图(窗口 - >显示视图 - >大纲)

  3. 按住CTRL并点击您要比较的两种方法。

  4. 右键单击其中一个突出显示的方法。

  5. 点击与之对比 - 成员彼此

  1. Open the class.
  2. Show the Outline view (Window->Show View->Outline)
  3. Hold CTRL and click on the two methods you wish to compare.
  4. Right click on one of the highlighted methods.
  5. Click on "Compare With->Each Other By Member"

您将得到一个类似于您正在比较两个文件的差异窗口。

You'll get a diff window similar to if you were comparing two files.

更新

自回答这个问题以来,我已经找到了一个类似的,但更强大的方法来做到这一点。按照上述步骤,除了使用包资源管理器视图而不是大纲视图。这样做的好处是,您可以选择比较两种方法,这两种方法在同一个类中比较不同类中的两种方法。证明两种方法或子类是相同的,可以重构成一个共同的共享资源是一个很好的方式。

Since answering this question, I have found a similar, but more powerful way to do this. Follow the steps above, except use the "Package Explorer" view rather than the outline view. The advantage of this is that you can choose to compare two methods that are in the same class or compare two methods that are in different classes. It's a great way to prove that two methods or subclasses are identical and can be refactored into a common shared resource.

这篇关于如何比较eclipse中的两种方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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