Finish merge.
This commit is contained in:
@@ -47,6 +47,16 @@ import java.util.List;
|
|||||||
public class JetCoreEnvironment extends JavaCoreEnvironment {
|
public class JetCoreEnvironment extends JavaCoreEnvironment {
|
||||||
private final List<JetFile> sourceFiles = new ArrayList<JetFile>();
|
private final List<JetFile> sourceFiles = new ArrayList<JetFile>();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static JetCoreEnvironment getCoreEnvironmentForJS(Disposable disposable) {
|
||||||
|
return new JetCoreEnvironment(disposable, CompilerDependencies.compilerDependenciesForProduction(CompilerSpecialMode.JS));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static JetCoreEnvironment getCoreEnvironmentForJVM(Disposable disposable, @NotNull CompilerDependencies dependencies) {
|
||||||
|
return new JetCoreEnvironment(disposable, dependencies);
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final CompilerDependencies compilerDependencies;
|
private final CompilerDependencies compilerDependencies;
|
||||||
|
|
||||||
@@ -89,7 +99,7 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addSources(File file) {
|
private void addSources(File file) {
|
||||||
if(file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
File[] files = file.listFiles();
|
File[] files = file.listFiles();
|
||||||
if (files != null) {
|
if (files != null) {
|
||||||
for (File child : files) {
|
for (File child : files) {
|
||||||
@@ -101,15 +111,15 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
|
|||||||
VirtualFile fileByPath = getLocalFileSystem().findFileByPath(file.getAbsolutePath());
|
VirtualFile fileByPath = getLocalFileSystem().findFileByPath(file.getAbsolutePath());
|
||||||
if (fileByPath != null) {
|
if (fileByPath != null) {
|
||||||
PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(fileByPath);
|
PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(fileByPath);
|
||||||
if(psiFile instanceof JetFile) {
|
if (psiFile instanceof JetFile) {
|
||||||
sourceFiles.add((JetFile)psiFile);
|
sourceFiles.add((JetFile) psiFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSources(VirtualFile vFile) {
|
public void addSources(VirtualFile vFile) {
|
||||||
if (vFile.isDirectory()) {
|
if (vFile.isDirectory()) {
|
||||||
for (VirtualFile virtualFile : vFile.getChildren()) {
|
for (VirtualFile virtualFile : vFile.getChildren()) {
|
||||||
addSources(virtualFile);
|
addSources(virtualFile);
|
||||||
}
|
}
|
||||||
@@ -118,15 +128,16 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
|
|||||||
if (vFile.getFileType() == JetFileType.INSTANCE) {
|
if (vFile.getFileType() == JetFileType.INSTANCE) {
|
||||||
PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(vFile);
|
PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(vFile);
|
||||||
if (psiFile instanceof JetFile) {
|
if (psiFile instanceof JetFile) {
|
||||||
sourceFiles.add((JetFile)psiFile);
|
sourceFiles.add((JetFile) psiFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSources(String path) {
|
public void addSources(String path) {
|
||||||
if(path == null)
|
if (path == null) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
VirtualFile vFile = getLocalFileSystem().findFileByPath(path);
|
VirtualFile vFile = getLocalFileSystem().findFileByPath(path);
|
||||||
if (vFile == null) {
|
if (vFile == null) {
|
||||||
@@ -145,14 +156,16 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
|
|||||||
|
|
||||||
public void addToClasspathFromClassLoader(ClassLoader loader) {
|
public void addToClasspathFromClassLoader(ClassLoader loader) {
|
||||||
ClassLoader parent = loader.getParent();
|
ClassLoader parent = loader.getParent();
|
||||||
if(parent != null)
|
if (parent != null) {
|
||||||
addToClasspathFromClassLoader(parent);
|
addToClasspathFromClassLoader(parent);
|
||||||
|
}
|
||||||
|
|
||||||
if(loader instanceof URLClassLoader) {
|
if (loader instanceof URLClassLoader) {
|
||||||
for (URL url : ((URLClassLoader) loader).getURLs()) {
|
for (URL url : ((URLClassLoader) loader).getURLs()) {
|
||||||
File file = new File(url.getPath());
|
File file = new File(url.getPath());
|
||||||
if(file.exists() && (!file.isFile() || file.getPath().endsWith(".jar")))
|
if (file.exists() && (!file.isFile() || file.getPath().endsWith(".jar"))) {
|
||||||
addToClasspath(file);
|
addToClasspath(file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user