Introducing KotlinPaths to impose some discipline on compiler/library location
This commit is contained in:
@@ -105,8 +105,8 @@ public class OutdatedKotlinRuntimeNotification extends AbstractProjectComponent
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
File runtimePath = PathUtil.getDefaultRuntimePath();
|
||||
if (runtimePath == null) {
|
||||
File runtimePath = PathUtil.getKotlinPathsForIdeaPlugin().getRuntimePath();
|
||||
if (!runtimePath.exists()) {
|
||||
Messages.showErrorDialog(myProject, "kotlin-runtime.jar is not found. Make sure plugin is properly installed.",
|
||||
"No Runtime Found");
|
||||
return;
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.plugin.compiler;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.compiler.impl.javaCompiler.OutputItemImpl;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.compiler.CompileContext;
|
||||
import com.intellij.openapi.compiler.TranslatingCompiler;
|
||||
import com.intellij.openapi.module.Module;
|
||||
@@ -29,6 +30,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.compiler.runner.CompilerEnvironment;
|
||||
import org.jetbrains.jet.compiler.runner.OutputItemsCollectorImpl;
|
||||
import org.jetbrains.jet.compiler.runner.SimpleOutputItem;
|
||||
import org.jetbrains.jet.utils.KotlinPaths;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@@ -42,7 +45,11 @@ public final class TranslatingCompilerUtils {
|
||||
public static CompilerEnvironment getEnvironmentFor(@NotNull CompileContext compileContext, @NotNull Module module, boolean tests) {
|
||||
VirtualFile mainOutput = compileContext.getModuleOutputDirectory(module);
|
||||
VirtualFile outputDirectoryForTests = compileContext.getModuleOutputDirectoryForTests(module);
|
||||
return CompilerEnvironment.getEnvironmentFor(tests, toNullableIoFile(mainOutput), toNullableIoFile(outputDirectoryForTests));
|
||||
File outputDir = tests ? toNullableIoFile(outputDirectoryForTests) : toNullableIoFile(mainOutput);
|
||||
KotlinPaths kotlinPaths = ApplicationManager.getApplication().isUnitTestMode()
|
||||
? PathUtil.getKotlinPathsForDistDirectory()
|
||||
: PathUtil.getKotlinPathsForIdeaPlugin();
|
||||
return CompilerEnvironment.getEnvironmentFor(kotlinPaths, outputDir);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+4
-4
@@ -118,8 +118,8 @@ public class ConfigureKotlinLibraryNotificationProvider extends EditorNotificati
|
||||
}
|
||||
}
|
||||
|
||||
File runtimePath = PathUtil.getDefaultRuntimePath();
|
||||
if (runtimePath == null) {
|
||||
File runtimePath = PathUtil.getKotlinPathsForIdeaPlugin().getRuntimePath();
|
||||
if (!runtimePath.exists()) {
|
||||
Messages.showErrorDialog(myProject, "kotlin-runtime.jar is not found. Make sure plugin is properly installed.",
|
||||
"No Runtime Found");
|
||||
return null;
|
||||
@@ -215,8 +215,8 @@ public class ConfigureKotlinLibraryNotificationProvider extends EditorNotificati
|
||||
/* package */ static void addJdkAnnotations(Module module) {
|
||||
Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
|
||||
assert sdk != null;
|
||||
File annotationsIoFile = PathUtil.getJdkAnnotationsPath();
|
||||
if (annotationsIoFile != null) {
|
||||
File annotationsIoFile = PathUtil.getKotlinPathsForIdeaPlugin().getJdkAnnotationsPath();
|
||||
if (annotationsIoFile.exists()) {
|
||||
VirtualFile jdkAnnotationsJar = LocalFileSystem.getInstance().findFileByIoFile(annotationsIoFile);
|
||||
if (jdkAnnotationsJar != null) {
|
||||
SdkModificator modificator = sdk.getSdkModificator();
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.intellij.psi.impl.PsiModificationTrackerImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.plugin.project.K2JSModuleComponent;
|
||||
import org.jetbrains.jet.utils.KotlinPaths;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
|
||||
import java.io.File;
|
||||
@@ -109,9 +110,10 @@ public final class JsModuleSetUp {
|
||||
}
|
||||
|
||||
private static boolean copyJsLibFiles(@NotNull File rootDir) {
|
||||
File jsLibJarPath = PathUtil.getDefaultJsLibJarPath();
|
||||
File jsLibJsPath = PathUtil.getDefaultJsLibJsPath();
|
||||
if ((jsLibJarPath == null) || (jsLibJsPath == null)) {
|
||||
KotlinPaths paths = PathUtil.getKotlinPathsForIdeaPlugin();
|
||||
File jsLibJarPath = paths.getJsLibJarPath();
|
||||
File jsLibJsPath = paths.getJsLibJsPath();
|
||||
if (!jsLibJarPath.exists() || !jsLibJsPath.exists()) {
|
||||
notifyFailure("JavaScript library not found. Make sure plugin is installed properly.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user