add JDK to CompilerDependencies
This commit is contained in:
@@ -138,7 +138,7 @@ public class KotlinCompiler {
|
|||||||
runtimeJar = null;
|
runtimeJar = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
CompilerDependencies dependencies = new CompilerDependencies(mode, jdkHeadersJar, runtimeJar);
|
CompilerDependencies dependencies = new CompilerDependencies(mode, CompilerDependencies.findRtJar(), jdkHeadersJar, runtimeJar);
|
||||||
PrintingMessageCollector messageCollector = new PrintingMessageCollector(errStream, messageRenderer, arguments.verbose);
|
PrintingMessageCollector messageCollector = new PrintingMessageCollector(errStream, messageRenderer, arguments.verbose);
|
||||||
Disposable rootDisposable = CompileEnvironmentUtil.createMockDisposable();
|
Disposable rootDisposable = CompileEnvironmentUtil.createMockDisposable();
|
||||||
|
|
||||||
|
|||||||
@@ -93,51 +93,13 @@ public class CompileEnvironmentUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ensureJdkRuntime(JetCoreEnvironment env) {
|
|
||||||
if (JavaPsiFacade.getInstance(env.getProject()).findClass("java.lang.Object", GlobalSearchScope.allScope(env.getProject())) == null) {
|
|
||||||
// TODO: prepend
|
|
||||||
env.addToClasspath(findRtJar());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static File findRtJar() {
|
|
||||||
String javaHome = System.getProperty("java.home");
|
|
||||||
if ("jre".equals(new File(javaHome).getName())) {
|
|
||||||
javaHome = new File(javaHome).getParent();
|
|
||||||
}
|
|
||||||
|
|
||||||
File rtJar = findRtJar(javaHome);
|
|
||||||
|
|
||||||
if (rtJar == null || !rtJar.exists()) {
|
|
||||||
throw new CompileEnvironmentException("No JDK rt.jar found under " + javaHome);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rtJar;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static File findRtJar(String javaHome) {
|
|
||||||
File rtJar = new File(javaHome, "jre/lib/rt.jar");
|
|
||||||
if (rtJar.exists()) {
|
|
||||||
return rtJar;
|
|
||||||
}
|
|
||||||
|
|
||||||
File classesJar = new File(new File(javaHome).getParentFile().getAbsolutePath(), "Classes/classes.jar");
|
|
||||||
if (classesJar.exists()) {
|
|
||||||
return classesJar;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ensureRuntime(JetCoreEnvironment environment, CompilerDependencies compilerDependencies) {
|
public static void ensureRuntime(JetCoreEnvironment environment, CompilerDependencies compilerDependencies) {
|
||||||
if (compilerDependencies.getCompilerSpecialMode() == CompilerSpecialMode.REGULAR) {
|
if (compilerDependencies.getCompilerSpecialMode() == CompilerSpecialMode.REGULAR) {
|
||||||
ensureJdkRuntime(environment);
|
|
||||||
ensureKotlinRuntime(environment);
|
ensureKotlinRuntime(environment);
|
||||||
}
|
}
|
||||||
else if (compilerDependencies.getCompilerSpecialMode() == CompilerSpecialMode.JDK_HEADERS) {
|
else if (compilerDependencies.getCompilerSpecialMode() == CompilerSpecialMode.JDK_HEADERS) {
|
||||||
ensureJdkRuntime(environment);
|
|
||||||
}
|
}
|
||||||
else if (compilerDependencies.getCompilerSpecialMode() == CompilerSpecialMode.STDLIB) {
|
else if (compilerDependencies.getCompilerSpecialMode() == CompilerSpecialMode.STDLIB) {
|
||||||
ensureJdkRuntime(environment);
|
|
||||||
}
|
}
|
||||||
else if (compilerDependencies.getCompilerSpecialMode() == CompilerSpecialMode.BUILTINS) {
|
else if (compilerDependencies.getCompilerSpecialMode() == CompilerSpecialMode.BUILTINS) {
|
||||||
// nop
|
// nop
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ public class JetCoreEnvironment extends JavaCoreEnvironment {
|
|||||||
|
|
||||||
CompilerSpecialMode compilerSpecialMode = compilerDependencies.getCompilerSpecialMode();
|
CompilerSpecialMode compilerSpecialMode = compilerDependencies.getCompilerSpecialMode();
|
||||||
|
|
||||||
|
addToClasspath(compilerDependencies.getJdkJar());
|
||||||
|
|
||||||
if (compilerSpecialMode.includeJdkHeaders()) {
|
if (compilerSpecialMode.includeJdkHeaders()) {
|
||||||
for (VirtualFile root : compilerDependencies.getJdkHeaderRoots()) {
|
for (VirtualFile root : compilerDependencies.getJdkHeaderRoots()) {
|
||||||
addLibraryRoot(root);
|
addLibraryRoot(root);
|
||||||
|
|||||||
+37
-1
@@ -33,12 +33,15 @@ public class CompilerDependencies {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private final CompilerSpecialMode compilerSpecialMode;
|
private final CompilerSpecialMode compilerSpecialMode;
|
||||||
@Nullable
|
@Nullable
|
||||||
|
private final File jdkJar;
|
||||||
|
@Nullable
|
||||||
private final File jdkHeadersJar;
|
private final File jdkHeadersJar;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final File runtimeJar;
|
private final File runtimeJar;
|
||||||
|
|
||||||
public CompilerDependencies(@NotNull CompilerSpecialMode compilerSpecialMode, @Nullable File jdkHeadersJar, @Nullable File runtimeJar) {
|
public CompilerDependencies(@NotNull CompilerSpecialMode compilerSpecialMode, @Nullable File jdkJar, @Nullable File jdkHeadersJar, @Nullable File runtimeJar) {
|
||||||
this.compilerSpecialMode = compilerSpecialMode;
|
this.compilerSpecialMode = compilerSpecialMode;
|
||||||
|
this.jdkJar = jdkJar;
|
||||||
this.jdkHeadersJar = jdkHeadersJar;
|
this.jdkHeadersJar = jdkHeadersJar;
|
||||||
this.runtimeJar = runtimeJar;
|
this.runtimeJar = runtimeJar;
|
||||||
|
|
||||||
@@ -59,6 +62,11 @@ public class CompilerDependencies {
|
|||||||
return compilerSpecialMode;
|
return compilerSpecialMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public File getJdkJar() {
|
||||||
|
return jdkJar;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public File getJdkHeadersJar() {
|
public File getJdkHeadersJar() {
|
||||||
return jdkHeadersJar;
|
return jdkHeadersJar;
|
||||||
@@ -93,8 +101,36 @@ public class CompilerDependencies {
|
|||||||
public static CompilerDependencies compilerDependenciesForProduction(@NotNull CompilerSpecialMode compilerSpecialMode) {
|
public static CompilerDependencies compilerDependenciesForProduction(@NotNull CompilerSpecialMode compilerSpecialMode) {
|
||||||
return new CompilerDependencies(
|
return new CompilerDependencies(
|
||||||
compilerSpecialMode,
|
compilerSpecialMode,
|
||||||
|
findRtJar(),
|
||||||
compilerSpecialMode.includeJdkHeaders() ? PathUtil.getAltHeadersPath() : null,
|
compilerSpecialMode.includeJdkHeaders() ? PathUtil.getAltHeadersPath() : null,
|
||||||
compilerSpecialMode.includeKotlinRuntime() ? PathUtil.getDefaultRuntimePath() : null);
|
compilerSpecialMode.includeKotlinRuntime() ? PathUtil.getDefaultRuntimePath() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static File findRtJar() {
|
||||||
|
String javaHome = System.getProperty("java.home");
|
||||||
|
if ("jre".equals(new File(javaHome).getName())) {
|
||||||
|
javaHome = new File(javaHome).getParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
File rtJar = findRtJar(javaHome);
|
||||||
|
|
||||||
|
if (rtJar == null || !rtJar.exists()) {
|
||||||
|
throw new IllegalArgumentException("No JDK rt.jar found under " + javaHome);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rtJar;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File findRtJar(String javaHome) {
|
||||||
|
File rtJar = new File(javaHome, "jre/lib/rt.jar");
|
||||||
|
if (rtJar.exists()) {
|
||||||
|
return rtJar;
|
||||||
|
}
|
||||||
|
|
||||||
|
File classesJar = new File(new File(javaHome).getParentFile().getAbsolutePath(), "Classes/classes.jar");
|
||||||
|
if (classesJar.exists()) {
|
||||||
|
return classesJar;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,9 +49,10 @@ public class CompileCompilerDependenciesTest {
|
|||||||
* @see CompilerDependencies#compilerDependenciesForProduction(org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode)
|
* @see CompilerDependencies#compilerDependenciesForProduction(org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode)
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public static CompilerDependencies compilerDependenciesForTests(@NotNull CompilerSpecialMode compilerSpecialMode) {
|
public static CompilerDependencies compilerDependenciesForTests(@NotNull CompilerSpecialMode compilerSpecialMode, boolean mockJdk) {
|
||||||
return new CompilerDependencies(
|
return new CompilerDependencies(
|
||||||
compilerSpecialMode,
|
compilerSpecialMode,
|
||||||
|
mockJdk ? JetTestUtils.findMockJdkRtJar() : CompilerDependencies.findRtJar(),
|
||||||
compilerSpecialMode.includeJdkHeaders() ? ForTestCompileJdkHeaders.jdkHeadersForTests() : null,
|
compilerSpecialMode.includeJdkHeaders() ? ForTestCompileJdkHeaders.jdkHeadersForTests() : null,
|
||||||
compilerSpecialMode.includeKotlinRuntime() ? ForTestCompileRuntime.runtimeJarForTests() : null);
|
compilerSpecialMode.includeKotlinRuntime() ? ForTestCompileRuntime.runtimeJarForTests() : null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ import com.intellij.testFramework.LightVirtualFile;
|
|||||||
import com.intellij.testFramework.TestDataFile;
|
import com.intellij.testFramework.TestDataFile;
|
||||||
import com.intellij.testFramework.UsefulTestCase;
|
import com.intellij.testFramework.UsefulTestCase;
|
||||||
import org.jetbrains.annotations.NonNls;
|
import org.jetbrains.annotations.NonNls;
|
||||||
import org.jetbrains.jet.compiler.CompileEnvironmentUtil;
|
|
||||||
import org.jetbrains.jet.compiler.JetCoreEnvironment;
|
import org.jetbrains.jet.compiler.JetCoreEnvironment;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.CompilerDependencies;
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||||
import org.jetbrains.jet.plugin.JetLanguage;
|
import org.jetbrains.jet.plugin.JetLanguage;
|
||||||
|
|
||||||
@@ -76,9 +76,7 @@ public abstract class JetLiteFixture extends UsefulTestCase {
|
|||||||
|
|
||||||
protected void createEnvironmentWithFullJdk() {
|
protected void createEnvironmentWithFullJdk() {
|
||||||
myEnvironment = new JetCoreEnvironment(getTestRootDisposable(),
|
myEnvironment = new JetCoreEnvironment(getTestRootDisposable(),
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR));
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, false));
|
||||||
final File rtJar = CompileEnvironmentUtil.findRtJar();
|
|
||||||
myEnvironment.addToClasspath(rtJar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ public class JetTestUtils {
|
|||||||
|
|
||||||
public static AnalyzeExhaust analyzeFile(@NotNull JetFile namespace, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
public static AnalyzeExhaust analyzeFile(@NotNull JetFile namespace, @NotNull JetControlFlowDataTraceFactory flowDataTraceFactory) {
|
||||||
return AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(namespace, flowDataTraceFactory,
|
return AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(namespace, flowDataTraceFactory,
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR));
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JetCoreEnvironment createEnvironmentWithMockJdk(Disposable disposable) {
|
public static JetCoreEnvironment createEnvironmentWithMockJdk(Disposable disposable) {
|
||||||
@@ -171,10 +171,11 @@ public class JetTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static JetCoreEnvironment createEnvironmentWithMockJdk(Disposable disposable, @NotNull CompilerSpecialMode compilerSpecialMode) {
|
public static JetCoreEnvironment createEnvironmentWithMockJdk(Disposable disposable, @NotNull CompilerSpecialMode compilerSpecialMode) {
|
||||||
JetCoreEnvironment environment = new JetCoreEnvironment(disposable, CompileCompilerDependenciesTest.compilerDependenciesForTests(compilerSpecialMode));
|
return new JetCoreEnvironment(disposable, CompileCompilerDependenciesTest.compilerDependenciesForTests(compilerSpecialMode, true));
|
||||||
final File rtJar = new File(JetTestCaseBuilder.getHomeDirectory(), "compiler/testData/mockJDK-1.7/jre/lib/rt.jar");
|
}
|
||||||
environment.addToClasspath(rtJar);
|
|
||||||
return environment;
|
public static File findMockJdkRtJar() {
|
||||||
|
return new File(JetTestCaseBuilder.getHomeDirectory(), "compiler/testData/mockJDK-1.7/jre/lib/rt.jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File getAnnotationsJar() {
|
public static File getAnnotationsJar() {
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ public class CheckerTestUtilTest extends JetLiteFixture {
|
|||||||
public void test(final @NotNull PsiFile psiFile) {
|
public void test(final @NotNull PsiFile psiFile) {
|
||||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(
|
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(
|
||||||
(JetFile) psiFile, JetControlFlowDataTraceFactory.EMPTY,
|
(JetFile) psiFile, JetControlFlowDataTraceFactory.EMPTY,
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR))
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, true))
|
||||||
.getBindingContext();
|
.getBindingContext();
|
||||||
|
|
||||||
String expectedText = CheckerTestUtil.addDiagnosticMarkersToText(psiFile, CheckerTestUtil.getDiagnosticsIncludingSyntaxErrors(bindingContext, psiFile)).toString();
|
String expectedText = CheckerTestUtil.addDiagnosticMarkersToText(psiFile, CheckerTestUtil.getDiagnosticsIncludingSyntaxErrors(bindingContext, psiFile)).toString();
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ public class JetDiagnosticsTest extends JetLiteFixture {
|
|||||||
|
|
||||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
||||||
getProject(), jetFiles, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY,
|
getProject(), jetFiles, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY,
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR))
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, true))
|
||||||
.getBindingContext();
|
.getBindingContext();
|
||||||
|
|
||||||
boolean ok = true;
|
boolean ok = true;
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public abstract class CodegenTestCase extends JetLiteFixture {
|
|||||||
private GenerationState generateCommon(ClassBuilderFactory classBuilderFactory) {
|
private GenerationState generateCommon(ClassBuilderFactory classBuilderFactory) {
|
||||||
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
||||||
myFile, JetControlFlowDataTraceFactory.EMPTY,
|
myFile, JetControlFlowDataTraceFactory.EMPTY,
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR));
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, false));
|
||||||
analyzeExhaust.throwIfError();
|
analyzeExhaust.throwIfError();
|
||||||
GenerationState state = new GenerationState(getProject(), classBuilderFactory, analyzeExhaust, Collections.singletonList(myFile));
|
GenerationState state = new GenerationState(getProject(), classBuilderFactory, analyzeExhaust, Collections.singletonList(myFile));
|
||||||
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import java.lang.reflect.Method;
|
|||||||
public class CompileTextTest extends CodegenTestCase {
|
public class CompileTextTest extends CodegenTestCase {
|
||||||
public void testMe() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
public void testMe() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||||
String text = "import org.jetbrains.jet.codegen.CompileTextTest; fun x() = CompileTextTest()";
|
String text = "import org.jetbrains.jet.codegen.CompileTextTest; fun x() = CompileTextTest()";
|
||||||
CompilerDependencies dependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR);
|
CompilerDependencies dependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, false);
|
||||||
JetCoreEnvironment environment = new JetCoreEnvironment(CompileEnvironmentUtil.createMockDisposable(), dependencies);
|
JetCoreEnvironment environment = new JetCoreEnvironment(CompileEnvironmentUtil.createMockDisposable(), dependencies);
|
||||||
CompileEnvironmentConfiguration configuration = new CompileEnvironmentConfiguration(environment, dependencies, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR);
|
CompileEnvironmentConfiguration configuration = new CompileEnvironmentConfiguration(environment, dependencies, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR);
|
||||||
configuration.getEnvironment().addToClasspathFromClassLoader(getClass().getClassLoader());
|
configuration.getEnvironment().addToClasspathFromClassLoader(getClass().getClassLoader());
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class GenerationUtils {
|
|||||||
public static GenerationState compileFileGetGenerationStateForTest(JetFile psiFile, @NotNull CompilerSpecialMode compilerSpecialMode) {
|
public static GenerationState compileFileGetGenerationStateForTest(JetFile psiFile, @NotNull CompilerSpecialMode compilerSpecialMode) {
|
||||||
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
final AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
||||||
psiFile, JetControlFlowDataTraceFactory.EMPTY,
|
psiFile, JetControlFlowDataTraceFactory.EMPTY,
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(compilerSpecialMode));
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(compilerSpecialMode, true));
|
||||||
analyzeExhaust.throwIfError();
|
analyzeExhaust.throwIfError();
|
||||||
GenerationState state = new GenerationState(psiFile.getProject(), ClassBuilderFactories.binaries(false), analyzeExhaust, Collections.singletonList(psiFile));
|
GenerationState state = new GenerationState(psiFile.getProject(), ClassBuilderFactories.binaries(false), analyzeExhaust, Collections.singletonList(psiFile));
|
||||||
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
state.compileCorrectFiles(CompilationErrorHandler.THROW_EXCEPTION);
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class TestlibTest extends CodegenTestCase {
|
|||||||
|
|
||||||
private TestSuite doBuildSuite() {
|
private TestSuite doBuildSuite() {
|
||||||
try {
|
try {
|
||||||
CompilerDependencies compilerDependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR);
|
CompilerDependencies compilerDependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, false);
|
||||||
File junitJar = new File("libraries/lib/junit-4.9.jar");
|
File junitJar = new File("libraries/lib/junit-4.9.jar");
|
||||||
|
|
||||||
if (!junitJar.exists()) {
|
if (!junitJar.exists()) {
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class JavaDescriptorResolverTest extends TestCaseWithTmpdir {
|
|||||||
jetCoreEnvironment.addToClasspath(tmpdir);
|
jetCoreEnvironment.addToClasspath(tmpdir);
|
||||||
|
|
||||||
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(
|
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.JDK_HEADERS), jetCoreEnvironment.getProject());
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.JDK_HEADERS, true), jetCoreEnvironment.getProject());
|
||||||
JavaDescriptorResolver javaDescriptorResolver = injector.getJavaDescriptorResolver();
|
JavaDescriptorResolver javaDescriptorResolver = injector.getJavaDescriptorResolver();
|
||||||
ClassDescriptor classDescriptor = javaDescriptorResolver.resolveClass(new FqName("A"), DescriptorSearchRule.ERROR_IF_FOUND_IN_KOTLIN);
|
ClassDescriptor classDescriptor = javaDescriptorResolver.resolveClass(new FqName("A"), DescriptorSearchRule.ERROR_IF_FOUND_IN_KOTLIN);
|
||||||
Assert.assertNotNull(classDescriptor);
|
Assert.assertNotNull(classDescriptor);
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public class ReadJavaBinaryClassTest extends TestCaseWithTmpdir {
|
|||||||
|
|
||||||
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
||||||
psiFile, JetControlFlowDataTraceFactory.EMPTY,
|
psiFile, JetControlFlowDataTraceFactory.EMPTY,
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.JDK_HEADERS))
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.JDK_HEADERS, true))
|
||||||
.getBindingContext();
|
.getBindingContext();
|
||||||
return bindingContext.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, FqName.topLevel("test"));
|
return bindingContext.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, FqName.topLevel("test"));
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ public class ReadJavaBinaryClassTest extends TestCaseWithTmpdir {
|
|||||||
jetCoreEnvironment.addToClasspath(new File("out/production/runtime"));
|
jetCoreEnvironment.addToClasspath(new File("out/production/runtime"));
|
||||||
|
|
||||||
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(
|
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.JDK_HEADERS), jetCoreEnvironment.getProject());
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.JDK_HEADERS, true), jetCoreEnvironment.getProject());
|
||||||
JavaDescriptorResolver javaDescriptorResolver = injector.getJavaDescriptorResolver();
|
JavaDescriptorResolver javaDescriptorResolver = injector.getJavaDescriptorResolver();
|
||||||
return javaDescriptorResolver.resolveNamespace(FqName.topLevel("test"), DescriptorSearchRule.ERROR_IF_FOUND_IN_KOTLIN);
|
return javaDescriptorResolver.resolveNamespace(FqName.topLevel("test"), DescriptorSearchRule.ERROR_IF_FOUND_IN_KOTLIN);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class ReadKotlinBinaryClassTest extends TestCaseWithTmpdir {
|
|||||||
jetCoreEnvironment.addToClasspath(new File("out/production/runtime"));
|
jetCoreEnvironment.addToClasspath(new File("out/production/runtime"));
|
||||||
|
|
||||||
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(
|
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.JDK_HEADERS), jetCoreEnvironment.getProject());
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.JDK_HEADERS, true), jetCoreEnvironment.getProject());
|
||||||
JavaDescriptorResolver javaDescriptorResolver = injector.getJavaDescriptorResolver();
|
JavaDescriptorResolver javaDescriptorResolver = injector.getJavaDescriptorResolver();
|
||||||
NamespaceDescriptor namespaceFromClass = javaDescriptorResolver.resolveNamespace(FqName.topLevel("test"), DescriptorSearchRule.ERROR_IF_FOUND_IN_KOTLIN);
|
NamespaceDescriptor namespaceFromClass = javaDescriptorResolver.resolveNamespace(FqName.topLevel("test"), DescriptorSearchRule.ERROR_IF_FOUND_IN_KOTLIN);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ public class ResolveDescriptorsFromExternalLibraries {
|
|||||||
|
|
||||||
public ResolveDescriptorsFromExternalLibraries() {
|
public ResolveDescriptorsFromExternalLibraries() {
|
||||||
System.out.println("Getting compiler dependencies");
|
System.out.println("Getting compiler dependencies");
|
||||||
compilerDependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR);
|
compilerDependencies = CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run() throws Exception {
|
private void run() throws Exception {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class DescriptorRendererTest extends JetLiteFixture {
|
|||||||
AnalyzeExhaust analyzeExhaust =
|
AnalyzeExhaust analyzeExhaust =
|
||||||
AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(
|
AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(
|
||||||
(JetFile) psiFile, JetControlFlowDataTraceFactory.EMPTY,
|
(JetFile) psiFile, JetControlFlowDataTraceFactory.EMPTY,
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR));
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, true));
|
||||||
final BindingContext bindingContext = analyzeExhaust.getBindingContext();
|
final BindingContext bindingContext = analyzeExhaust.getBindingContext();
|
||||||
final List<DeclarationDescriptor> descriptors = new ArrayList<DeclarationDescriptor>();
|
final List<DeclarationDescriptor> descriptors = new ArrayList<DeclarationDescriptor>();
|
||||||
psiFile.acceptChildren(new JetVisitorVoid() {
|
psiFile.acceptChildren(new JetVisitorVoid() {
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public abstract class ExpectedResolveData {
|
|||||||
|
|
||||||
AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(project, files,
|
AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(project, files,
|
||||||
Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY,
|
Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY,
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR));
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, true));
|
||||||
BindingContext bindingContext = analyzeExhaust.getBindingContext();
|
BindingContext bindingContext = analyzeExhaust.getBindingContext();
|
||||||
for (Diagnostic diagnostic : bindingContext.getDiagnostics()) {
|
for (Diagnostic diagnostic : bindingContext.getDiagnostics()) {
|
||||||
if (diagnostic.getFactory() instanceof UnresolvedReferenceDiagnosticFactory) {
|
if (diagnostic.getFactory() instanceof UnresolvedReferenceDiagnosticFactory) {
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public class JetResolveTest extends ExtensibleResolveTestCase {
|
|||||||
private PsiClass findClass(String qualifiedName) {
|
private PsiClass findClass(String qualifiedName) {
|
||||||
Project project = getProject();
|
Project project = getProject();
|
||||||
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(
|
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR), project);
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, true), project);
|
||||||
return injector.getPsiClassFinderForJvm().findPsiClass(new FqName(qualifiedName), PsiClassFinder.RuntimeClassesHandleMode.THROW);
|
return injector.getPsiClassFinderForJvm().findPsiClass(new FqName(qualifiedName), PsiClassFinder.RuntimeClassesHandleMode.THROW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
|||||||
assert aClass instanceof JetClass;
|
assert aClass instanceof JetClass;
|
||||||
AnalyzeExhaust bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(file,
|
AnalyzeExhaust bindingContext = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(file,
|
||||||
JetControlFlowDataTraceFactory.EMPTY,
|
JetControlFlowDataTraceFactory.EMPTY,
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR));
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, true));
|
||||||
DeclarationDescriptor classDescriptor = bindingContext.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass);
|
DeclarationDescriptor classDescriptor = bindingContext.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass);
|
||||||
WritableScopeImpl scope = new WritableScopeImpl(libraryScope, root, RedeclarationHandler.DO_NOTHING);
|
WritableScopeImpl scope = new WritableScopeImpl(libraryScope, root, RedeclarationHandler.DO_NOTHING);
|
||||||
assert classDescriptor instanceof ClassifierDescriptor;
|
assert classDescriptor instanceof ClassifierDescriptor;
|
||||||
|
|||||||
@@ -587,7 +587,7 @@ public class JetTypeCheckerTest extends JetLiteFixture {
|
|||||||
WritableScopeImpl writableScope = new WritableScopeImpl(scope, scope.getContainingDeclaration(), RedeclarationHandler.DO_NOTHING);
|
WritableScopeImpl writableScope = new WritableScopeImpl(scope, scope.getContainingDeclaration(), RedeclarationHandler.DO_NOTHING);
|
||||||
writableScope.importScope(library.getLibraryScope());
|
writableScope.importScope(library.getLibraryScope());
|
||||||
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(
|
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(
|
||||||
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR), getProject());
|
CompileCompilerDependenciesTest.compilerDependenciesForTests(CompilerSpecialMode.REGULAR, true), getProject());
|
||||||
JavaDescriptorResolver javaDescriptorResolver = injector.getJavaDescriptorResolver();
|
JavaDescriptorResolver javaDescriptorResolver = injector.getJavaDescriptorResolver();
|
||||||
writableScope.importScope(javaDescriptorResolver.resolveNamespace(FqName.ROOT,
|
writableScope.importScope(javaDescriptorResolver.resolveNamespace(FqName.ROOT,
|
||||||
DescriptorSearchRule.INCLUDE_KOTLIN).getMemberScope());
|
DescriptorSearchRule.INCLUDE_KOTLIN).getMemberScope());
|
||||||
|
|||||||
Reference in New Issue
Block a user