Refactor scripting properties:
- flatten the structure - add some parameters - replace iterables with lists - renaming all scope objects uniformily also: - fix passing and usage of script sources - renamings and other minor improvements
This commit is contained in:
+6
-3
@@ -3,10 +3,13 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
|
||||
package kotlin.script.experimental.api
|
||||
|
||||
object ProcessedScriptDataParams {
|
||||
val annotations by typedKey<Iterable<Annotation>>()
|
||||
object ProcessedScriptDataProperties {
|
||||
val foundAnnotations by typedKey<List<Annotation>>()
|
||||
|
||||
val fragments by typedKey<Iterable<ScriptSourceNamedFragment>>()
|
||||
val foundFragments by typedKey<List<ScriptSourceNamedFragment>>()
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ interface ScriptCompilationConfigurator {
|
||||
suspend fun baseConfiguration(scriptSource: ScriptSource): ResultWithDiagnostics<ScriptCompileConfiguration>
|
||||
|
||||
suspend fun refineConfiguration(
|
||||
scriptSource: ScriptSource,
|
||||
configuration: ScriptCompileConfiguration,
|
||||
processedScriptData: ProcessedScriptData = ProcessedScriptData()
|
||||
): ResultWithDiagnostics<ScriptCompileConfiguration>
|
||||
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
|
||||
package kotlin.script.experimental.api
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
object ScriptCompileConfigurationParams {
|
||||
|
||||
val baseClass by typedKey<KClass<*>>()
|
||||
|
||||
val scriptSourceFragments by typedKey<ScriptSourceFragments>()
|
||||
|
||||
val scriptSignature by typedKey<ScriptSignature>()
|
||||
|
||||
val importedPackages by typedKey<Iterable<String>>()
|
||||
|
||||
val restrictions by typedKey<ResolvingRestrictions>()
|
||||
|
||||
val importedScripts by typedKey<Iterable<ScriptSource>>()
|
||||
|
||||
val dependencies by typedKey<Iterable<ScriptDependency>>()
|
||||
|
||||
val compilerOptions by typedKey<Iterable<String>>() // Q: CommonCompilerOptions instead?
|
||||
|
||||
val updateConfigurationOnAnnotations by typedKey<Iterable<KClass<out Annotation>>>()
|
||||
|
||||
val updateConfigurationOnSections by typedKey<Iterable<String>>()
|
||||
}
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
|
||||
package kotlin.script.experimental.api
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.KType
|
||||
|
||||
object ScriptCompileConfigurationProperties {
|
||||
|
||||
val sourceFragments by typedKey<List<ScriptSourceNamedFragment>>()
|
||||
|
||||
val baseClass = ScriptingEnvironmentProperties.baseClass
|
||||
|
||||
val scriptBodyTarget by typedKey<ScriptBodyTarget>()
|
||||
|
||||
val scriptImplicitReceivers by typedKey<List<KType>>() // in the order from outer to inner scope
|
||||
|
||||
val contextVariables by typedKey<Map<String, KType>>() // external variables
|
||||
|
||||
val importedPackages by typedKey<List<String>>()
|
||||
|
||||
val restrictions by typedKey<List<ResolvingRestrictionRule>>()
|
||||
|
||||
val importedScripts by typedKey<List<ScriptSource>>()
|
||||
|
||||
val dependencies by typedKey<List<ScriptDependency>>()
|
||||
|
||||
val compilerOptions by typedKey<List<String>>() // Q: CommonCompilerOptions instead?
|
||||
|
||||
val updateConfigurationOnAnnotations by typedKey<List<KClass<out Annotation>>>()
|
||||
|
||||
val updateConfigurationOnSections by typedKey<List<String>>()
|
||||
}
|
||||
|
||||
@@ -22,37 +22,22 @@ interface ScriptSource {
|
||||
|
||||
data class ScriptSourceNamedFragment(val name: String?, val range: ScriptSource.Range)
|
||||
|
||||
open class ScriptSourceFragments(
|
||||
val originalSource: ScriptSource,
|
||||
val fragments: List<ScriptSourceNamedFragment>?)
|
||||
|
||||
open class ProvidedDeclarations(
|
||||
val implicitReceivers: List<KType> = emptyList(), // previous scripts, etc.
|
||||
val contextVariables: Map<String, KType> = emptyMap() // external variables
|
||||
// Q: do we need context constants and/or types here, e.g.
|
||||
// val contextConstants: Map<String, Any?> // or with KType as well
|
||||
// val contextTypes: List<KType> // additional (to the classpath) types provided by the environment
|
||||
// alternatively:
|
||||
// val contextDeclarations: List<Tuple<DeclarationKind, String?, KType, Any?> // kind, name, type, value
|
||||
// OR: it should be a HeterogeneousMap too
|
||||
) {
|
||||
object Empty : ProvidedDeclarations()
|
||||
enum class ScriptBodyTarget {
|
||||
Constructor,
|
||||
SingleAbstractMethod
|
||||
}
|
||||
|
||||
open class ScriptSignature(
|
||||
val scriptBase: KClass<*>,
|
||||
val providedDeclarations: ProvidedDeclarations
|
||||
)
|
||||
|
||||
open class ResolvingRestrictions {
|
||||
data class Rule(
|
||||
val allow: Boolean,
|
||||
val pattern: String // FQN wildcard
|
||||
)
|
||||
|
||||
val rules: Iterable<Rule> = arrayListOf()
|
||||
data class ResolvingRestrictionRule(
|
||||
val action: Action,
|
||||
val pattern: String // FQN wildcard
|
||||
) {
|
||||
enum class Action {
|
||||
Allow,
|
||||
Deny
|
||||
}
|
||||
}
|
||||
|
||||
interface ScriptDependency {
|
||||
// Q: anything generic here?
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -9,8 +9,8 @@ package kotlin.script.experimental.api
|
||||
|
||||
object ScriptDefinitionProperties {
|
||||
|
||||
val name by typedKey<String>()
|
||||
val name by typedKey<String>() // Name of the script type, by default "Kotlin script"
|
||||
|
||||
val fileExtension by typedKey<String>()
|
||||
val fileExtension by typedKey<String>() // default: "kts"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user