From b88d3c2d5ab3fce7562c94b12a6c1d3d051bb98b Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Fri, 8 Jul 2016 10:50:23 +0200 Subject: [PATCH] end template in tests as normal; if template was canceled - don't perform onSuccess method setup (IDEA-157973) --- .../daemon/impl/quickfix/CreateMethodFromUsageFix.java | 1 + .../daemon/quickFix/CreateMethodFromUsageTest.groovy | 4 ++-- .../codeInsight/template/impl/TemplateManagerImpl.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromUsageFix.java index 5c505da612f51..ce8427166dc25 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromUsageFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromUsageFix.java @@ -259,6 +259,7 @@ public static void doCreate(PsiClass targetClass, startTemplate(newEditor, template, project, new TemplateEditingAdapter() { @Override public void templateFinished(Template template, boolean brokenOff) { + if (brokenOff) return; WriteCommandAction.runWriteCommandAction(project, () -> { PsiDocumentManager.getInstance(project).commitDocument(newEditor.getDocument()); final int offset = newEditor.getCaretModel().getOffset(); diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.groovy index 75ee4fb449bfc..c285cd4fd716d 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/CreateMethodFromUsageTest.groovy @@ -127,7 +127,7 @@ class Usage { PsiDocumentManager.getInstance(getFile().project).commitDocument(document) } - state.gotoEnd() + state.gotoEnd(false) } public void "test prefer outer class when static is not applicable for inner"() { @@ -153,7 +153,7 @@ class A { PsiDocumentManager.getInstance(getFile().project).commitDocument(document) } - state.gotoEnd() + state.gotoEnd(false) checkResultByText """ class A { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateManagerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateManagerImpl.java index 86d82a44d6512..6659c8fb0d1b7 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateManagerImpl.java @@ -191,7 +191,7 @@ private void startTemplate(final Editor editor, } if (shouldSkipInTests()) { - if (!templateState.isFinished()) templateState.gotoEnd(); + if (!templateState.isFinished()) templateState.gotoEnd(false); } }