[FIR JS] Report WRONG_JS_QUALIFIER for the argument of JsQualifier

This commit is contained in:
Nikolay Lunyak
2023-01-03 13:38:57 +02:00
committed by Space Team
parent 73c89a5d9d
commit f422a3a4e8
21 changed files with 139 additions and 31 deletions
+15
View File
@@ -0,0 +1,15 @@
plugins {
kotlin("jvm")
id("jps-compatible")
}
project.configureJvmToolchain(JdkMajorVersion.JDK_1_8)
dependencies {
api(project(":core:compiler.common"))
}
sourceSets {
"main" { projectDefault() }
"test" {}
}
@@ -0,0 +1,15 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.js
fun validateQualifier(qualifier: String): Boolean {
val parts = qualifier.split('.')
if (parts.isEmpty()) return false
return parts.all { part ->
part.isNotEmpty() && part[0].isJavaIdentifierStart() && part.drop(1).all(Char::isJavaIdentifierPart)
}
}
@@ -0,0 +1,18 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.name
import org.jetbrains.kotlin.name.StandardClassIds.BASE_KOTLIN_PACKAGE
object JsStandardClassIds {
val BASE_JS_PACKAGE = BASE_KOTLIN_PACKAGE.child(Name.identifier("js"))
object Annotations {
val JsQualifier = "JsQualifier".jsId()
}
}
private fun String.jsId() = ClassId(JsStandardClassIds.BASE_JS_PACKAGE, Name.identifier(this))