mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java completion sorting: disprefer return in void lambdas (IDEA-CR-9303, IDEA-152289)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class Util {
|
||||
int foo(int reaction, boolean rezet) {
|
||||
Runnable r = () -> {
|
||||
re<caret>
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
+3
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user