IntelliJ IDEA4新特性之动态代码分析
扫描二维码
随时随地手机看文章
Intelligent error highlighting(智能突出显示错误)
All common syntax errors, as well as all other errors that would be detected during compilation, are highlighted in the source code so you do not need to compile your code in order to find all your mistakes. Each error is highlighted in the editor and has the corresponding red link on the right gutter area for easy navigation to the erroneous places, which is especially useful when working with large files.
所有常见的语法错误以及其他一些可以被发现的编辑错误,都会在源代码里被突出显示。这意味着,你不用编译程序就可以发现你所有的错误。错误突出会用红色的波浪下划线标示,你可以轻易的找到它,这个功能在大的源文件编辑时尤为突出。
JavaDoc error highlighting(JavaDoc错误突出)
IDEA knows general javadoc rules, such as structure and syntax, and will detect any common inconsistencies found in your javadoc comments, e.g. wrong parameter references, return attributes in the field or void method comments, etc.
Having found an unknown javadoc tag, IDEA will suggests that you add this tag to the known tags list, so that you never get an error or warning indications about it.
IDEA晓得一般的JavaDoc一些关于结构和语法的规则,而且会发现一些在你的JavaDoc中相矛盾的地方,比如,不一致的参数申明,返回局部变量或没有返回值方法的注释等等。当发现一个未知的JavaDoc Tag 时,IDEA会提醒你将这个Tag加入到已知Tag列表中,这样就再也看不到关于这个Tag的错误和警告提示了。
Detecting deprecated symbols(发现不合法的标识符)
If any deprecated code is used in any class or interface, IDEA will recognize it and highlight the corresponding statements directly in the editor.
如果有任何不合法的代码在你得class或interface里,IDEA会找出它,并在编辑器里直接标记出它。
Highlighting unused imports, throws declarations and other unused symbols(突出显示没有被使用的import和 throw声明以及其他没有使用的标识符)
IDEA will point out all redundant import statements, throws declarations and other unused symbols (like variables and methods), and will highlight them in the editor with the corresponding links on the right gutter area for easier navigation. More information on other code analysis features can be found here.
IDEA将会指出多余的import和throw声明,以及其他的多余的方法和变量标识符,并将在编辑器里突出显示他们,并给出相应的建议,你可以轻易找到它们。你也可以从提示意见里获得更过的相关信息。
Import Assistant - helps to automatically insert import statements while typing code, and detects non-imported classes found in pasted blocks of code(Import助手——在编辑代码时帮你自动插入import声明,并自动找出你粘贴代码时没有导出的class)
When you use the name of a class from anywhere in a project library, but the class has not been imported into the current file, a hint with the suggestion to import the class pops up over the text. Pressing Alt + Enter inserts the import statement. Moreover, when you copy a block of text from one file and paste it into another, IDEA automatically detects all the classes that are used inside the copied block but have not been imported to the destination file. It then shows a list of all such classes and allows you to select classes you want to import into the new file.
当你随便使用一个package里的class时,而且这个class没有在当前文件中声明时,就会有一个提示来建议你import一些有这个class声明的package,你只需按下Alt + Enter就会import相应package了。当然,这个功能也会在你粘贴代码时起作用,他会提示出所有需要import的package。IDEA还会给出一个列表让你选择呢?
Intention actions(意图识别)
When you are typing your source code, know that IDEA is always one step ahead of you. For example, if you assign a value to a variable that represents an instance of one of its ancestors, IDEA will immediately interpret your intention as wanting either to cast the ancestor type to the variable type or to define the type of variable the same as the ancestor. A light bulb will appear suggesting that you perform one of these two operations. Also you can start using a method before it has been declared. When this occurs, IDEA’s light bulb popup will appear suggesting you create a new method from its usage. If you accept the suggestion, the new method will be created in the corresponding class. More features related to automatic code generation in IDEA are described here.
当你在输入源代码时,IDEA会知道你下一步将会做什么。例如,当你成声明一个继承于某个父类的变量时,IDEA会认为是是不是需要继承一些父类的声明。有一个小灯泡出现会提示你完成这些操作。当你写一个方法时也是这样。如果你接受了“小灯泡”的建议,你需一点,他就会自动帮你完成。(意译,可能有出入,但易于理解)
Visual indication of overriding/overriden and implementing/implemented methods(醒目的指出override和implement的方法)
Special signs ( and ) on the left gutter area of the editor indicate that the current method overrides or implements the corresponding method of an ancestor class/interface. Moving the mouse to one of these symbols will bring up a tooltip with the base method details. If you click the symbol, the corresponding class/interface will be immediately opened in the editor, with the caret automatically positioned at the base method.
When icons or are shown, it means that the method is overriden or implemented in inheriting classes. Pressing the icon will open a lookup list with these classes, for selecting the desired one to open at the corresponding method.
用符号( 和 ) 在代码的左边标示出当前方法是否是重载或实现了父类或接口的相应方法. 移动鼠标到这些符号上,将会显示出父类是显得的详细细节。如果你点击鼠标, 相应的父类实现就会出现在编辑器里,并自动定位到那个方法上。
当符号 或 出现时,就意味着这个方法需要重载或实现与父类的方法。 点击鼠标就会弹出相应的列表让你在其中选择一个方法。