Implement SamWithReceiverAnnotations annotation and it's handling (KT-15848)
TODO: tests
This commit is contained in:
+8
-3
@@ -63,6 +63,10 @@ open class KotlinScriptDefinitionFromAnnotatedTemplate(
|
||||
}
|
||||
}
|
||||
|
||||
val samWithReceiverAnnotations: List<String>? by lazy {
|
||||
template.annotations.firstIsInstanceOrNull<SamWithReceiverAnnotations>()?.annotations?.toList()
|
||||
}
|
||||
|
||||
private val acceptedAnnotations: List<KClass<out Annotation>> by lazy {
|
||||
val resolveMethod = ScriptDependenciesResolver::resolve
|
||||
val resolverMethodAnnotations =
|
||||
@@ -146,9 +150,10 @@ open class KotlinScriptDefinitionFromAnnotatedTemplate(
|
||||
override val text: CharSequence? by lazy { getFileContents(myFile) }
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "KotlinScriptDefinitionFromAnnotatedTemplate - ${template.simpleName}"
|
||||
}
|
||||
override fun toString(): String = "KotlinScriptDefinitionFromAnnotatedTemplate - ${template.simpleName}"
|
||||
|
||||
override val annotationsForSamWithReceivers: List<String>
|
||||
get() = samWithReceiverAnnotations ?: super.annotationsForSamWithReceivers
|
||||
|
||||
companion object {
|
||||
internal val log = Logger.getInstance(KotlinScriptDefinitionFromAnnotatedTemplate::class.java)
|
||||
|
||||
@@ -30,6 +30,10 @@ const val DEFAULT_SCRIPT_FILE_PATTERN = ".*\\.kts"
|
||||
annotation class ScriptTemplateDefinition(val resolver: KClass<out ScriptDependenciesResolver> = BasicScriptDependenciesResolver::class,
|
||||
val scriptFilePattern: String = DEFAULT_SCRIPT_FILE_PATTERN)
|
||||
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class SamWithReceiverAnnotations(vararg val annotations: String)
|
||||
|
||||
interface ScriptContents {
|
||||
|
||||
data class Position(val line: Int, val col: Int)
|
||||
|
||||
Reference in New Issue
Block a user