commonMain.pro.felixo.protobuf.schemadocument.validation.ValidationScope.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protobuf-kotlin-schemadocument-jvm Show documentation
Show all versions of protobuf-kotlin-schemadocument-jvm Show documentation
Protocol Buffers 3 support for Kotlin Multiplatform
The newest version!
package pro.felixo.protobuf.schemadocument.validation
import pro.felixo.protobuf.schemadocument.SchemaElement
data class ValidationScope(
val element: SchemaElement,
val parent: ValidationScope?
) {
override fun toString(): String =
(parent?.toString()?.let { "$it -> " } ?: "") + element.elementType + " " + element.elementName
}
fun ValidationScope.sub(element: SchemaElement) = ValidationScope(element, this)
fun rootValidationScope(
element: SchemaElement,
block: ValidationScope.() -> T
): T = ValidationScope(element, null).block()
fun ValidationScope.validationScope(
element: SchemaElement,
block: ValidationScope.() -> T
): T = sub(element).block()