add dependency on idea-js for idea and fix AbstractQuickFixTest

This commit is contained in:
Michael Nedzelsky
2015-04-30 16:03:56 +03:00
parent 533e4ac812
commit f56bb4e9f4
3 changed files with 11 additions and 6 deletions
@@ -26,6 +26,7 @@ import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEdito
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.vfs.VfsUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.js.KotlinJavaScriptLibraryManager;
import org.jetbrains.kotlin.utils.PathUtil;
import java.io.File;
@@ -76,6 +77,7 @@ public class ConfigLibraryUtil {
public static void unConfigureKotlinJsRuntimeAndSdk(Module module, Sdk sdk) {
configureSdk(module, sdk);
removeLibrary(module, DEFAULT_KOTLIN_JS_STDLIB_NAME);
removeLibrary(module, KotlinJavaScriptLibraryManager.LIBRARY_NAME);
}
public static void configureSdk(@NotNull final Module module, @NotNull final Sdk sdk) {
+1
View File
@@ -49,5 +49,6 @@
<orderEntry type="module" module-name="idea-completion" scope="TEST" />
<orderEntry type="module" module-name="idea-test-framework" scope="TEST" />
<orderEntry type="module" module-name="js.serializer" />
<orderEntry type="module" module-name="idea-js" scope="TEST" />
</component>
</module>
@@ -38,6 +38,7 @@ import org.apache.commons.lang.SystemUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.idea.KotlinLightQuickFixTestCase;
import org.jetbrains.kotlin.idea.js.KotlinJavaScriptLibraryManager;
import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil;
import org.jetbrains.kotlin.idea.test.DirectiveBasedActionUtils;
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase;
@@ -98,7 +99,7 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase {
private static QuickFixTestCase myWrapper;
private static void doTestFor(final String testName, final QuickFixTestCase quickFixTestCase) {
final String relativePath = notNull(quickFixTestCase.getBasePath(), "") + "/" + KotlinPackage.decapitalize(testName);
String relativePath = notNull(quickFixTestCase.getBasePath(), "") + "/" + KotlinPackage.decapitalize(testName);
final String testFullPath = quickFixTestCase.getTestDataPath().replace(File.separatorChar, '/') + relativePath;
final File testFile = new File(testFullPath);
CommandProcessor.getInstance().executeCommand(quickFixTestCase.getProject(), new Runnable() {
@@ -109,9 +110,9 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase {
String contents = StringUtil.convertLineSeparators(FileUtil.loadFile(testFile, CharsetToolkit.UTF8_CHARSET));
quickFixTestCase.configureFromFileText(testFile.getName(), contents);
quickFixTestCase.bringRealEditorBack();
final Pair<String, Boolean> pair = quickFixTestCase.parseActionHintImpl(quickFixTestCase.getFile(), contents);
final String text = pair.getFirst();
final boolean actionShouldBeAvailable = pair.getSecond().booleanValue();
Pair<String, Boolean> pair = quickFixTestCase.parseActionHintImpl(quickFixTestCase.getFile(), contents);
String text = pair.getFirst();
boolean actionShouldBeAvailable = pair.getSecond().booleanValue();
quickFixTestCase.beforeActionStarted(testName, contents);
@@ -136,7 +137,7 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase {
}
@Override
protected void doAction(final String text, final boolean actionShouldBeAvailable, final String testFullPath, final String testName)
protected void doAction(String text, boolean actionShouldBeAvailable, String testFullPath, String testName)
throws Exception {
doAction(text, actionShouldBeAvailable, testFullPath, testName, myWrapper);
}
@@ -152,9 +153,10 @@ public abstract class AbstractQuickFixTest extends KotlinLightQuickFixTestCase {
}
//endregion
private static void configureRuntimeIfNeeded(@NotNull String beforeFileName) {
private void configureRuntimeIfNeeded(@NotNull String beforeFileName) {
if (beforeFileName.endsWith("JsRuntime.kt")) {
ConfigLibraryUtil.configureKotlinJsRuntimeAndSdk(getModule(), getFullJavaJDK());
KotlinJavaScriptLibraryManager.getInstance(getProject()).syncUpdateProjectLibrary();
}
else if (beforeFileName.endsWith("Runtime.kt")) {
ConfigLibraryUtil.configureKotlinRuntimeAndSdk(getModule(), getFullJavaJDK());