Some Eclipse Features
- Documentation of a method. Holding the cursor over a method name pops up the javadoc for that method. This will include information on the number of type of arguments that a method should be provided.
- Locating the definition of a method or class. Suppose you are viewing a class and see a reference to another. Hold the cursor over the reference and right click. Choose the "Open Declaration" item from the resulting pop-up menu.
- Locating the methods that invoke a method. Suppose you see a reference to, or declaration of a method and want to know where this method is invoked. Select the method name, right click, and select Open Call Hierarchy. A clickable list of the invocations of method will appear at the bottom of the screen.
- Using suggested fixes to detect errors (and how the fixes aren't always correct!) When Eclipse detects a warning, or error, it sometimes suggests ways you might fix the situation. It does this by placing a yellow "light bulb" icon in the left margin of the offending line:
Holding the cursor over the lightbulb will bring up an explanation of the error/warning: (You should also see the message in the "Problems" tab at the bottom of the Eclipse window.)
Clicking on the lightbulb brings up a pop-up menu suggesting possible fixes to the warning/error. If you select one of these, Eclipse will effect the repair:
N.B.: You should note that these are only suggestions by Eclipse, and Eclipse is certainly not omniscient. The necessary repair to fix your code may not be one suggested by Eclipse. The error may actually be on an earlier line of your program. In general, you should only tell Eclipse to effect a repair if you have determined for yourself that that is what is actually wrong. The idea is for Eclipse to serve as your aide-de-camp, not your general!
If you would like to see this capaiblity in action, try adding a Scanner object to file not containing the appropriate import.
- Error Symbols. Sometimes repairing a syntax error does not immediately remove the "X" symbol from the left margin of the offending line. (Sometimes the "X" icon will grey-out.) Try saving the file--it sometimes alerts Eclipse to the change.
- Creating Header Comments. For creating method header comments, the Generate Element Comment menu item from the Source menu. (Brief discussion of Javadoc.)
- Refactoring. If you want to change the name of a class or method, you also need to change it wherever the method or class is referenced. Use the Refactoring option in the Source menu. This will search your entire project, changing the identifier anywhere it appears.
There is another good tutorial at http://www.cs.laurentian.ca/badams/c1047/eclipse-tutorials/intro-tutorial.html. Discusses how to set up Java API doc in the IDE. (Though my Java lists "classes.jar", not "rt.jar".)
©Matthew Evett, 2008