/** * Determine the best match of all possible type matches. The input into this method is all * possible completions that match the type of the argument. The purpose of this method is to * choose among them based on the following simple rules: * * 1) Local Variables > Instance/Class Variables > Inherited Instance/Class Variables * * 2) A longer case insensitive substring match will prevail * * 3) Variables that have not been used already during this completion will prevail over * those that have already been used (this avoids the same String/int/char from being passed * in for multiple arguments) * * 4) A better source position score will prevail (the declaration point of the variable, or * "how close to the point of completion?" * * @param typeMatches the list of type matches * @param paramName the parameter name */ private static void orderMatches(List<Variable> typeMatches, String paramName) { if (typeMatches != null) { Collections.sort(typeMatches, new MatchComparator(paramName)); } }