Add support for IntelliJ cron tab feature

This commit is contained in:
Michael Rittmeister 2024-06-16 16:33:55 +02:00
parent f90d8d03d9
commit e5b33ae9b0
No known key found for this signature in database
GPG Key ID: 20ED60DB80559DEB
3 changed files with 19 additions and 9 deletions

View File

@ -7,7 +7,6 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlin.coroutines.coroutineContext
/**
* Execute [block] once at the [KronScheduler.next] time and return result of [block] calculation.
*
@ -53,7 +52,7 @@ suspend inline fun <T> KronScheduler.doOnceTz(noinline block: suspend (DateTimeT
* @see buildSchedule
*/
suspend inline fun <T> doOnce(
scheduleConfig: String,
@Language("CronExp") scheduleConfig: String,
block: (DateTime) -> T
) = buildSchedule(scheduleConfig).doOnce(block)
@ -62,7 +61,7 @@ suspend inline fun <T> doOnce(
* @see buildSchedule
*/
suspend inline fun <T> doOnceTz(
scheduleConfig: String,
@Language("CronExp") scheduleConfig: String,
noinline block: suspend (DateTimeTz) -> T
) = buildSchedule(scheduleConfig).doOnceTz(block)
@ -114,7 +113,7 @@ suspend inline fun KronScheduler.doWhileTz(noinline block: suspend (DateTimeTz)
* @see buildSchedule
*/
suspend inline fun doWhile(
scheduleConfig: String,
@Language("CronExp") scheduleConfig: String,
block: (DateTime) -> Boolean
) = buildSchedule(scheduleConfig).doWhile(block)
@ -125,7 +124,7 @@ suspend inline fun doWhile(
*/
@Deprecated("Replaceable", ReplaceWith("doWhile", "dev.inmo.krontab.doWhile"))
suspend inline fun doWhileLocal(
scheduleConfig: String,
@Language("CronExp") scheduleConfig: String,
block: (DateTime) -> Boolean
) = doWhile(scheduleConfig, block)
@ -135,7 +134,7 @@ suspend inline fun doWhileLocal(
* @see buildSchedule
*/
suspend inline fun doWhileTz(
scheduleConfig: String,
@Language("CronExp") scheduleConfig: String,
noinline block: suspend (DateTimeTz) -> Boolean
) = buildSchedule(scheduleConfig).doWhileTz(block)
@ -167,7 +166,7 @@ suspend inline fun KronScheduler.doInfinityTz(noinline block: suspend (DateTimeT
* @see buildSchedule
*/
suspend inline fun doInfinity(
scheduleConfig: String,
@Language("CronExp") scheduleConfig: String,
block: (DateTime) -> Unit
) = buildSchedule(scheduleConfig).doInfinity(block)
@ -178,7 +177,7 @@ suspend inline fun doInfinity(
*/
@Deprecated("Replaceable", ReplaceWith("doInfinity", "dev.inmo.krontab.doInfinity"))
suspend inline fun doInfinityLocal(
scheduleConfig: String,
@Language("CronExp") scheduleConfig: String,
block: (DateTime) -> Unit
) = doInfinity(scheduleConfig, block)
@ -188,6 +187,6 @@ suspend inline fun doInfinityLocal(
* @see buildSchedule
*/
suspend inline fun doInfinityTz(
scheduleConfig: String,
@Language("CronExp") scheduleConfig: String,
noinline block: suspend (DateTimeTz) -> Unit
) = buildSchedule(scheduleConfig).doInfinityTz(block)

View File

@ -0,0 +1,6 @@
package dev.inmo.krontab
import kotlin.OptionalExpectation
@OptionalExpectation
internal expect annotation class Language(val value: String, val prefix: String = "", val suffix: String = "")

View File

@ -0,0 +1,5 @@
package dev.inmo.krontab
import org.intellij.lang.annotations.Language
actual typealias Language = Language