From 31426985e37c217e1fee160368f43957d3185367 Mon Sep 17 00:00:00 2001 From: Alex Semin Date: Tue, 3 Dec 2024 23:08:26 +0100 Subject: [PATCH] Use @Language from java-annotations --- build.gradle.kts | 7 ++++++ .../me/alllex/parsus/external/Language.kt | 24 ------------------- .../me/alllex/parsus/token/RegexToken.kt | 2 +- 3 files changed, 8 insertions(+), 25 deletions(-) delete mode 100644 src/commonMain/kotlin/me/alllex/parsus/external/Language.kt diff --git a/build.gradle.kts b/build.gradle.kts index 220281c..cf9d5ff 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,6 +12,13 @@ version = publishVersion kotlin { sourceSets { + commonMain { + dependencies { + compileOnly("org.jetbrains:annotations:26.0.1") { + because("multiplatform @Language annotation") + } + } + } commonTest { dependencies { implementation(kotlin("test")) diff --git a/src/commonMain/kotlin/me/alllex/parsus/external/Language.kt b/src/commonMain/kotlin/me/alllex/parsus/external/Language.kt deleted file mode 100644 index 20162af..0000000 --- a/src/commonMain/kotlin/me/alllex/parsus/external/Language.kt +++ /dev/null @@ -1,24 +0,0 @@ -@file:Suppress("PackageDirectoryMismatch", "unused") - -package org.intellij.lang.annotations - -/** - * IntelliJ will inject languages into Strings when it sees this annotation. - * It's copy-pasted from https://github.com/JetBrains/java-annotations because the `@Language` - * annotation is JVM only. However, IntelliJ will still recognise it as long as the FQN matches. - */ -@Retention(AnnotationRetention.BINARY) -@Target( - AnnotationTarget.FUNCTION, - AnnotationTarget.PROPERTY_GETTER, - AnnotationTarget.PROPERTY_SETTER, - AnnotationTarget.FIELD, - AnnotationTarget.VALUE_PARAMETER, - AnnotationTarget.LOCAL_VARIABLE, - AnnotationTarget.ANNOTATION_CLASS, -) -internal annotation class Language( - val value: String, - val prefix: String = "", - val suffix: String = "", -) diff --git a/src/commonMain/kotlin/me/alllex/parsus/token/RegexToken.kt b/src/commonMain/kotlin/me/alllex/parsus/token/RegexToken.kt index 2f916b5..b8b344c 100644 --- a/src/commonMain/kotlin/me/alllex/parsus/token/RegexToken.kt +++ b/src/commonMain/kotlin/me/alllex/parsus/token/RegexToken.kt @@ -35,7 +35,7 @@ private fun Regex.withIgnoreCase(ignoreCase: Boolean) = * This token defined by a regular expression [pattern] that is expected to match the input. */ fun Grammar<*>.regexToken( - @Language("RegExp", "", "") + @Language("RegExp") pattern: String, name: String? = null, ignored: Boolean = false,