use of org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment in project kotlin by JetBrains.
the class KotlinTestUtils method compileKotlinWithJava.
public static void compileKotlinWithJava(@NotNull List<File> javaFiles, @NotNull List<File> ktFiles, @NotNull File outDir, @NotNull Disposable disposable, @Nullable File javaErrorFile) throws IOException {
if (!ktFiles.isEmpty()) {
KotlinCoreEnvironment environment = createEnvironmentWithMockJdkAndIdeaAnnotations(disposable);
LoadDescriptorUtil.compileKotlinToDirAndGetModule(ktFiles, outDir, environment);
} else {
boolean mkdirs = outDir.mkdirs();
assert mkdirs : "Not created: " + outDir;
}
if (!javaFiles.isEmpty()) {
compileJavaFiles(javaFiles, Arrays.asList("-classpath", outDir.getPath() + File.pathSeparator + ForTestCompileRuntime.runtimeJarForTests(), "-d", outDir.getPath()), javaErrorFile);
}
}
use of org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment in project kotlin by JetBrains.
the class AbstractBlackBoxCodegenTest method doLightAnalysisModeTest.
private void doLightAnalysisModeTest(@NotNull File wholeFile, @NotNull List<TestFile> files, @Nullable File javaFilesDir) {
if (SKIP_LIGHT_ANALYSIS_MODE_TESTS)
return;
File boxTestsDir = new File("compiler/testData/codegen/box");
String relativePath = FilesKt.toRelativeString(wholeFile, boxTestsDir);
// Do nothing if this test is not under codegen/box
if (relativePath.startsWith(".."))
return;
String outDir = new File("compiler/testData/codegen/light-analysis", relativePath).getParent();
File txtFile = new File(outDir, FilesKt.getNameWithoutExtension(wholeFile) + ".txt");
AbstractBytecodeListingTest.doTest(getTestRootDisposable(), files, javaFilesDir, txtFile, ClassBuilderFactories.TEST_KAPT3, new Function1<KotlinCoreEnvironment, Unit>() {
@Override
public Unit invoke(KotlinCoreEnvironment environment) {
AnalysisHandlerExtension.Companion.registerExtension(environment.getProject(), new PartialAnalysisHandlerExtension());
return Unit.INSTANCE;
}
});
}
use of org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment in project kotlin by JetBrains.
the class AbstractCompileKotlinAgainstKotlinTest method compileA.
@NotNull
private ClassFileFactory compileA(@NotNull TestFile testFile, List<TestFile> files) throws IOException {
Disposable compileDisposable = createDisposable("compileA");
CompilerConfiguration configuration = createConfiguration(ConfigurationKind.ALL, getJdkKind(files), Collections.singletonList(KotlinTestUtils.getAnnotationsJar()), Collections.<File>emptyList(), Collections.singletonList(testFile));
KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests(compileDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
return compileKotlin(testFile.name, testFile.content, aDir, environment, compileDisposable);
}
use of org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment in project kotlin by JetBrains.
the class AbstractCompileKotlinAgainstKotlinTest method compileB.
@NotNull
private ClassFileFactory compileB(@NotNull TestFile testFile, List<TestFile> files) throws IOException {
CompilerConfiguration configurationWithADirInClasspath = createConfiguration(ConfigurationKind.ALL, getJdkKind(files), Lists.newArrayList(KotlinTestUtils.getAnnotationsJar(), aDir), Collections.<File>emptyList(), Collections.singletonList(testFile));
Disposable compileDisposable = createDisposable("compileB");
KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests(compileDisposable, configurationWithADirInClasspath, EnvironmentConfigFiles.JVM_CONFIG_FILES);
return compileKotlin(testFile.name, testFile.content, bDir, environment, compileDisposable);
}
Aggregations