inserting paired brace for lambda body (following IDEA-CR-8127)

This commit is contained in:
Dmitry Batrak
2016-02-02 15:40:07 +03:00
parent 32080eb785
commit 0a2e21407b
4 changed files with 18 additions and 3 deletions
@@ -142,9 +142,10 @@ public class JavaTypedHandler extends TypedHandlerDelegate {
}, "Insert block statement", null);
return Result.STOP;
}
if (leaf != null && PsiTreeUtil.getParentOfType(PsiTreeUtil.prevVisibleLeaf(leaf), PsiNewExpression.class, true,
PsiCodeBlock.class, PsiMember.class) != null) {
PsiElement prevLeaf = leaf == null ? null : PsiTreeUtil.prevVisibleLeaf(leaf);
if (PsiUtil.isJavaToken(prevLeaf, JavaTokenType.ARROW) ||
PsiTreeUtil.getParentOfType(prevLeaf, PsiNewExpression.class, true, PsiCodeBlock.class, PsiMember.class) != null) {
return Result.CONTINUE;
}
@@ -0,0 +1,5 @@
class A {
void m() {
javax.swing.SwingUtilities.invokeLater(() -> {<caret>});
}
}
@@ -0,0 +1,5 @@
class A {
void m() {
javax.swing.SwingUtilities.invokeLater(() -> <caret>);
}
}
@@ -98,6 +98,10 @@ public class JavaTypingTest extends LightPlatformCodeInsightFixtureTestCase {
doTest('{');
}
public void testInsertPairedBraceForLambdaBody() {
doTest('{');
}
private void doTest(char c) {
myFixture.configureByFile(getTestName(true) + "_before.java");
myFixture.type(c);