mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
IDEA-131845 Lambdas. Wrong current statement completion.
This commit is contained in:
@@ -83,7 +83,7 @@ public class MissingReturnExpressionFixer implements Fixer {
|
||||
|
||||
if (!(prev instanceof PsiJavaToken)) {
|
||||
int offset = returnStatement.getTextRange().getEndOffset();
|
||||
final PsiMethod method = PsiTreeUtil.getParentOfType(returnStatement, PsiMethod.class);
|
||||
final PsiMethod method = PsiTreeUtil.getParentOfType(returnStatement, PsiMethod.class, true, PsiLambdaExpression.class);
|
||||
if (method != null && method.getReturnType() == PsiType.VOID) {
|
||||
offset = returnStatement.getTextRange().getStartOffset() + "return".length();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class SemicolonFixer implements Fixer {
|
||||
|
||||
private static boolean fixReturn(@NotNull Editor editor, @Nullable PsiElement psiElement) {
|
||||
if (psiElement instanceof PsiReturnStatement) {
|
||||
PsiMethod method = PsiTreeUtil.getParentOfType(psiElement, PsiMethod.class);
|
||||
PsiMethod method = PsiTreeUtil.getParentOfType(psiElement, PsiMethod.class, true, PsiLambdaExpression.class);
|
||||
if (method != null && PsiType.VOID.equals(method.getReturnType())) {
|
||||
PsiReturnStatement stmt = (PsiReturnStatement)psiElement;
|
||||
if (stmt.getReturnValue() != null) {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
public class Class1 {
|
||||
interface Lamb {
|
||||
Object call(Object... args);
|
||||
}
|
||||
|
||||
public void m(Lamb l) {
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Ex().m((arg) -> {
|
||||
return "<caret>"
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
public class Class1 {
|
||||
interface Lamb {
|
||||
Object call(Object... args);
|
||||
}
|
||||
|
||||
public void m(Lamb l) {
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Ex().m((arg) -> {
|
||||
return "";<caret>
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -270,6 +270,8 @@ public class CompleteStatementTest extends EditorActionTestCase {
|
||||
|
||||
public void testArrayInitializerRBracket() throws Exception { doTest(); }
|
||||
|
||||
public void testReturnInLambda() { doTest(); }
|
||||
|
||||
private void doTestBracesNextLineStyle() throws Exception {
|
||||
CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
|
||||
|
||||
Reference in New Issue
Block a user