All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlinx.jupyter.libraries.DescriptorOptionsParsing.kt Maven / Gradle / Ivy

Go to download

Implementation of REPL compiler and preprocessor for Jupyter dialect of Kotlin (IDE-compatible)

There is a newer version: 0.12.0-333
Show newest version
package org.jetbrains.kotlinx.jupyter.libraries

import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationException
import kotlinx.serialization.Transient
import kotlinx.serialization.json.Json
import org.jetbrains.kotlinx.jupyter.exceptions.ReplException

@Serializable
@Suppress("CanBeParameter")
class LibraryDescriptorGlobalOptionsImpl(
    private val ignoredPropertyPatterns: List?,
) : LibraryDescriptorGlobalOptions {
    @Transient
    private val ignoredPropertyRegExps = ignoredPropertyPatterns.orEmpty().map { Regex(it) }

    override fun isPropertyIgnored(propertyName: String): Boolean {
        return ignoredPropertyRegExps.any { it.matches(propertyName) }
    }
}

fun parseLibraryDescriptorGlobalOptions(json: String): LibraryDescriptorGlobalOptions {
    return try {
        Json.decodeFromString(json)
    } catch (e: SerializationException) {
        throw ReplException("Error during descriptor global options deserialization. Options text:\n$json", e)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy