All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.ure.UreKotlin.kt Maven / Gradle / Ivy

There is a newer version: 0.0.87
Show newest version
package pl.mareklangiewicz.ure

import pl.mareklangiewicz.annotations.DelicateApi
import pl.mareklangiewicz.annotations.NotPortableApi
import pl.mareklangiewicz.ure.core.Ure
import kotlin.text.RegexOption.*

fun urePackageLine(withNamePrefix: String = "ktPackage") = ureKtKeywordLine("package", withNamePrefix)
fun ureImportLine(withNamePrefix: String = "ktImport") = ureKtKeywordLine("import", withNamePrefix)

fun ureKtKeywordLine(keyword: String, withNamePrefix: String = keyword) =
  ureLineWithContent(
    ureKeywordAndOptArg(
      keyword = keyword,
      arg = ureChain(ureIdent(), chDot).withName(withNamePrefix + "Name"),
    ),
  ).withName(withNamePrefix + "Line")


@OptIn(DelicateApi::class, NotPortableApi::class)
private val ureLicenceMarker = (ureText("licence") or ureText("copyright")).withOptionsEnabled(IGNORE_CASE)

fun ureLicenceComment(licenceMarker: Ure = ureLicenceMarker, withName: String = "ktLicenceComment") = ure {
  +ureWhateva()
  +licenceMarker
  +ureWhateva()
}.commentedOut(traditional = true).withName(withName)

fun ureKtComposeTestOutline() = ure {
  +ureLicenceComment().withOptSpacesAround()
  +ureWhateva(reluctant = false).withName("ktOtherStuffBeforePackageLine")
  +urePackageLine().withOptSpacesAround()
  +ureWhateva(reluctant = false).withName("ktRest")
}

fun ureKtOutline(withNamePrefix: String = "ktPart") = ure {
  TODO("NOW")
}






© 2015 - 2024 Weber Informatics LLC | Privacy Policy