diff --git a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/IntroduceVariablePostfixTemplate.java b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/IntroduceVariablePostfixTemplate.java index e1cf9bae64f9..7bf1e8cd03bd 100644 --- a/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/IntroduceVariablePostfixTemplate.java +++ b/java/java-impl/src/com/intellij/codeInsight/template/postfix/templates/IntroduceVariablePostfixTemplate.java @@ -86,6 +86,11 @@ public class IntroduceVariablePostfixTemplate extends PostfixTemplateWithExpress } }; } + + @Override + protected boolean isInplaceAvailableInTestMode() { + return true; + } }; } } \ No newline at end of file diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java index aac8eb5b523f..c6ad929835b0 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/JavaVariableInplaceIntroducer.java @@ -422,6 +422,7 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer finally { myDeleteSelf = true; } + PsiDocumentManager.getInstance(myProject).doPostponedOperationsAndUnblockDocument(myEditor.getDocument()); initOccurrencesMarkers(); return variable; } diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/var/add_after.java b/java/java-tests/testData/codeInsight/template/postfix/templates/var/add_after.java index 05f95bdd2d87..2dc9a7fc158f 100644 --- a/java/java-tests/testData/codeInsight/template/postfix/templates/var/add_after.java +++ b/java/java-tests/testData/codeInsight/template/postfix/templates/var/add_after.java @@ -1,5 +1,5 @@ public class Foo { void m(Object o) { - int foo = 1; + int foo = 1; } } \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/var/anonymous.java b/java/java-tests/testData/codeInsight/template/postfix/templates/var/anonymous.java new file mode 100644 index 000000000000..2a6c4ab541fc --- /dev/null +++ b/java/java-tests/testData/codeInsight/template/postfix/templates/var/anonymous.java @@ -0,0 +1,7 @@ +public class Foo { + void m() { + foo(new Runnable() {public void run()}.var); + } + + void foo(Runnable r) {} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/var/anonymous_after.java b/java/java-tests/testData/codeInsight/template/postfix/templates/var/anonymous_after.java new file mode 100644 index 000000000000..2fd8e29b5395 --- /dev/null +++ b/java/java-tests/testData/codeInsight/template/postfix/templates/var/anonymous_after.java @@ -0,0 +1,9 @@ +public class Foo { + void m() { + Runnable foo = new Runnable() { + public void run() + }; foo(foo); + } + + void foo(Runnable r) {} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/template/postfix/templates/var/simple_after.java b/java/java-tests/testData/codeInsight/template/postfix/templates/var/simple_after.java index 3922fc499e94..0f00e0f7f506 100644 --- a/java/java-tests/testData/codeInsight/template/postfix/templates/var/simple_after.java +++ b/java/java-tests/testData/codeInsight/template/postfix/templates/var/simple_after.java @@ -1,5 +1,5 @@ public class Foo { void m(Object o) { - boolean foo = o instanceof String; + boolean foo = o instanceof String; } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/VarPostfixTemplateTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/VarPostfixTemplateTest.java index 13cabdd086e0..fb7e841eca85 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/VarPostfixTemplateTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/template/postfix/templates/VarPostfixTemplateTest.java @@ -34,4 +34,8 @@ public class VarPostfixTemplateTest extends PostfixTemplateTestCase { public void testAdd() { doTest(); } + + public void testAnonymous() { + doTest(); + } }