From 756d1df8eb115c55dbeb67d30c15a2f500bfe72f Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Tue, 7 Jul 2015 12:27:04 +0200 Subject: [PATCH] Test framework now allows custom light project setup --- .../testFramework/LightPlatformTestCase.java | 9 ++++++- .../LightProjectDescriptorEx.java | 24 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 platform/testFramework/src/com/intellij/testFramework/LightProjectDescriptorEx.java diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index d19ec3da8c49..68f5021e7e0f 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -94,7 +94,8 @@ import com.intellij.psi.impl.source.tree.injected.InjectedLanguageManagerImpl; import com.intellij.psi.templateLanguages.TemplateDataLanguageMappings; import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl; import com.intellij.util.Consumer; -import com.intellij.util.GCUtil;import com.intellij.util.IncorrectOperationException; +import com.intellij.util.GCUtil; +import com.intellij.util.IncorrectOperationException; import com.intellij.util.LocalTimeCounter; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.indexing.FileBasedIndex; @@ -261,6 +262,12 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da ourPsiManager = null; ourModule = createMainModule(descriptor.getModuleType()); + if (descriptor instanceof LightProjectDescriptorEx) { + ((LightProjectDescriptorEx)descriptor).setupModule(ourModule); + + if(!((LightProjectDescriptorEx)descriptor).shouldConfigureModule()) return; + } + VirtualFile dummyRoot = VirtualFileManager.getInstance().findFileByUrl("temp:///"); assert dummyRoot != null; dummyRoot.refresh(false, false); diff --git a/platform/testFramework/src/com/intellij/testFramework/LightProjectDescriptorEx.java b/platform/testFramework/src/com/intellij/testFramework/LightProjectDescriptorEx.java new file mode 100644 index 000000000000..26c68c476028 --- /dev/null +++ b/platform/testFramework/src/com/intellij/testFramework/LightProjectDescriptorEx.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.testFramework; + +import com.intellij.openapi.module.Module; + +public interface LightProjectDescriptorEx extends LightProjectDescriptor { + boolean shouldConfigureModule(); + + void setupModule(Module module); +}