use of org.jetbrains.kotlin.config.CompilerConfiguration 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.config.CompilerConfiguration 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);
}
use of org.jetbrains.kotlin.config.CompilerConfiguration in project kotlin by JetBrains.
the class KotlinMultiFileTestWithJava method createEnvironment.
@Override
protected KotlinCoreEnvironment createEnvironment() throws Exception {
// TODO: do not create temporary directory for tests without Java sources
javaFilesDir = KotlinTestUtils.tmpDir("java-files");
CompilerConfiguration configuration = KotlinTestUtils.newConfiguration(getConfigurationKind(), getTestJdkKind(), CollectionsKt.plus(Collections.singletonList(KotlinTestUtils.getAnnotationsJar()), getExtraClasspath()), Collections.singletonList(javaFilesDir));
configuration.add(JVMConfigurationKeys.SCRIPT_DEFINITIONS, StandardScriptDefinition.INSTANCE);
if (isKotlinSourceRootNeeded()) {
kotlinSourceRoot = KotlinTestUtils.tmpDir("kotlin-src");
ContentRootsKt.addKotlinSourceRoot(configuration, kotlinSourceRoot.getPath());
}
return KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, getEnvironmentConfigFiles());
}
use of org.jetbrains.kotlin.config.CompilerConfiguration in project kotlin by JetBrains.
the class AbstractPositionManagerTest method performTest.
private void performTest() {
Project project = getProject();
List<KtFile> files = new ArrayList<KtFile>(PluginJetFilesProvider.allFilesInProject(project));
if (files.isEmpty())
return;
final List<Breakpoint> breakpoints = Lists.newArrayList();
for (KtFile file : files) {
breakpoints.addAll(extractBreakpointsInfo(file, file.getText()));
}
CompilerConfiguration configuration = KotlinTestUtils.newConfiguration(ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK);
// TODO: delete this once IDEVirtualFileFinder supports loading .kotlin_builtins files
configuration.put(JVMConfigurationKeys.ADD_BUILT_INS_FROM_COMPILER_TO_DEPENDENCIES, true);
GenerationState state = GenerationUtils.compileFiles(files, configuration, new Function1<GlobalSearchScope, PackagePartProvider>() {
@Override
public PackagePartProvider invoke(GlobalSearchScope scope) {
return PackagePartProvider.Empty.INSTANCE;
}
});
Map<String, ReferenceType> referencesByName = getReferenceMap(state.getFactory());
debugProcess = createDebugProcess(referencesByName);
final PositionManager positionManager = createPositionManager(debugProcess, files, state);
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
try {
for (Breakpoint breakpoint : breakpoints) {
assertBreakpointIsHandledCorrectly(breakpoint, positionManager);
}
} catch (NoDataException e) {
throw ExceptionUtilsKt.rethrow(e);
}
}
});
}
use of org.jetbrains.kotlin.config.CompilerConfiguration in project kotlin by JetBrains.
the class BasicTest method createConfig.
@NotNull
private JsConfig createConfig(@NotNull Project project, @NotNull String moduleName, @NotNull EcmaVersion ecmaVersion, @Nullable List<String> libraries, @NotNull List<KtFile> files) {
CompilerConfiguration configuration = getEnvironment().getConfiguration().copy();
configuration.put(CommonConfigurationKeys.DISABLE_INLINE, hasNoInline(files));
List<String> librariesWithStdlib = new ArrayList<String>(LibrarySourcesConfig.JS_STDLIB);
if (libraries != null) {
librariesWithStdlib.addAll(libraries);
}
librariesWithStdlib.add(getKotlinPathsForDistDirectory().getJsKotlinTestJarPath().getAbsolutePath());
configuration.put(JSConfigurationKeys.LIBRARIES, librariesWithStdlib);
configuration.put(CommonConfigurationKeys.MODULE_NAME, moduleName);
configuration.put(JSConfigurationKeys.TARGET, ecmaVersion);
configuration.put(JSConfigurationKeys.SOURCE_MAP, shouldGenerateSourceMap());
configuration.put(JSConfigurationKeys.META_INFO, false);
configuration.put(JSConfigurationKeys.UNIT_TEST_CONFIG, shouldBeTranslateAsUnitTestClass());
return new LibrarySourcesConfig(project, configuration);
}
Aggregations