mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 10:20:15 +07:00
method refs: do not insert ; in calls/exprs (IDEA-92713)
This commit is contained in:
@@ -792,7 +792,9 @@ public class JavaCompletionUtil {
|
||||
|
||||
boolean insertAdditionalSemicolon = true;
|
||||
final PsiReferenceExpression referenceExpression = PsiTreeUtil.getTopmostParentOfType(context.getFile().findElementAt(context.getStartOffset()), PsiReferenceExpression.class);
|
||||
if (referenceExpression != null) {
|
||||
if (referenceExpression instanceof PsiMethodReferenceExpression && LambdaUtil.insertSemicolon(referenceExpression.getParent())) {
|
||||
insertAdditionalSemicolon = false;
|
||||
} else if (referenceExpression != null) {
|
||||
PsiElement parent = referenceExpression.getParent();
|
||||
if (parent instanceof PsiMethodCallExpression) {
|
||||
parent = parent.getParent();
|
||||
|
||||
@@ -566,13 +566,16 @@ public class LambdaUtil {
|
||||
if (lambdaExpression.getBody() instanceof PsiCodeBlock) {
|
||||
return true;
|
||||
}
|
||||
final PsiElement parent = lambdaExpression.getParent();
|
||||
if (parent instanceof PsiExpressionList || parent instanceof PsiExpression) {
|
||||
if (insertSemicolon(lambdaExpression.getParent())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean insertSemicolon(PsiElement parent) {
|
||||
return parent instanceof PsiExpressionList || parent instanceof PsiExpression;
|
||||
}
|
||||
|
||||
public static boolean isValidQualifier(PsiMethodReferenceExpression expression) {
|
||||
final PsiElement referenceNameElement = expression.getReferenceNameElement();
|
||||
if (referenceNameElement instanceof PsiKeyword) {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import java.util.*;
|
||||
|
||||
class Test {
|
||||
void aaa(Test p) { return 1; }
|
||||
void test() {
|
||||
c(Test::<caret>);
|
||||
}
|
||||
void c(Comparator<Test> c){}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import java.util.*;
|
||||
|
||||
class Test {
|
||||
void aaa(Test p) { return 1; }
|
||||
void test() {
|
||||
c(Test::c);
|
||||
}
|
||||
void c(Comparator<Test> c){}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ public class Normal17CompletionTest extends LightFixtureCompletionTestCase {
|
||||
public void testOnlyResourcesInResourceList4() { doTest() }
|
||||
|
||||
public void testMethodReferenceNoStatic() { doTest() }
|
||||
public void testMethodReferenceCallContext() { doTest() }
|
||||
|
||||
public void testResourceParentInResourceList() {
|
||||
configureByFile(getTestName(false) + ".java")
|
||||
|
||||
Reference in New Issue
Block a user