Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
README | 2002-07-02 | 3.0 kB | |
param-guess.jar | 2002-07-02 | 52.6 kB | |
Totals: 2 Items | 55.6 kB | 0 |
You can see the discussion of this fetaure in the following bug report: http://bugs.eclipse.org/bugs/show_bug.cgi?id=9100 Installation: Since this is not easily done as a plugin, and the 2.0 development is pretty well done, I have decided to develop this as a patch: 1. Put "param-guess.jar" in the %ECLIPSE_HOME%\plugins\org.eclipse.jdt.ui_2.0.0 directory 2. Modify the top of the jdt-ui plugin.xml file, so that the <runtime> tag looks like this: <runtime> <library name="param-guess.jar"/> <library name="jdt.jar"> <export name="*"/> </library> </runtime> 3. Start/Restart Eclipse. Some Details: 1. Requires "fill in argument names" to be enabled 2. Guesses the appropriate field/variable to use as the parameter based on a number of factors, these are the preference rules in approximate order: * Variable type must be assignable to the parameter type * Local variables will be chosen before instance variables * Instance variables will be chosen before inherited instance variables * Variables that have a common substring with the parameter get preference (e.g. if the parameter is "String theString" a variable "String myString" will have a greatercommon substring than "String otherVariable") * Variables that appear closer to the point of code completion get preference * Variables that have not been matched to a parameter yet are given preference over those already used in this method completion. The code at the botton of this message shows some examples of completions. Examples of Completions: List nonInheritedInstanceList = null; public void listParamMethod(List theList) {} public void mixedMethod(int myInt, List myList, char myChar) {} public void testGuessing() { char localChar = ' '; int fartherInt = 0; int closer = 0; char myCloserName = ' '; char close = ' '; List unrelatedName = null; Vector unrelatedNameVector = null; // "unrelatedNameVector" is the closest implementor of List // (it is one line closer than "unrelatedName" // the instance variable is ignored in favor of the local variables. listParamMethod(unrelatedNameVector); // fartherInt is not the closest local variable, but // it has a greater common substring ("Int"). Same for "localChar" mixedMethod(fartherInt, unrelatedNameVector, localChar); } public void fruits(int apple, int orange, int strawberry) {} public void colors(int red, int green, int blue) { /* This illustrates how un-used variables get preference over those already used. Guesses are also computed in reverse order, so "delegation" completions (where you pass the current methods' parameters to another, similar method) work better. Without these two rules, the completion would be fruits(blue, blue, blue) because it would just pick the closest integer (no substring matches apply). */ fruits(red, green, blue); }