Fix path util to return dist paths in tests
This commit is contained in:
committed by
Nikolay Krasko
parent
71be3bcec5
commit
d2b948dc2c
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.utils;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -43,7 +44,9 @@ public class PathUtil {
|
||||
|
||||
@NotNull
|
||||
public static KotlinPaths getKotlinPathsForIdeaPlugin() {
|
||||
return new KotlinPathsFromHomeDir(getCompilerPathForIdeaPlugin());
|
||||
return ApplicationManager.getApplication().isUnitTestMode()
|
||||
? getKotlinPathsForDistDirectory()
|
||||
: new KotlinPathsFromHomeDir(getCompilerPathForIdeaPlugin());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -19,7 +19,6 @@ 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;
|
||||
@@ -46,9 +45,7 @@ public final class TranslatingCompilerUtils {
|
||||
VirtualFile mainOutput = compileContext.getModuleOutputDirectory(module);
|
||||
VirtualFile outputDirectoryForTests = compileContext.getModuleOutputDirectoryForTests(module);
|
||||
File outputDir = tests ? toNullableIoFile(outputDirectoryForTests) : toNullableIoFile(mainOutput);
|
||||
KotlinPaths kotlinPaths = ApplicationManager.getApplication().isUnitTestMode()
|
||||
? PathUtil.getKotlinPathsForDistDirectory()
|
||||
: PathUtil.getKotlinPathsForIdeaPlugin();
|
||||
KotlinPaths kotlinPaths = PathUtil.getKotlinPathsForIdeaPlugin();
|
||||
return CompilerEnvironment.getEnvironmentFor(kotlinPaths, outputDir);
|
||||
}
|
||||
|
||||
|
||||
@@ -106,12 +106,12 @@ public class KotlinJavaModuleConfigurator extends KotlinWithLibraryConfigurator
|
||||
@Override
|
||||
@NotNull
|
||||
public File getExistedJarFile() {
|
||||
return assertFileExists(getKotlinPaths().getRuntimePath());
|
||||
return assertFileExists(PathUtil.getKotlinPathsForIdeaPlugin().getRuntimePath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getExistedSourcesJarFile() {
|
||||
return assertFileExists(getKotlinPaths().getRuntimeSourcesPath());
|
||||
return assertFileExists(PathUtil.getKotlinPathsForIdeaPlugin().getRuntimeSourcesPath());
|
||||
}
|
||||
|
||||
public void copySourcesToPathFromLibrary(@NotNull Library library) {
|
||||
|
||||
@@ -81,7 +81,7 @@ public class KotlinJsModuleConfigurator extends KotlinWithLibraryConfigurator {
|
||||
@NotNull
|
||||
@Override
|
||||
public File getExistedJarFile() {
|
||||
return assertFileExists(getKotlinPaths().getJsLibJarPath());
|
||||
return assertFileExists(PathUtil.getKotlinPathsForIdeaPlugin().getJsLibJarPath());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -125,7 +125,7 @@ public class KotlinJsModuleConfigurator extends KotlinWithLibraryConfigurator {
|
||||
|
||||
@NotNull
|
||||
public File getJsFile() {
|
||||
return assertFileExists(getKotlinPaths().getJsLibJsPath());
|
||||
return assertFileExists(PathUtil.getKotlinPathsForIdeaPlugin().getJsLibJsPath());
|
||||
}
|
||||
|
||||
private static boolean needToChooseJsFilePath(@NotNull Project project) {
|
||||
|
||||
@@ -19,8 +19,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.plugin.JetPluginUtil;
|
||||
import org.jetbrains.jet.plugin.framework.ui.FileUIUtils;
|
||||
import org.jetbrains.jet.utils.KotlinPaths;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -417,12 +415,6 @@ public abstract class KotlinWithLibraryConfigurator implements KotlinProjectConf
|
||||
}
|
||||
}
|
||||
|
||||
protected static KotlinPaths getKotlinPaths() {
|
||||
return ApplicationManager.getApplication().isUnitTestMode()
|
||||
? PathUtil.getKotlinPathsForDistDirectory()
|
||||
: PathUtil.getKotlinPathsForIdeaPlugin();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getPathToCopyFileTo(
|
||||
@NotNull Project project,
|
||||
|
||||
Reference in New Issue
Block a user