private String[] guessParameters(char[][] parameterNames, CompletionProposal proposal) throws JavaModelException { int count = parameterNames.length; String[] result = new String[count]; String[] parameterTypes = getParameterTypes(proposal); IJavaElement[][] assignableElements = getAssignableElements(proposal); ParameterGuesser guesser = new ParameterGuesser(compilationUnit); for (int i = count - 1; i >= 0; i--) { String paramName = new String(parameterNames[i]); String argumentProposal = guesser.parameterProposals(parameterTypes[i], paramName, assignableElements[i]); if (argumentProposal != null) { result[i] = argumentProposal; } else { result[i] = paramName; } } return result; }
/** * Returns the matches for the type and name argument, ordered by match quality. * * @param expectedType - the qualified type of the parameter we are trying to match * @param paramName - the name of the parameter (used to find similarly named matches) * @param suggestions the suggestions or <code>null</code> * @throws JavaModelException if it fails */ public String parameterProposals(String expectedType, String paramName, IJavaElement[] suggestions) throws JavaModelException { List<Variable> typeMatches = evaluateVisibleMatches(expectedType, suggestions); orderMatches(typeMatches, paramName); String[] ret = new String[typeMatches.size()]; if (typeMatches.size() > 0) { int i = 0; for (Iterator<Variable> it = typeMatches.iterator(); it.hasNext();) { Variable v = it.next(); if (i == 0) { fAlreadyMatchedNames.add(v.name); } ret[i++] = v.name; } return ret[0]; } return null; }
Variable variable= createVariable(suggestions[i], currentType, expectedType, i); if (variable != null) { if (fAlreadyMatchedNames.contains(variable.name)) { Code primitiveTypeCode= getPrimitiveTypeCode(expectedType); if (primitiveTypeCode == null) {
if (isMethodToSuggest(method)) { if (method.getDeclaringType().equals(enclosingType)) { variableType= Variable.METHOD; boolean isAutoboxMatch= isPrimitiveType(expectedType) != isPrimitiveType(type); return new Variable(type, elementName, variableType, isAutoboxMatch, positionScore);