Hidden features of Eclipse [closed]

2019-01-01 14:09发布

Alright it can be a lame question, but everybody uses these things differently. What's some of the best time savers out there for this IDE.

Tom

标签: java eclipse ide
30条回答
姐姐魅力值爆表
2楼-- · 2019-01-01 14:26

Crtl+1 is my favorite. The quick fixes for the red-squiggles.

It is also located in the Edit Menu -> Quick Fix.

查看更多
牵手、夕阳
3楼-- · 2019-01-01 14:28

CTRL+SPACE, for anything, anywhere.

Generate getters and setters.

Create Constructors using Fields

Extract Method...

Refactor->Rename

CTRL+O for the quick outline. CTRL+O+CTRL+O for the inherited outline.

F4 to display a type hierarchy

Open Call Hierarchy to display where a method is called from.

CTRL+SHIFT+T to open a Java Type

CTRL+SHIFT+R to open any resource.

ALT + left or right to go forward or backwards through edit places in your documents (easy navigation)

Override/Implement methods if you know you're going to do a lot of methods (otherwise, CTRL+SPACE is better for one at a time selection.

Refactor->Extract Interface

Refactor->Pull up

Refactor->Push down

CTRL+SHIFT+O for organize imports (when typing the general class name such as Map, pressing CTRL+SPACE and then selecting the appropriate class will import it directly for you).

CTRL+SHIFT+F for formatting (although Eclipse's built in formatter can be a little braindead for long lines of code)

EDIT: Oh yeah, some debugging:

F5: Step into (show me the details!)

F6: Step over (I believe you, on to the next part...)

F7: Step out (I thought I cared about this method, but it turns out I don't, get me out of here!)

F8: Resume (go until the next breakpoint is reached)

CTRL+SHIFT+I: inspect an expression. CTRL+SHIFT+I+CTRL+SHIFT+I: create a watch expression on the inspected expression.

Conditional breakpoints: Right click a breakpoint and you may set a condition that occurs which triggers its breaking the execution of the program (context assist, with Ctrl+Space, is available here!)

F11 - Debug last launched (application)

CTRL+F11 - Run last launched (application)

查看更多
无色无味的生活
4楼-- · 2019-01-01 14:30

F3 has been my favorite, opens the definition for the selected item.

Ctrl+Shift+R has an interesting feature, you can use just the uppercase camel letters from a class when searching (such as typing CWAR will show a result for ClassWithAReallyLongName).

Alt+Shift+W > Package Explorer makes life easier when browsing large projects.

查看更多
无色无味的生活
5楼-- · 2019-01-01 14:31

Ctrl+Alt+H on a method to get the call hierarchy for it. Fast way to see where it is called from.

查看更多
皆成旧梦
6楼-- · 2019-01-01 14:31

Ctrl-J starts an incremental find.

Hit Ctrl-J, then start typing. Use up/down to find previous/next instances of what you typed.

Ctrl-Shift-J searches backwards.

查看更多
浮光初槿花落
7楼-- · 2019-01-01 14:31

Clicking on the return type in a method's declaration highlights all exit points of the method.

for instance:

1: public void foo()
2: {
3:   somecode();
4:    if ( blah ) return;
5:
6:    bar();
7: }

clicking on void will highlight the return on line 4 and the close } on line 7.

Update: It even works for try{} catch blocks. If you put cursor on exception in the catch block and eclipse will highlight the probable methods which may throw that exception.

查看更多
登录 后发表回答