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.
- 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 pressing F4 after selecting TestCase.java.
- 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.
- 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.
In this "reversed hierarchy" view, you can see that TestCase implements
the Test interface.
- Click the Show the Subtype Hierarchy button in the
view toolbar.
- 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().
- In the Type Hierarchy view, click the Show the Supertype Hierarchy
button. Then on the member pane, select
countTestCases()
to display
the places where this method is declared.
- 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.
- 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.
- 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.
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:
- Open
junit.framework.TestCase.java file in the Java editor
if you do not already have it open.
- Select the type name in the Java editor
- Press Ctrl+T or invoke Navigate > Quick Type Hierarchy and the
in-place type hierarchy view is shown.
- Pressing Ctrl+T while the type hierarchy view is shown will toggle between
supertype hierarchy and subtype hierarchy.
To see where a virtual method call can resolve to:
- In the body of runBare() select the invocation of
setUp()
- Press Ctrl+T or invoke Navigate > Quick Type Hierarchy and the
in-place type hierarchy view is shown.
- 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()
- Select a type to navigate to its implementation of setUp()
Java views
Type Hierarchy view
Java Base preference page