【Eclipse】使用指南(6)添加新方法

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

添加新方法

  1. 在打开 VectorTest.java 文件的编辑器最后(在声明类的括号之前)输入以下内容:        
    public void testSizeIsThree()        
    当你输入完名称之后,该方法就会出现在 Outline 视图的底部。        

    【Eclipse】使用指南(6)添加新方法_第1张图片          
    另外,

    这些错误提示表明编译有错。将鼠标悬停在错误文本处,会提示:“)”处语法错误,后面需要“{”,这是因为该方法还未声明方法体。这种错误提示会随着你继续输入而不断更新。这个过程是由 Java > Editor 首选页中的 Report problems as you type 选项控制的。          
    【Eclipse】使用指南(6)添加新方法_第2张图片

    • 错误提示(红色长方形块)会出现在编辑器右边垂直标尺上,

    • 错误图标(红叉)会出现在编辑器左侧垂直标尺上,

    • 错误指示符(红色小方块)会出现在编辑器右上角 ,

    • 错误标记会出现在编辑器的文本中。

  2. 点击保存按钮,程序自动编译,错误将出现在包管理器视图、问题视图和垂直标尺(编辑器左边)。在包管理器视图中,错误会一直传播到项目的最上层。      
    【Eclipse】使用指南(6)添加新方法_第3张图片

  3. 输入以下内容完成方法添加:

    {          
     //TODO: Check size            

    闭合的花括号会自动添加。

  4. 保存文件。随着括号的添加,错误提示也消失了。

(完)

(原文)

Adding new methods

  1. Start adding a method by typing the following at the end of the VectorTest.java file (but before the closing brace of the type) in the Java editor:        
    public void testSizeIsThree()        
    As soon as you type the method name in the editor area, the new method appears at the bottom of the Outline view.

    【Eclipse】使用指南(6)添加新方法_第4张图片

    In addition,

    These error annotations indicate that the compilation unit is currently not correct. If you hover over the error in the text, a tool tip appears: Syntax error on token ")", { expected after this token. This is correct since the method doesn't have a body yet. Note that error annotations in the editor are updated as you type. This behavior can be controlled via the Report problems as you type option located on the  Java > Editor preference page.

    【Eclipse】使用指南(6)添加新方法_第5张图片

    • error annotations (red boxes) appear in the overview ruler positioned on the right hand side of the editor,

    • error icons appear in the vertical ruler positioned on the left of the editor,

    • an error indicator appears in the top right corner of the editor,

    • errors are marked in the text.

  2. Click the Save button. The compilation unit is compiled automatically and errors appear in the Package Explorer view, in the Problems view and on the vertical ruler (left hand side of the editor). In the Package Explorer view, the errors are propagated up to the project of the compilation unit containing the error.

    【Eclipse】使用指南(6)添加新方法_第6张图片

  3. Complete the new method by typing the following:

    {          
     //TODO: Check size            

    Note that the closing curly brace has been inserted automatically.

  4. Save the file. Notice that the error indicators disappear since the missing brace has been added.

(END)

你可能感兴趣的:(eclipse,error,indicator)