Cleaup context building API
This commit is contained in:
parent
874a253292
commit
53393e7958
@ -38,7 +38,8 @@ public final class space/kscience/dataforge/context/ClassLoaderPluginKt {
|
||||
public class space/kscience/dataforge/context/Context : kotlinx/coroutines/CoroutineScope, space/kscience/dataforge/meta/MetaRepr, space/kscience/dataforge/misc/Named, space/kscience/dataforge/provider/Provider {
|
||||
public static final field Companion Lspace/kscience/dataforge/context/Context$Companion;
|
||||
public static final field PROPERTY_TARGET Ljava/lang/String;
|
||||
public final fun buildContext (Lkotlin/jvm/functions/Function1;)Lspace/kscience/dataforge/context/Context;
|
||||
public final fun buildContext (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/dataforge/context/Context;
|
||||
public static synthetic fun buildContext$default (Lspace/kscience/dataforge/context/Context;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/dataforge/context/Context;
|
||||
public fun close ()V
|
||||
public fun content (Ljava/lang/String;)Ljava/util/Map;
|
||||
public final fun content (Ljava/lang/String;Z)Ljava/util/Map;
|
||||
@ -102,8 +103,8 @@ public final class space/kscience/dataforge/context/Factory$DefaultImpls {
|
||||
}
|
||||
|
||||
public final class space/kscience/dataforge/context/GlobalKt {
|
||||
public static final fun Context (Lkotlin/jvm/functions/Function1;)Lspace/kscience/dataforge/context/Context;
|
||||
public static synthetic fun Context$default (Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/dataforge/context/Context;
|
||||
public static final fun Context (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)Lspace/kscience/dataforge/context/Context;
|
||||
public static synthetic fun Context$default (Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lspace/kscience/dataforge/context/Context;
|
||||
public static final fun getGlobal ()Lspace/kscience/dataforge/context/Context;
|
||||
}
|
||||
|
||||
|
@ -76,8 +76,11 @@ public open class Context internal constructor(
|
||||
* Build and register a child context
|
||||
*/
|
||||
@Synchronized
|
||||
public fun buildContext(block: ContextBuilder.() -> Unit): Context{
|
||||
val newContext = ContextBuilder(this).apply(block).build()
|
||||
public fun buildContext(name: String? = null, block: ContextBuilder.() -> Unit): Context {
|
||||
val newContext = ContextBuilder(this)
|
||||
.apply { name?.let { name(it) } }
|
||||
.apply(block)
|
||||
.build()
|
||||
childrenContexts[newContext.name] = newContext
|
||||
return newContext
|
||||
}
|
||||
|
@ -19,4 +19,5 @@ private object GlobalContext : Context("GLOBAL".asName(), null, Meta.EMPTY) {
|
||||
|
||||
public val Global: Context get() = GlobalContext
|
||||
|
||||
public fun Context(block: ContextBuilder.() -> Unit = {}): Context = Global.buildContext(block)
|
||||
public fun Context(name: String? = null, block: ContextBuilder.() -> Unit = {}): Context =
|
||||
Global.buildContext(name, block)
|
@ -51,7 +51,7 @@ public class WorkspaceBuilder(private val parentContext: Context = Global) : Tas
|
||||
* Define a context for the workspace
|
||||
*/
|
||||
public fun context(block: ContextBuilder.() -> Unit = {}) {
|
||||
this.context = parentContext.buildContext(block)
|
||||
this.context = parentContext.buildContext("workspace", block)
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user