« Volver a Eclipse

Eclipse Tips and Tricks

Etiquetas: eclipse

While in any Eclipse editor, press Shift+Ctrl+T. This opens up the Eclipse "find type" window. Type in the name of the class you are looking for (for example, type "ThemeDisplay"). Double click, and Eclipse will open the source file for you. Use this whenever you know of a class name, but don't know where its located. If you do not know the Class Name exactly you might type wildcards or ?.eg:  LocalServiceImpl returns all Liferay's LocalServiceImpl.  If you do know the Class Names by heart type only the Captials. eg: ULSI gives you UserLocalServiceImpl. BTW: Shift+Ctrl+R does the same for all types of resources

Have a source code file open (found it using above Shift+Ctrl+T) but STILL don't know where it is in the source tree? Right click in the source code's editor window, and select "Show in >" from the right-mouse menu. Select "Navigator" or "Package Explorer" to have that view sync with the file you are now editing.

With any class name or method name highlighted in the source code, press the F3 key to "Open declaration." For example, if you see a line of code like User user = this.getRealUser(), and you want to examine the "User" class, place the cursor over the "User" class and press F3 (or right click and select "Open declaration" or hold the Ctrl key (Win) or Apple key (Mac) and click). Or - want to see the implementation of the method? Put your cursor over the .getRealUser part and have Eclipse take you to the declaration of the getRealUser() method (which is usually the implementation, unless the method is from an interface).

Need to track down where a variable, method, or class is used elsewhere in the source code? Place your cursor on the name in any Java file, right click on it, and select "References -> Workspace". All of the Java code in your workspace will be searched, and you will be shown all code that references the object in question.

Have a Java interface, but want to see any and all implementation code behind it? With the interface declaration code opened in the editor, place your cursor on the interface name and press F4 (or right click on it and select "Open in Type Hierachy"). The "Type Hierarchy" view will open. Highlight any "Impl" class, and the methods it implements will be displayed in the bottom pane of the type hierarchy window. Double click on a method name, and Eclipse will open the source code that implements that method.

If you see a property in portal.properties and you want to know more about it (i.e. how does it work, where in the code is it used, etc)? You can combine the above features to get to that information quickly. First, almost every property defined in portal.properties has a corresponding Java string type located in the class com.liferay.portal.kernel.util.PropsKeys. So, first thing you should do is use Ctrl+Shift+T to open the type editor, type in PropsKeys, and open that source file. Search that file for the property you are intersted in. Place your cursor over the Java member that the value is assigned to (for example, the "upgrade.process" string is assigned to the static String member PropsKeys.UPGRADE_PROCESS). Next, right click on the member, and select "References -> Workspace." Eclipse will now find all the code where the property is referenced and list it in the "Search" view. Double click on an entry to see the source code.

0 archivos adjuntos
14609 Accesos
Promedio (0 Votos)
La valoración media es de 0.0 estrellas de 5.
Comentarios