Cours IUT - CSID 2012 - Arnaud Nauwynck

Eclipse … Google It ... Search : Ctrl + T (T = Types: class, interface, enum...) cf also. Ctrl + R ... English => read Right to Left for class behavior. ○ example: ...
1MB taille 2 téléchargements 282 vues
Cours IUT - CSID 2012

Eclipse Hands On Tip & Tricks, Shortcut, Quick Features [email protected] This document: http://arnaud.nauwynck.free.fr/CoursIUT/CoursIUT-Eclipse-HandsOn.pdf

Outline ●

Eclipse Eclipse Eclipse … JDT



Resources: Doc, Tutorials, Help, …



Navigation, Search Tips



Editor Tips



Refactoring Tips



Debugging Tips

Eclipse … Google It

Wikipedia

Eclipse Plugins Ecosystem ●





not only JDT (Java IDE) Very Rich... Confusing? … Consistent

Eclipse Beginner's Guide ●

http://wiki.eclipse.org/Main%5FPage



http://eclipsetutorial.sourceforge.net/index.html



http://www.eclipse.org/home/newcomers.php



http://eclipsetutorial.sourceforge.net/totalbeginner.h



http://www.vogella.com/articles/Eclipse/article.html





http://agile.csc.ncsu.edu/SEMaterials/tutorials/e clipse/eclipse%5Ftutorial%5F3.3.html ...

http://www.eclipse.org/resources/

Eclipse Help

MUST READ !!!

Examples of Tips &Tricks

Eclipse Built-in Tutorials

Eclipse Navigation Tips

Navigation Shortcuts ●

Search : Ctrl + T (T = Types: class, interface, enum...) cf also Ctrl + R (R = Resources: files, folder..)

Camel Case Names ●

“Camel Case” : Split Words + UpperCase first letter of words



English => read Right to Left for class behavior



example: “ObjectInputStream” ●

= A Stream



More precisely... an Input stream



More.. an Object input



Other examples: NPE = NullPointerException, OOME



MUST known for JDK !!

Ctrl+T (Search) + Camel Case ●

To search for ObjectInputStream



You can use ●

OIS



O*I*S*



Obj*Inp*Stream



ObjectInputStream



java.io.ObjectInputStream

Search Within a File ●





“Ctrl + F” (then next Ctrl+K) => search text exact case-sensitive case-insensitive Regular expression “Ctrl + O” Search member => methods, fields “Ctrl + L” Goto Line

Other Useful Navigate Keys ●

Shift+Ctrl+P = Go to matching bracket



Ctrl+. = Go to next error



Shift+Ctrl+UP/DOWN = next member



Alt+LEFT (back) / Alt+RIGHT (forward)

Ctrl+O ●

Search members... ●

Filter by prefix only in declared class





Filter by regexp Show ALL (inherited) Ctrl+O

Search in Multiple Files ●

Ctrl +H idem Ctrl+F, but in all files



Can search by Text, by Java, by Task...



Can search by Working Set

Customize ...

Working Set

Search By Regular Expression ●

Very powerfull in eclipse …



Standards: (), *, ?, \( \) *, [^], .



Non-standards:





\s = any space



\w = any letter/digit from a word



(s?) = multi-line regexps

Replace ●

( .. ) = capture block \(, \) for parenthesis



=> $1, $2, … captured blocks

Open Call Hierarchy Ctrl + Alt + H

Type Hierarchy Ctrl+T , F4 ●

Ctrl+T On a Type => show all its sub-types In a View: F4

In a Floating Tip View: CTRL+T

Ctrl+T on Method => search impl in sub-class ●

Design Pattern => Use interfaces not classes... Pb: difficult to navigate Solution: Ctrl+T

Method Override / Implement ●

Upward Triangle = see Up in parent class

Full Triangle : override (super = concrete)

Empty Triangle : implements (super = abstract)

Resource Explorer / Filter ●

Use Java View for Java / Resource View for …



See Also Perspective

Filter: Hide NOTHING = show all ...

Extensions to Show: Nothing BUT Resources

Eclipse Editor Tips

Shift + Ctrl + O = Organize Import ● ●

NEVER do manually !! Customize Order, Type Filter: Window>Preferences>Java

Ctrl + 1 … QuickFix ●



Example: ●

Method does not exists => Create it



Method not public => change visibility

Ctrl+1 = Right Click on fault = Click on Pb

Ctrl + SPACE ●

=> AUTOCOMPLETION



Code Template, Example: sysout + Ctrl+SPACE => System.out.println() main + Ctrl+SPACE => public static void main(... for =>

User-Defined Code Template ●

Frequent use : Logger (SLF4J), Separator, constructor, serialId, ...

Auto Import Generate Code Replace var by contextual value

Customize Code Template Window > Preferences > Java > Editor > Templates

Source Menu – Shift+Alt+S ●

Classical needs : getter/setter equals(), hashCode(), toString()...

Getter / Setter Code Generator Shift+Alt+S (Source) > R (getter) > Alt+A (all) > ENTER (OK)

Equals/HashCode Code Generator Shift+Alt+S (Source) > H (hashcode) > ENTER (OK)

More Code Generator... ●

Example : Delegates

Eclipse Refactoring Tips

Rename ●

For a File : F2 (standard shortcut)



For all others : Shift+Alt+R



In place edition... (class, local var, ...)

Refactoring Menu: Shift+Alt+T

Extract Method : Shift+Alt+M Select fragment (including ending “;” Shift+Alt+M (method)

d e t c e t De

lls a 2c

Extract Local Var : Shift+Alt+L Select expr (not stmt: no ending “;”) Shift+Alt+L (local)

Detected 2 uses

Eclipse Debugging Tips

F11 = Start / Debug / Relaunch ●



Note: use the Debug Perspective to Debug

Press F11 on method with @Test => start JUnit



Press F11 on main() => start



Press F11 on existing launch => re-start

F5 < F6 < F7 < F8 ●

Take your four fingers on keys F5 .. F8



F5 = step into



F6 = step over



F7= step out



F8 = resume

Conclusion

Questions ? [email protected] This document: http://arnaud.nauwynck.free.fr/CoursIUT/CoursIUT-Eclipse-HandsOn.pdf