diagnostics in CompileEnvironment
This commit is contained in:
@@ -9,6 +9,7 @@ import com.intellij.psi.search.GlobalSearchScope;
|
|||||||
import com.intellij.util.Processor;
|
import com.intellij.util.Processor;
|
||||||
import jet.modules.AllModules;
|
import jet.modules.AllModules;
|
||||||
import jet.modules.Module;
|
import jet.modules.Module;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.codegen.ClassFileFactory;
|
import org.jetbrains.jet.codegen.ClassFileFactory;
|
||||||
import org.jetbrains.jet.codegen.GeneratedClassLoader;
|
import org.jetbrains.jet.codegen.GeneratedClassLoader;
|
||||||
@@ -67,6 +68,7 @@ public class CompileEnvironment {
|
|||||||
Disposer.dispose(myRootDisposable);
|
Disposer.dispose(myRootDisposable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static File getUnpackedRuntimePath() {
|
public static File getUnpackedRuntimePath() {
|
||||||
URL url = CompileEnvironment.class.getClassLoader().getResource("jet/JetObject.class");
|
URL url = CompileEnvironment.class.getClassLoader().getResource("jet/JetObject.class");
|
||||||
if (url != null && url.getProtocol().equals("file")) {
|
if (url != null && url.getProtocol().equals("file")) {
|
||||||
@@ -75,6 +77,7 @@ public class CompileEnvironment {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static File getRuntimeJarPath() {
|
public static File getRuntimeJarPath() {
|
||||||
URL url = CompileEnvironment.class.getClassLoader().getResource("jet/JetObject.class");
|
URL url = CompileEnvironment.class.getClassLoader().getResource("jet/JetObject.class");
|
||||||
if (url != null && url.getProtocol().equals("jar")) {
|
if (url != null && url.getProtocol().equals("jar")) {
|
||||||
@@ -88,7 +91,7 @@ public class CompileEnvironment {
|
|||||||
ensureRuntime(myEnvironment);
|
ensureRuntime(myEnvironment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ensureRuntime(JetCoreEnvironment env) {
|
public static void ensureRuntime(@NotNull JetCoreEnvironment env) {
|
||||||
Project project = env.getProject();
|
Project project = env.getProject();
|
||||||
if (JavaPsiFacade.getInstance(project).findClass("java.lang.Object", GlobalSearchScope.allScope(project)) == null) {
|
if (JavaPsiFacade.getInstance(project).findClass("java.lang.Object", GlobalSearchScope.allScope(project)) == null) {
|
||||||
// TODO: prepend
|
// TODO: prepend
|
||||||
@@ -102,6 +105,9 @@ public class CompileEnvironment {
|
|||||||
kotlin = getUnpackedRuntimePath();
|
kotlin = getUnpackedRuntimePath();
|
||||||
if (kotlin == null) kotlin = getRuntimeJarPath();
|
if (kotlin == null) kotlin = getRuntimeJarPath();
|
||||||
}
|
}
|
||||||
|
if (kotlin == null) {
|
||||||
|
throw new IllegalStateException("kotlin runtime not found");
|
||||||
|
}
|
||||||
env.addToClasspath(kotlin);
|
env.addToClasspath(kotlin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.intellij.openapi.application.PathManager;
|
|||||||
import com.intellij.openapi.vfs.VirtualFile;
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -46,6 +47,7 @@ public class PathUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static File getDefaultRuntimePath() {
|
public static File getDefaultRuntimePath() {
|
||||||
File compilerPath = getDefaultCompilerPath();
|
File compilerPath = getDefaultCompilerPath();
|
||||||
if (compilerPath == null) return null;
|
if (compilerPath == null) return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user