本文内容:
Eclipse 4.8版本 代号 photon 光量子 ,感觉更像ide了,虽然这些技巧广为认知,但是作为eclipse来说,也是很重要的、
Code completion allows you to quickly complete statements in your code. For example, start typing a part of a method name and press CTRL+Space to complete it. Multiple choices are presents to you via a popup.
The 'new' Template
Use the 'new' template for quick object creation. (通过键入new 快速选择类)
Extract class refactoring (Alt+Shift+T)
The 'Extract class...' refactoring (from Alt+Shift+T) extracts a group of fields into a separate class and replaces all occurrences to fit the new structure.
Add Module
You don't need to know which module contains a class in Java9. Ctrl-1 can identify the module and add it for you.
The 'ifnull' Template
Use the 'ifnull' template to quickly create an if null check.
Block Selection
Use the Edit -> Block Selection (Alt+Shift+A) while working with Java9.
Use CSV as Parameter Source
You can directly use a CSV file as a parameter source in JUnit5 parameterised tests for a large number of cases.
CSV in Parameterised Tests
In JUnit5 parameterised tests also accept CSV literals (and files) as a source of parameters. Quite handy to feed your tests!
Streams as Test Parameters
You can use methods returning Java streams as a source of parameters in JUnit5 tests. Use @MethodSource as shown below(推荐使用)
Jump to Javadoc on Web
Put your cursor on a class name (or method) and press Shift+F2 to jump to the web version of your library's Javadoc. ()
CTRL+3 - The Master Shortcut
Use the 'Quick Access' box (Ctrl+3) to be more productive. Just type what you want and you'll probably find it.
Private Methods in Interfaces
Private methods in interfaces are allowed in Java9. Here's an example use case with a shared 'worker' method. ]
Invert Equals
Always safer to 'Invert equals' on literal strings in order to avoid a NullPointerException! Ctrl+1 does it for you.
'Show in' for more Details
Whatever element you have selected, code or item, 'Show in...' (Alt+Shift+W) command pops up useful views for various details.
Alt+Up and Alt+Down
Press Alt+Up/Dn to move the selected lines along with the cursor. Indenting is corrected for you. Alt+Shift+Up/Down copies the selection.
Toggle Block Selection
Edit -> Toggle Block Selection tool (or just hit Shift+Alt+A) is demonstrated below.
Inspect Variable Declaration
If you want to see where and how a variable was declared press Shift while hovering and you'll see it in-place.
Show Implementation In-place
Press Shift while hovering a method and it will show implementation in-place.
Select Enclosing Structure
The 'enclosing' selection (Alt+Shift+Up/Dn) shortcut selects the enclosing structure, e.g. var->if->method->class
Java 10 'var'
Use Java 10 and the new 'var' statement in Eclipse with its quick assists (Ctrl+1). Install Java 10 support from Eclipse Marketplace first.