Search in sources :

Example 11 with CompilerConfiguration

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);
}
Also used : Disposable(com.intellij.openapi.Disposable) KotlinCoreEnvironment(org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment) CompilerConfiguration(org.jetbrains.kotlin.config.CompilerConfiguration) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with CompilerConfiguration

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);
}
Also used : Disposable(com.intellij.openapi.Disposable) KotlinCoreEnvironment(org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment) CompilerConfiguration(org.jetbrains.kotlin.config.CompilerConfiguration) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with CompilerConfiguration

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());
}
Also used : CompilerConfiguration(org.jetbrains.kotlin.config.CompilerConfiguration)

Example 14 with CompilerConfiguration

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);
            }
        }
    });
}
Also used : PositionManager(com.intellij.debugger.PositionManager) ArrayList(java.util.ArrayList) GenerationState(org.jetbrains.kotlin.codegen.state.GenerationState) ReferenceType(com.sun.jdi.ReferenceType) Project(com.intellij.openapi.project.Project) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) PackagePartProvider(org.jetbrains.kotlin.descriptors.PackagePartProvider) CompilerConfiguration(org.jetbrains.kotlin.config.CompilerConfiguration) KtFile(org.jetbrains.kotlin.psi.KtFile) NoDataException(com.intellij.debugger.NoDataException)

Example 15 with CompilerConfiguration

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);
}
Also used : CompilerConfiguration(org.jetbrains.kotlin.config.CompilerConfiguration) ArrayList(java.util.ArrayList) LibrarySourcesConfig(org.jetbrains.kotlin.js.config.LibrarySourcesConfig) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

CompilerConfiguration (org.jetbrains.kotlin.config.CompilerConfiguration)15 KotlinCoreEnvironment (org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment)8 File (java.io.File)7 NotNull (org.jetbrains.annotations.NotNull)6 KtFile (org.jetbrains.kotlin.psi.KtFile)5 Disposable (com.intellij.openapi.Disposable)4 ArrayList (java.util.ArrayList)4 AnalysisResult (org.jetbrains.kotlin.analyzer.AnalysisResult)3 GenerationState (org.jetbrains.kotlin.codegen.state.GenerationState)3 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)2 FqName (org.jetbrains.kotlin.name.FqName)2 NoDataException (com.intellij.debugger.NoDataException)1 PositionManager (com.intellij.debugger.PositionManager)1 Project (com.intellij.openapi.project.Project)1 ReferenceType (com.sun.jdi.ReferenceType)1 FileFilter (java.io.FileFilter)1 JarFile (java.util.jar.JarFile)1 ZipEntry (java.util.zip.ZipEntry)1 PrintingMessageCollector (org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector)1 CliLightClassGenerationSupport (org.jetbrains.kotlin.cli.jvm.compiler.CliLightClassGenerationSupport)1