Eclipse Tutorial IX

Continue today to learn about Eclipse Quick Fixes, Eclipse Browse Menu, Eclipse Find, and Eclipse Hover Tips! Old rules, no more nonsense, let's start.

Eclipse quick fixes

use quick fix

When you enter letters in the Eclipse editor, the editor will perform error analysis on the content you entered.

The Java syntax is used in the Java editor to detect errors in the code. When it finds errors or warnings:

  • Highlight errors with red squiggly lines
  • Highlight warnings with a yellow squiggly line
  • Display errors and warnings in the Problem view
  • Small yellow light bulb with warning and error signs on vertical scale

A quick fix dialog provides a solution. The quickfix dialog can be invoked by:

  • place the mouse pointer over the wavy line
  • click on the light bulb
  • Place the mouse pointer on the highlighted text and select the Quick fix item on the Edit menu or press the shortcut key Ctrl + 1

In the image above, getId is highlighted because there is not a method called getId() in the Person class. In the pop-up fix, select "Create method 'getId()' in type 'Person'" so that the getId() method can be added to the Person class.

You can also right-click the error item in the Problems view, and then select the Quick Fix menu item to display the Quick Fix dialog box, as shown in the following figure:

Eclipse floating prompt

Use hover

The java editor contains different types of hover tips, which provide additional information about the element the mouse pointer is pointing at. Hover hints related to all java editors can be configured through the preference (preferences) Hovers page (type "hover" in the search box).

Move the mouse pointer over a class in the java editor, and the java document information related to the class will be displayed.

Move the mouse pointer over a method in the java editor, and the java document information related to the method will be displayed.

Eclipse lookup

Find in workspace

The Eclipse Find dialog box allows users to search for files using word or letter patterns on a specified workspace. Or you can select the specified folder in the specified project or in the package explorer view to search.

The find box can be invoked in the following ways:

  • On the Search menu choose Search or File or Java
  • Press the shortcut key: Ctrl + H

File (File) search allows users to search for all file types, while Java search only searches for Java files.

For example, if we look for the use of the Person type, we can look up the page through Java:

  • Type Person in the search box
  • Select Type in the radio button of search for
  • Select References in the limit to (limited to) radio button
  • Click Search

The results displayed in the Search view are as follows:

Eclipse Navigate menu

Browse Eclipse workspaces

The Navigate menu provides multiple menus that allow you to quickly navigate to a specific resource.

The three menu items Open Type, Open Type in Hierarchy and Open Resource in the figure above are very useful.

Open Type

The Open Type menu item opens a dialog where Java type files can be found.

You can enter the class name in the input box to search. The '*' sign indicates 0 or more letters, and the '?' sign indicates that a single letter can be used to specify the pattern. All matching patterns will be displayed in the dialog.

Just select the file you are looking for from the list.

Eclipse will open an editor showing the selected type. If the source code cannot be displayed for the selected type, the class file editor will be used to display the bytecode for the selected type.

You can click the Attach Source button to view the source code corresponding to the class file.

The source code is in the compressed src.zip file in your Java home directory.

Open Type in Hierarchy

The Open Type in Hierarchy menu allows the user to view the inheritance hierarchy of classes in the Type Hierarchy view.

Select the specified class in the Type Hierarchy view to see the class definition information, including the corresponding attributes and methods:

Open Resource

The open resource menu can be used to find files in the workspace.

The '*' sign indicates 0 or more letters, and the '?' sign indicates that a single letter can be used to specify the pattern. All matching patterns will be displayed in the dialog.

Select the file you want to open and click the OK button.

 

 

 

Guess you like

Origin blog.csdn.net/slave_of_life/article/details/130958579