Eclipse 简明教程
Eclipse - Quick Fix
Using Quix Fix
当你向 Eclipse 编辑器输入字符时,它将分析文档内容以找出潜在的错误和警告。Java 编辑器使用 Java 语法来检测代码中的错误。当它发现错误或警告时,它将:
As you type characters into an eclipse editor it analyzes the document content for potential error and warnings. The java editor uses the java syntax to detect errors in the code. When it finds error or warning, it −
-
Highlights errors using red squiggly lines.
-
Highlights warnings using yellow squiggly lines.
-
Displays errors and warnings in the Problem view.
-
Adds a light bulb with a warning sign or error sign to the vertical ruler.
快速修复对话框提供可能的更正列表。可以通过以下方式调用快速修复对话框:
The quick fix dialog provides a list of possible corrections. The quick fix dialog can be invoked by −
-
Placing the mouse pointer on a squiggly line.
-
Clicking on the light bulb.
-
Placing the cursor in the highlighted text and selecting Quick fix from the Edit menu or clicking shortcut Ctrl + 1.
在上述图表中,getId 被突出显示,因为 Person 类没有名为 getId() 的方法。选择在类型“Person”中“创建方法”getId()“将导致 getId() 方法被添加到 Person 类。
In the above diagram, getId is highlighted because the Person class does not have a method called getId(). Selecting Create method 'getId()' in type 'Person' would cause the getId() method to be added to the Person class.
还可通过右键单击“问题”视图中的错误项目,然后选择“快速修复”菜单项来显示快速修复对话框。
The Quick Fix dialog can also be displayed by right clicking on the error item in the Problems view and selecting the Quick Fix menu item.