[BT] Introduce CompilationResult

#KT-57398 In Progress
This commit is contained in:
Alexander.Likhachev
2023-06-27 16:01:23 +02:00
committed by Space Team
parent 754f4830b9
commit b3fbe4c484
4 changed files with 58 additions and 3 deletions
@@ -1,7 +1,16 @@
public final class org/jetbrains/kotlin/buildtools/api/CompilationResult : java/lang/Enum {
public static final field COMPILATION_ERROR Lorg/jetbrains/kotlin/buildtools/api/CompilationResult;
public static final field COMPILATION_OOM_ERROR Lorg/jetbrains/kotlin/buildtools/api/CompilationResult;
public static final field COMPILATION_SUCCESS Lorg/jetbrains/kotlin/buildtools/api/CompilationResult;
public static final field COMPILER_INTERNAL_ERROR Lorg/jetbrains/kotlin/buildtools/api/CompilationResult;
public static fun valueOf (Ljava/lang/String;)Lorg/jetbrains/kotlin/buildtools/api/CompilationResult;
public static fun values ()[Lorg/jetbrains/kotlin/buildtools/api/CompilationResult;
}
public abstract interface class org/jetbrains/kotlin/buildtools/api/CompilationService {
public static final field Companion Lorg/jetbrains/kotlin/buildtools/api/CompilationService$Companion;
public abstract fun calculateClasspathSnapshot (Ljava/io/File;)Lorg/jetbrains/kotlin/buildtools/api/jvm/ClasspathEntrySnapshot;
public abstract fun compileJvm (Lorg/jetbrains/kotlin/buildtools/api/CompilerExecutionStrategyConfiguration;Lorg/jetbrains/kotlin/buildtools/api/jvm/JvmCompilationConfiguration;Ljava/util/List;Ljava/util/List;)V
public abstract fun compileJvm (Lorg/jetbrains/kotlin/buildtools/api/CompilerExecutionStrategyConfiguration;Lorg/jetbrains/kotlin/buildtools/api/jvm/JvmCompilationConfiguration;Ljava/util/List;Ljava/util/List;)Lorg/jetbrains/kotlin/buildtools/api/CompilationResult;
public static fun loadImplementation (Ljava/lang/ClassLoader;)Lorg/jetbrains/kotlin/buildtools/api/CompilationService;
public abstract fun makeCompilerExecutionStrategyConfiguration ()Lorg/jetbrains/kotlin/buildtools/api/CompilerExecutionStrategyConfiguration;
public abstract fun makeJvmCompilationConfiguration ()Lorg/jetbrains/kotlin/buildtools/api/jvm/JvmCompilationConfiguration;
@@ -0,0 +1,44 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.buildtools.api
/**
* Represents the result of a compilation process.
*
* This enum is used as the return value of compilation methods to indicate the status of the compilation process.
*/
public enum class CompilationResult {
/**
* Represents a successful compilation state.
*/
COMPILATION_SUCCESS,
/**
* Represents an error that occurs during compilation of code.
* Usage:
* The object of this class should be used when an error occurs during the compilation of code. It can be used to
* identify and handle such errors during runtime.
*/
COMPILATION_ERROR,
/**
* Represents a compilation error caused by running out of memory.
*
* This error is thrown when the compilation process has run out of memory and was unable to complete. This can occur when
* the compilation task requires more memory than is available to the operating system or allocated to the process.
*
* This error should be handled by allocating more memory to the process or optimizing the compilation task to require
* less memory.
*/
COMPILATION_OOM_ERROR,
/**
* Represents an internal error that occurs within the compiler.
*
* This error should be [reported](https://kotl.in/issue) to the compiler developers for investigation and resolution.
*/
COMPILER_INTERNAL_ERROR,
}
@@ -53,7 +53,7 @@ public interface CompilationService {
compilationConfig: JvmCompilationConfiguration,
sources: List<File>,
arguments: List<String>
)
): CompilationResult
@ExperimentalBuildToolsApi
public companion object {
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.buildtools.internal
import org.jetbrains.kotlin.buildtools.api.CompilationResult
import org.jetbrains.kotlin.buildtools.api.CompilationService
import org.jetbrains.kotlin.buildtools.api.CompilerExecutionStrategyConfiguration
import org.jetbrains.kotlin.buildtools.api.jvm.*
@@ -24,7 +25,8 @@ internal class CompilationServiceImpl : CompilationService {
compilationConfig: JvmCompilationConfiguration,
sources: List<File>,
arguments: List<String>
) {
): CompilationResult {
println("I'm simulating compilation, nothing more yet")
return CompilationResult.COMPILATION_SUCCESS
}
}