Merge branch 'master' of git+ssh://git.labs.intellij.net/jet
This commit is contained in:
Generated
+1
@@ -18,6 +18,7 @@
|
|||||||
<module fileurl="file://$PROJECT_DIR$/compiler/jet.as.java.psi/jet.as.java.psi.iml" filepath="$PROJECT_DIR$/compiler/jet.as.java.psi/jet.as.java.psi.iml" />
|
<module fileurl="file://$PROJECT_DIR$/compiler/jet.as.java.psi/jet.as.java.psi.iml" filepath="$PROJECT_DIR$/compiler/jet.as.java.psi/jet.as.java.psi.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/stdlib/stdlib.iml" filepath="$PROJECT_DIR$/stdlib/stdlib.iml" />
|
<module fileurl="file://$PROJECT_DIR$/stdlib/stdlib.iml" filepath="$PROJECT_DIR$/stdlib/stdlib.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/testlib/testlib.iml" filepath="$PROJECT_DIR$/testlib/testlib.iml" />
|
<module fileurl="file://$PROJECT_DIR$/testlib/testlib.iml" filepath="$PROJECT_DIR$/testlib/testlib.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/compiler/util/util.iml" filepath="$PROJECT_DIR$/compiler/util/util.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -76,7 +76,8 @@
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="jarJDKHeaders" depends="compile,compileJDKHeaders">
|
<target name="jarJDKHeaders" depends="compile,compileJDKHeaders">
|
||||||
<jar destfile="${output}/kotlin-jdk-headers.jar">
|
<mkdir dir="${output}/alt"/>
|
||||||
|
<jar destfile="${output}/alt/kotlin-jdk-headers.jar">
|
||||||
<fileset dir="${output}/classes/jdk-headers"/>
|
<fileset dir="${output}/classes/jdk-headers"/>
|
||||||
</jar>
|
</jar>
|
||||||
</target>
|
</target>
|
||||||
@@ -108,6 +109,7 @@
|
|||||||
<zipfileset prefix="kotlinc" file="${output}/build.txt"/>
|
<zipfileset prefix="kotlinc" file="${output}/build.txt"/>
|
||||||
<zipfileset prefix="kotlinc/license" dir="${basedir}/license"/>
|
<zipfileset prefix="kotlinc/license" dir="${basedir}/license"/>
|
||||||
<zipfileset prefix="kotlinc/bin" filemode="755" dir="${basedir}/compiler/cli/bin"/>
|
<zipfileset prefix="kotlinc/bin" filemode="755" dir="${basedir}/compiler/cli/bin"/>
|
||||||
|
<zipfileset prefix="kotlinc/lib/alt" dir="${output}/alt" includes="*.jar"/>
|
||||||
<zipfileset prefix="kotlinc/lib" dir="${idea.sdk}"/>
|
<zipfileset prefix="kotlinc/lib" dir="${idea.sdk}"/>
|
||||||
<zipfileset prefix="kotlinc/lib" dir="${basedir}/lib"/>
|
<zipfileset prefix="kotlinc/lib" dir="${basedir}/lib"/>
|
||||||
<zipfileset prefix="kotlinc/lib" dir="${output}" includes="*.jar"/>
|
<zipfileset prefix="kotlinc/lib" dir="${output}" includes="*.jar"/>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<orderEntry type="module" module-name="frontend" />
|
<orderEntry type="module" module-name="frontend" />
|
||||||
<orderEntry type="module" module-name="stdlib" />
|
<orderEntry type="module" module-name="stdlib" />
|
||||||
<orderEntry type="library" scope="PROVIDED" name="intellij-core" level="project" />
|
<orderEntry type="library" scope="PROVIDED" name="intellij-core" level="project" />
|
||||||
|
<orderEntry type="module" module-name="util" exported="" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
|
|||||||
+5
@@ -16,6 +16,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
|||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.alt.AltClassFinder;
|
||||||
import org.jetbrains.jet.lang.resolve.java.kt.JetClassAnnotation;
|
import org.jetbrains.jet.lang.resolve.java.kt.JetClassAnnotation;
|
||||||
import org.jetbrains.jet.lang.types.*;
|
import org.jetbrains.jet.lang.types.*;
|
||||||
import org.jetbrains.jet.plugin.JetFileType;
|
import org.jetbrains.jet.plugin.JetFileType;
|
||||||
@@ -124,6 +125,7 @@ public class JavaDescriptorResolver {
|
|||||||
protected final JavaPsiFacade javaFacade;
|
protected final JavaPsiFacade javaFacade;
|
||||||
protected final GlobalSearchScope javaSearchScope;
|
protected final GlobalSearchScope javaSearchScope;
|
||||||
protected final JavaSemanticServices semanticServices;
|
protected final JavaSemanticServices semanticServices;
|
||||||
|
private final AltClassFinder altClassFinder;
|
||||||
|
|
||||||
public JavaDescriptorResolver(Project project, JavaSemanticServices semanticServices) {
|
public JavaDescriptorResolver(Project project, JavaSemanticServices semanticServices) {
|
||||||
this.javaFacade = JavaPsiFacade.getInstance(project);
|
this.javaFacade = JavaPsiFacade.getInstance(project);
|
||||||
@@ -141,6 +143,7 @@ public class JavaDescriptorResolver {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.semanticServices = semanticServices;
|
this.semanticServices = semanticServices;
|
||||||
|
altClassFinder = new AltClassFinder(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isInJdkHeaders(VirtualFile file) {
|
public static boolean isInJdkHeaders(VirtualFile file) {
|
||||||
@@ -656,6 +659,8 @@ public class JavaDescriptorResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PsiClass findClass(String qualifiedName) {
|
private PsiClass findClass(String qualifiedName) {
|
||||||
|
PsiClass altClass = altClassFinder.findClass(qualifiedName);
|
||||||
|
if (altClass != null) return altClass;
|
||||||
return javaFacade.findClass(qualifiedName, javaSearchScope);
|
return javaFacade.findClass(qualifiedName, javaSearchScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+60
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* @author max
|
||||||
|
*/
|
||||||
|
package org.jetbrains.jet.lang.resolve.java.alt;
|
||||||
|
|
||||||
|
import com.intellij.openapi.diagnostic.Logger;
|
||||||
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
|
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||||
|
import com.intellij.psi.PsiClass;
|
||||||
|
import com.intellij.psi.PsiClassOwner;
|
||||||
|
import com.intellij.psi.PsiFile;
|
||||||
|
import com.intellij.psi.PsiManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.plugin.compiler.PathUtil;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AltClassFinder {
|
||||||
|
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jet.lang.resolve.java.alt.AltClassFinder");
|
||||||
|
|
||||||
|
private final PsiManager psiManager;
|
||||||
|
private final List<VirtualFile> roots = new ArrayList<VirtualFile>();
|
||||||
|
|
||||||
|
public AltClassFinder(Project project) {
|
||||||
|
psiManager = PsiManager.getInstance(project);
|
||||||
|
|
||||||
|
File alts = PathUtil.getAltHeadersPath();
|
||||||
|
|
||||||
|
if (alts != null) {
|
||||||
|
for (File root : alts.listFiles()) {
|
||||||
|
VirtualFile jarRoot = VirtualFileManager.getInstance().findFileByUrl("jar://" + root.getPath() + "!/");
|
||||||
|
roots.add(jarRoot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PsiClass findClass(@NotNull String qualifiedName) {
|
||||||
|
for (final VirtualFile classRoot : roots) {
|
||||||
|
final VirtualFile classFile = classRoot.findFileByRelativePath(qualifiedName.replace('.', '/') + ".class");
|
||||||
|
if (classFile != null) {
|
||||||
|
if (!classFile.isValid()) {
|
||||||
|
LOG.error("Invalid child of valid parent: " + classFile.getPath() + "; " + classRoot.isValid() + " path=" + classRoot.getPath());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final PsiFile file = psiManager.findFile(classFile);
|
||||||
|
if (file instanceof PsiClassOwner) {
|
||||||
|
final PsiClass[] classes = ((PsiClassOwner) file).getClasses();
|
||||||
|
if (classes.length == 1) {
|
||||||
|
return classes[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* @author max
|
||||||
|
*/
|
||||||
|
package org.jetbrains.jet.plugin.compiler;
|
||||||
|
|
||||||
|
import com.intellij.openapi.application.PathManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class PathUtil {
|
||||||
|
private PathUtil() {}
|
||||||
|
|
||||||
|
public static File getDefaultCompilerPath() {
|
||||||
|
File plugin_jar_path = new File(getJarPathForClass(PathUtil.class));
|
||||||
|
|
||||||
|
if (!plugin_jar_path.exists()) return null;
|
||||||
|
|
||||||
|
if (plugin_jar_path.getName().equals("kotlin-plugin.jar")) {
|
||||||
|
File lib = plugin_jar_path.getParentFile();
|
||||||
|
File pluginHome = lib.getParentFile();
|
||||||
|
|
||||||
|
File answer = new File(pluginHome, "kotlinc");
|
||||||
|
|
||||||
|
return answer.exists() ? answer : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin_jar_path.getName().equals("kotlin-compiler.jar")) {
|
||||||
|
File lib = plugin_jar_path.getParentFile();
|
||||||
|
File answer = lib.getParentFile();
|
||||||
|
return answer.exists() ? answer : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File getDefaultRuntimePath() {
|
||||||
|
File compilerPath = getDefaultCompilerPath();
|
||||||
|
if (compilerPath == null) return null;
|
||||||
|
|
||||||
|
File answer = new File(compilerPath, "lib/kotlin-runtime.jar");
|
||||||
|
|
||||||
|
return answer.exists() ? answer : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File getAltHeadersPath() {
|
||||||
|
File compilerPath = getDefaultCompilerPath();
|
||||||
|
if (compilerPath == null) return null;
|
||||||
|
|
||||||
|
File answer = new File(compilerPath, "lib/alt");
|
||||||
|
return answer.exists() ? answer : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static String getJarPathForClass(@NotNull Class aClass) {
|
||||||
|
String resourceRoot = PathManager.getResourceRoot(aClass, "/" + aClass.getName().replace('.', '/') + ".class");
|
||||||
|
return new File(resourceRoot).getAbsoluteFile().getAbsolutePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="intellij-core" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
|
|
||||||
@@ -84,8 +84,6 @@
|
|||||||
<java.elementFinder implementation="org.jetbrains.jet.asJava.JavaElementFinder"/>
|
<java.elementFinder implementation="org.jetbrains.jet.asJava.JavaElementFinder"/>
|
||||||
<java.shortNamesCache implementation="org.jetbrains.jet.plugin.caches.JetShortNamesCache"/>
|
<java.shortNamesCache implementation="org.jetbrains.jet.plugin.caches.JetShortNamesCache"/>
|
||||||
|
|
||||||
<java.elementFinder implementation="org.jetbrains.jet.plugin.caches.JdkHeadersFinder"/>
|
|
||||||
|
|
||||||
<editorNotificationProvider implementation="org.jetbrains.jet.plugin.quickfix.ConfigureKotlinLibraryNotificationProvider"/>
|
<editorNotificationProvider implementation="org.jetbrains.jet.plugin.quickfix.ConfigureKotlinLibraryNotificationProvider"/>
|
||||||
|
|
||||||
<psi.treeChangePreprocessor implementation="org.jetbrains.jet.asJava.JetCodeBlockModificationListener"/>
|
<psi.treeChangePreprocessor implementation="org.jetbrains.jet.asJava.JetCodeBlockModificationListener"/>
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* @author max
|
|
||||||
*/
|
|
||||||
package org.jetbrains.jet.plugin.caches;
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project;
|
|
||||||
import com.intellij.openapi.vfs.JarFileSystem;
|
|
||||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
|
||||||
import com.intellij.psi.NonClasspathClassFinder;
|
|
||||||
import org.jetbrains.jet.plugin.compiler.CompilerUtil;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class JdkHeadersFinder extends NonClasspathClassFinder {
|
|
||||||
public JdkHeadersFinder(Project project) {
|
|
||||||
super(project);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<VirtualFile> calcClassRoots() {
|
|
||||||
File jdk_headers = CompilerUtil.getJdkHeadersPath();
|
|
||||||
if (jdk_headers == null) return Collections.emptyList();
|
|
||||||
|
|
||||||
VirtualFile jarVfs = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(jdk_headers);
|
|
||||||
if (jarVfs == null) return Collections.emptyList();
|
|
||||||
jarVfs.refresh(true, false);
|
|
||||||
|
|
||||||
return Collections.singletonList(JarFileSystem.getInstance().getJarRootForLocalFile(jarVfs));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* @author max
|
|
||||||
*/
|
|
||||||
package org.jetbrains.jet.plugin.compiler;
|
|
||||||
|
|
||||||
import com.intellij.util.PathUtil;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class CompilerUtil {
|
|
||||||
public static File getDefaultCompilerPath() {
|
|
||||||
File plugin_jar_path = new File(PathUtil.getJarPathForClass(CompilerUtil.class));
|
|
||||||
|
|
||||||
if (!plugin_jar_path.exists()) return null;
|
|
||||||
|
|
||||||
File lib = plugin_jar_path.getParentFile();
|
|
||||||
File pluginHome = lib.getParentFile();
|
|
||||||
|
|
||||||
File answer = new File(pluginHome, "kotlinc");
|
|
||||||
|
|
||||||
return answer.exists() ? answer : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getDefaultRuntimePath() {
|
|
||||||
File compilerPath = getDefaultCompilerPath();
|
|
||||||
if (compilerPath == null) return null;
|
|
||||||
|
|
||||||
File answer = new File(compilerPath, "lib/kotlin-runtime.jar");
|
|
||||||
|
|
||||||
return answer.exists() ? answer : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File getJdkHeadersPath() {
|
|
||||||
File compilerPath = getDefaultCompilerPath();
|
|
||||||
if (compilerPath == null) return null;
|
|
||||||
|
|
||||||
File answer = new File(compilerPath, "lib/kotlin-jdk-headers.jar");
|
|
||||||
|
|
||||||
return answer.exists() ? answer : null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+12
-15
@@ -3,7 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.jetbrains.jet.plugin.quickfix;
|
package org.jetbrains.jet.plugin.quickfix;
|
||||||
|
|
||||||
import com.intellij.ProjectTopics;
|
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
import com.intellij.openapi.compiler.CompilerManager;
|
import com.intellij.openapi.compiler.CompilerManager;
|
||||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||||
@@ -15,7 +14,9 @@ import com.intellij.openapi.module.ModuleUtil;
|
|||||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||||
import com.intellij.openapi.project.IndexNotReadyException;
|
import com.intellij.openapi.project.IndexNotReadyException;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.roots.*;
|
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||||
|
import com.intellij.openapi.roots.ModuleRootManager;
|
||||||
|
import com.intellij.openapi.roots.OrderRootType;
|
||||||
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable;
|
import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable;
|
||||||
import com.intellij.openapi.roots.libraries.Library;
|
import com.intellij.openapi.roots.libraries.Library;
|
||||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||||
@@ -33,7 +34,7 @@ import com.intellij.ui.EditorNotificationPanel;
|
|||||||
import com.intellij.ui.EditorNotifications;
|
import com.intellij.ui.EditorNotifications;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.plugin.JetFileType;
|
import org.jetbrains.jet.plugin.JetFileType;
|
||||||
import org.jetbrains.jet.plugin.compiler.CompilerUtil;
|
import org.jetbrains.jet.plugin.compiler.PathUtil;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -48,18 +49,8 @@ public class ConfigureKotlinLibraryNotificationProvider implements EditorNotific
|
|||||||
return KEY;
|
return KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigureKotlinLibraryNotificationProvider(Project project, final EditorNotifications notifications) {
|
public ConfigureKotlinLibraryNotificationProvider(Project project) {
|
||||||
myProject = project;
|
myProject = project;
|
||||||
project.getMessageBus().connect(project).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
|
|
||||||
@Override
|
|
||||||
public void beforeRootsChange(ModuleRootEvent event) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void rootsChanged(ModuleRootEvent event) {
|
|
||||||
notifications.updateAllNotifications();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -95,7 +86,7 @@ public class ConfigureKotlinLibraryNotificationProvider implements EditorNotific
|
|||||||
final Library kotlinRuntime = table.getLibraryByName("KotlinRuntime");
|
final Library kotlinRuntime = table.getLibraryByName("KotlinRuntime");
|
||||||
if (kotlinRuntime != null) return null;
|
if (kotlinRuntime != null) return null;
|
||||||
|
|
||||||
File runtimePath = CompilerUtil.getDefaultRuntimePath();
|
File runtimePath = PathUtil.getDefaultRuntimePath();
|
||||||
if (runtimePath == null) {
|
if (runtimePath == null) {
|
||||||
Messages.showErrorDialog(myProject, "kotlin-runtime.jar is not found. Make sure plugin is properly installed.", "No Runtime Found");
|
Messages.showErrorDialog(myProject, "kotlin-runtime.jar is not found. Make sure plugin is properly installed.", "No Runtime Found");
|
||||||
return null;
|
return null;
|
||||||
@@ -146,6 +137,12 @@ public class ConfigureKotlinLibraryNotificationProvider implements EditorNotific
|
|||||||
ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
|
ModifiableRootModel model = ModuleRootManager.getInstance(module).getModifiableModel();
|
||||||
model.addLibraryEntry(library);
|
model.addLibraryEntry(library);
|
||||||
model.commit();
|
model.commit();
|
||||||
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
EditorNotifications.getInstance(myProject).updateAllNotifications();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user