2018-10-2 Tip of the Day(eclipse)

茶木君發表於2018-10-02

1.Code completion

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.

 2.The 'new' Template

Use the 'new' template for quick object creation.

3.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.

          

 

4.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.

5.The 'ifnull' Template 

Use the 'ifnull' template to quickly create an if null check.

6. Block Selection

Use the Edit -> Block Selection (Alt+Shift+A) while working with Java9.

 7.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.

8.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!

9. Streams as Test Parameters

You can use methods returning Java streams as a source of parameters in JUnit5 tests. Use @MethodSource as shown below.

10.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.

11.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.

12.Private Methods in Interfaces 

Private methods in interfaces are allowed in Java9. Here's an example use case with a shared 'worker' method.

13.Invert Equals

Always safer to 'Invert equals' on literal strings in order to avoid a NullPointerException! 'Ctrl+1' does it for you.

 

14.'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.

15.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.

16.Toggle Block Selection

Edit -> Toggle Block Selection tool (or just hit 'Shift+Alt+A') is demonstrated below.

17.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.

18.Show Implementation In-place

Press 'Shift' while hovering a method and it will show implementation in-place.

19.Select Enclosing Structure

The 'enclosing' selection (Alt+Shift+Up/Dn) shortcut selects the enclosing structure, e.g. var->if->method->class

      

      

      

       

20.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.

21.Opening the Tips Dialog

The tips are shown automatically at startup if there are tips available. In case the tips are not loaded at startup you can activate the tips manually from the Help menu.

22.Tips Available?

In case you do not want to start tips at startup, you can still see if there are tips available. Check the bottom right corner to see a little lightbulb. This lightbulb only appears if there is something to read.

23.Action Tips

Some tips enable you to start one or more actions. If this is the case then an additional button will be displayed like in this tip. Go ahead and press the button, or choose another action from the drop down menu next to the button.

相關文章