java completion sorting: disprefer return in void lambdas (IDEA-CR-9303, IDEA-152289)

This commit is contained in:
peter
2016-03-16 11:32:51 +01:00
parent af67ab21c9
commit 80c6e1c9f4
3 changed files with 15 additions and 0 deletions
@@ -271,6 +271,10 @@ public class PreferByKindWeigher extends LookupElementWeigher {
if (parent instanceof PsiMethod) {
return ((PsiMethod)parent).isConstructor() || PsiType.VOID.equals(((PsiMethod)parent).getReturnType());
}
if (parent instanceof PsiLambdaExpression) {
PsiMethod method = LambdaUtil.getFunctionalInterfaceMethod(((PsiLambdaExpression)parent).getFunctionalInterfaceType());
return method != null && PsiType.VOID.equals(method.getReturnType());
}
}
return false;
}
@@ -0,0 +1,8 @@
class Util {
int foo(int reaction, boolean rezet) {
Runnable r = () -> {
re<caret>
};
}
}
@@ -442,6 +442,9 @@ interface TxANotAnno {}
public void testDispreferReturnInVoidMethodTopLevel() {
checkPreferredItems 0, 'reaction', 'rezet', 'return'
}
public void testDispreferReturnInVoidLambda() {
checkPreferredItems 0, 'reaction', 'rezet', 'return'
}
public void testDoNotPreferGetClass() {
checkPreferredItems 0, 'get', 'getClass'