【Eclipse】使用指南(17)类继承视图

(翻译说明:http://my.oschina.net/ywlaker/blog/468911

Viewing the type hierarchy

查看类层次结构

In this section, you will learn about using the Type Hierarchy view by viewing classes and members in a variety of different ways.
本小节,你将学会使用类继承视图的过重方式查看类及其成员。

  1. In the Package Explorer view, find junit.framework/TestCase.java. From its context menu, select Open Type Hierarchy. You can also open type hierarchy view:
    • from the menu bar by selecting Navigate > Open Type Hierarchy.
    • from the keyboard by pressingF4after selecting TestCase.java.

    在包管理器视图中,找到junit.framework/TestCase.java,右键选择Open Type Hierarchy菜单。或者使用菜单栏的Navigate > Open Type Hierarchy.菜单,或快捷键F4来达到同样的效果。
    Context menu

  2. The buttons in the view tool bar control which part of the hierarchy is shown.  Click the Show the Type Hierarchy button to see the class hierarchy, including the base classes and subclasses. The small arrow on the left side of the type icon of TestCase indicates that the hierarchy was opened on this type.
    视图工具栏中的按钮控制了继承结构显示的方式。点击Show the Type Hierarchy 按钮查看类继承结构,包括父类和子类,类左侧的箭头表明当前显示的是该类的继承结构。

    Type Hierarchy

  3. Click the Show the Supertype Hierarchy button to see a hierarchy showing the type's parent elements including implemented interfaces. This view shows the results of going up the type hierarchy.
    点击Show the Supertype Hierarchy按钮查看该类的父类以及实现的接口。

    Supertype hierarchy

    In this "reversed hierarchy" view, you can see that TestCase implements the Test interface.
    在反向层次结构中,可以看到TestCase 类实现了Test 接口。

  4. Click the Show the Subtype Hierarchy button in the view toolbar.
    点击工具栏中的Show the Subtype Hierarchy按钮。

    Subtype hierarchy

  5. Click the Lock View and Show Members in Hierarchy button in the toolbar of the member pane, then select the runTest() method in the member pane. The view will now show all the types implementing runTest().
    点击成员面板中的Lock View and Show Members in Hierarchy按钮,然后选择runTest() 方法,视图将会显示所有实现了runTest() 方法的类。

    Subtype hierarchy showing method implementors

  6. In the Type Hierarchy view, click the Show the Supertype Hierarchy button. Then on the member pane, selectcountTestCases()to display the places where this method is declared.
    在类继承视图中,点击Show the Supertype Hierarchy按钮,然后在成员面板上选择countTestCases()方法,此时视图将显示该方法的声明。

    Supertype hierarchy showing method implementors

  7. In the Type Hierarchy view select the Test element and select Focus On 'Test' from its context menu. Test is presented in the Type Hierarchy view.
    在类继承视图中,选择Test 元素,右键选择Focus On 'Test' 菜单,Test 将一直显示在视图中。
  8. Activate the Package Explorer view and select the package junit.framework. Use Open Type Hierarchy from its context menu. A hierarchy is opened containing all classes of the package. For completion of the tree, the hierarchy also shows some classes from other packages. These types are shown by a type icon with a white fill.
    激活包管理器视图,选择junit.framework包,右键选择Open Type Hierarchy菜单,继承结构视图将包含该包中的所有类,同时也会包含其他包的某些类,这些类以白色突出显示。

    Hierarchy on a package

  9. Use Previous Type Hierarchies to go back to a previously opened element. Click on the arrow next to the button to see a list of elements or click on the button to edit the history list.
    使用Previous Type Hierarchies查看之前打开的视图。点击该按钮右边下拉三角形查看或编辑历史元素。

    History menu

If you are working in the editor and only want to do a quick lookup for a hierarchy you can use the Quick Type Hierarchy:
如果你正在编辑文件并且只想看看类的继承关系,可以使用Quick Type Hierarchy

  1. Open junit.framework.TestCase.java file in the Java editor if you do not already have it open.
    打开junit.framework.TestCase.java 文件。
  2. Select the type name in the Java editor
    在编辑器中选中类名。
  3. PressCtrl+Tor invoke Navigate > Quick Type Hierarchy and the in-place type hierarchy view is shown.
    使用Ctrl+T快捷键或选择Navigate > Quick Type Hierarchy菜单打开类继承视图。
  4. PressingCtrl+Twhile the type hierarchy view is shown will toggle between supertype hierarchy and subtype hierarchy.
    多次按下Ctrl+T快捷键会在父类和子类继承视图之间切换。
Quicktype dialogs showing subtype and supertype hierarchy

To see where a virtual method call can resolve to:
通过以下步骤查看虚拟方法在哪被调用:

  1. In the body of runBare() select the invocation of setUp()
    在runBare()方法的方法体中选择setUp()方法。
  2. PressCtrl+Tor invoke Navigate > Quick Type Hierarchy and the in-place type hierarchy view is shown.
    按下Ctrl+T快捷键或者选择Navigate > Quick Type Hierarchy菜单打开快捷类继承视图。
  3. You can see that setUp() is implemented in 3 more classes. Object and Assert are only shown with a white filled images as are only required to complete the hierarchy but do not implement setUp()
    可以看到实现setUp()方法的类有很多。
  4. Select a type to navigate to its implementation of setUp()
    选择一个类按下enter键跳转至setUp() 方法实现的地方
Quicktype dialog showing types that implement setUp()

转载于:https://my.oschina.net/ywlaker/blog/476155

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值