IDEA-123355 Postfix template expansions .null/.notnull after 'else' fail to provide a valid Java output

allow JavaWithIfExpressionSurrounder just after else keywords
This commit is contained in:
Alexander Zolotov
2014-04-07 19:05:34 +04:00
parent ec1d4927bd
commit 2f3d180fbd
9 changed files with 111 additions and 14 deletions
@@ -0,0 +1,11 @@
class Test {
boolean foo() {
return true;
}
void bar() {
if (true) {
}
else <selection>foo()</selection>
}
}
@@ -0,0 +1,11 @@
class Test {
boolean foo() {
return true;
}
void bar() {
if (true) {
}
else <selection>foo()</selection>
}
}
@@ -0,0 +1,14 @@
class Test {
boolean foo() {
return true;
}
void bar() {
if (true) {
}
else if (foo()) {
<caret>
} else {
}
}
}
@@ -0,0 +1,13 @@
class Test {
boolean foo() {
return true;
}
void bar() {
if (true) {
}
else if (foo()) {
<caret>
}
}
}
@@ -0,0 +1,8 @@
public class Foo {
void m(Object o) {
if (true) {
}
else o.notnull<caret>
}
}
@@ -0,0 +1,10 @@
public class Foo {
void m(Object o) {
if (true) {
}
else if (o != null) {
<caret>
}
}
}
@@ -145,6 +145,16 @@ public class JavaSurroundWithTest extends LightCodeInsightTestCase {
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
doTest(getTestName(false), new JavaWithNotSurrounder());
}
public void testSurroundExpressionWithElseIf() {
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
doTest(getTestName(false), new JavaWithIfExpressionSurrounder());
}
public void testSurroundExpressionWithElseIfElse() {
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
doTest(getTestName(false), new JavaWithIfElseExpressionSurrounder());
}
private void doTest(@NotNull String fileName, final Surrounder surrounder) {
configureByFile(BASE_PATH + fileName + ".java");
@@ -17,9 +17,6 @@ package com.intellij.codeInsight.template.postfix.templates;
import org.jetbrains.annotations.NotNull;
/**
* @author ignatov
*/
public class NotNullPostfixTemplateTest extends PostfixTemplateTestCase {
@NotNull
@Override
@@ -29,4 +26,5 @@ public class NotNullPostfixTemplateTest extends PostfixTemplateTestCase {
public void testPrimitive() { doTest(); }
public void testNn() { doTest(); }
public void testSecondStatement() { doTest(); }
public void testElseStatement() { doTest(); }
}