From f28ee879df3187b0d9c226b2a9ded5df3f31b002 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 8 Aug 2013 18:39:19 +0200 Subject: [PATCH] fix PyDeprecationTest: allow to turn off the new behavior of looking for an injected fragment under the caret in CodeInsightTestFixture --- .../testFramework/fixtures/CodeInsightTestFixture.java | 8 ++++++++ .../fixtures/impl/CodeInsightTestFixtureImpl.java | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java index 38cd8c7b79c5..1ee830e8281e 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightTestFixture.java @@ -493,4 +493,12 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture { * @param consumer the callback in which the actual testing of the structure view is performed. */ void testStructureView(Consumer consumer); + + /** + * By default, if the caret in the text passed to {@link #configureByFile(String)} or {@link #configureByText} has an injected fragment + * at the caret, the test fixture puts the caret into the injected editor. This method allows to turn off this behavior. + * + * @param caresAboutInjection true if the fixture should look for an injection at caret, false otherwise. + */ + void setCaresAboutInjection(boolean caresAboutInjection); } diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index 32abf992a046..7a181b898441 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -153,6 +153,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig @NonNls private static final String XXX = "XXX"; private final FileTreeAccessFilter myJavaFilesFilter = new FileTreeAccessFilter(); private boolean myAllowDirt; + private boolean myCaresAboutInjection = true; @SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") public CodeInsightTestFixtureImpl(IdeaProjectTestFixture projectFixture, TempDirTestFixture tempDirTestFixture) { @@ -1363,7 +1364,9 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig module.getMessageBus().syncPublisher(FacetManager.FACETS_TOPIC).facetConfigurationChanged(facet); } } - setupEditorForInjectedLanguage(); + if (myCaresAboutInjection) { + setupEditorForInjectedLanguage(); + } } }.execute().throwException(); @@ -1928,6 +1931,11 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig } } + @Override + public void setCaresAboutInjection(boolean caresAboutInjection) { + myCaresAboutInjection = caresAboutInjection; + } + @Override public LookupImpl getLookup() { return (LookupImpl)LookupManager.getActiveLookup(myEditor);