Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse Java Development User Guide
Previous Page Home Next Page

Viewing the type hierarchy

In this section, you will learn about using the 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 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.

    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.

    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.

    Supertype hierarchy

    In this "reversed hierarchy" view, you can see that TestCase implements the Test interface.
  4. Click the Show the Subtype Hierarchy button in the view toolbar.

    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().

    Subtype hierarchy showing method implementors

  6. In the 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.

    Supertype hierarchy showing method implementors

  7. In the Hierarchy view select the Test element and select Focus On 'Test' from its context menu. Test is presented in the Hierarchy view.
  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.

    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.

    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:

  1. Open junit.framework.TestCase.java file in the Java editor if you do not already have it open.
  2. Select the type name in the Java editor
  3. Press Ctrl+T or invoke Navigate > Quick Type Hierarchy and the in-place type hierarchy view is shown.
  4. Pressing Ctrl+T while the type hierarchy view is shown will toggle between supertype hierarchy and subtype hierarchy.
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()
  2. Press Ctrl+T or invoke Navigate > Quick Type Hierarchy and the in-place type hierarchy view is shown.
  3. You can see that setIup() 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()
  4. Select a type to navigate to its implementation of setUp()
Quicktype dialog showing types that implement setUp() Related concepts

Java views

Related reference

Type Hierarchy view
Java Base preference page


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire