Code completion: minor changes after code review

This commit is contained in:
Valentin Kipyatkov
2014-04-23 19:20:23 +04:00
parent 6808e82b81
commit cd2cf2d987
3 changed files with 4 additions and 4 deletions
@@ -57,7 +57,7 @@ class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: Mo
val callExpression = expressionWithType.getParent() as? JetCallExpression val callExpression = expressionWithType.getParent() as? JetCallExpression
if (callExpression != null) { if (callExpression != null) {
val arguments = callExpression.getFunctionLiteralArguments() val arguments = callExpression.getFunctionLiteralArguments()
if (arguments.size > 0 && arguments[0] == expressionWithType) { if (arguments.firstOrNull() == expressionWithType) {
return calculateForArgument(callExpression, callExpression.getValueArguments().size, true) return calculateForArgument(callExpression, callExpression.getValueArguments().size, true)
} }
} }
@@ -103,7 +103,7 @@ class ExpectedInfos(val bindingContext: BindingContext, val moduleDescriptor: Mo
if (isFunctionLiteralArgument) { if (isFunctionLiteralArgument) {
if (argumentIndex != parameters.size - 1) continue if (argumentIndex != parameters.size - 1) continue
} }
else{ else {
if (parameters.size <= argumentIndex) continue if (parameters.size <= argumentIndex) continue
} }
val parameterDescriptor = parameters[argumentIndex] val parameterDescriptor = parameters[argumentIndex]
@@ -100,7 +100,7 @@ public class JetCompletionResultSet {
LookupElement lookupElement = DescriptorLookupConverter.createLookupElement(resolveSession, bindingContext, descriptor); LookupElement lookupElement = DescriptorLookupConverter.createLookupElement(resolveSession, bindingContext, descriptor);
addElement(new LookupElementDecorator<LookupElement>(lookupElement) { addElement(new LookupElementDecorator<LookupElement>(lookupElement) {
@Override @Override
public void renderElement(LookupElementPresentation presentation) { public void renderElement(@NotNull LookupElementPresentation presentation) {
super.renderElement(presentation); super.renderElement(presentation);
presentation.setItemText(getLookupString() + " " + HandlersPackage.buildLambdaPresentation(parameterType)); presentation.setItemText(getLookupString() + " " + HandlersPackage.buildLambdaPresentation(parameterType));
} }
@@ -75,7 +75,7 @@ private fun needExplicitParameterTypes(context: InsertionContext, placeholderRan
if (functionTypes.size <= 1) return false if (functionTypes.size <= 1) return false
val lambdaParameterCount = KotlinBuiltIns.getInstance().getParameterTypeProjectionsFromFunctionType(lambdaType).size val lambdaParameterCount = KotlinBuiltIns.getInstance().getParameterTypeProjectionsFromFunctionType(lambdaType).size
return functionTypes.filter { KotlinBuiltIns.getInstance().getParameterTypeProjectionsFromFunctionType(it).size == lambdaParameterCount}.size > 1 return functionTypes.filter { KotlinBuiltIns.getInstance().getParameterTypeProjectionsFromFunctionType(it).size == lambdaParameterCount }.size > 1
} }
private fun buildTemplate(lambdaType: JetType, explicitParameterTypes: Boolean, project: Project): Template { private fun buildTemplate(lambdaType: JetType, explicitParameterTypes: Boolean, project: Project): Template {