-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add global pkl functions and vals
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package dev.fruxz.ascend.extension.pkl | ||
|
||
import org.pkl.config.java.ConfigEvaluator | ||
import org.pkl.config.java.ConfigEvaluatorBuilder | ||
import org.pkl.config.kotlin.forKotlin | ||
|
||
/** | ||
* This lazily computed value returns a Kotlin instance of | ||
* the apple/pkl ConfigEvaluator preconfigured instance. | ||
* @see ConfigEvaluator | ||
* @see ConfigEvaluatorBuilder | ||
* @see forKotlin | ||
* @author Fruxz | ||
* @since 2024.2 | ||
*/ | ||
val pkl by lazy { ConfigEvaluator.preconfigured().forKotlin() } | ||
|
||
/** | ||
* This function builds a new Kotlin instance of the apple/pkl ConfigEvaluator | ||
* using the preconfigured() function and applies the [builder] function to it. | ||
* @see ConfigEvaluator | ||
* @see ConfigEvaluatorBuilder | ||
* @see forKotlin | ||
* @param builder the function to apply to the preconfigured ConfigEvaluatorBuilder | ||
* @return the new Kotlin instance of the ConfigEvaluator | ||
* @author Fruxz | ||
* @since 2024.2 | ||
*/ | ||
fun buildPkl(builder: ConfigEvaluatorBuilder.() -> Unit) = ConfigEvaluatorBuilder.preconfigured().apply(builder).forKotlin() | ||
|
||
/** | ||
* This function builds a new Kotlin instance of the apple/pkl ConfigEvaluator | ||
* using the unconfigured() function and applies the [builder] function to it. | ||
* @see ConfigEvaluator | ||
* @see ConfigEvaluatorBuilder | ||
* @see forKotlin | ||
* @param builder the function to apply to the unconfigured ConfigEvaluatorBuilder | ||
* @return the new Kotlin instance of the ConfigEvaluator | ||
* @author Fruxz | ||
* @since 2024.2 | ||
*/ | ||
fun buildUnconfiguredPkl(builder: ConfigEvaluatorBuilder.() -> Unit) = ConfigEvaluatorBuilder.unconfigured().apply(builder).forKotlin() |