Avoid computing AST for IdentifierChecker
Basically, it's unnecessary to check anything when analysing stubs, but it's complicated now to avoid that, so we just postpone computing AST until reporting happens
This commit is contained in:
+5
-4
@@ -16,19 +16,20 @@
|
||||
|
||||
package org.jetbrains.kotlin.js.resolve.diagnostics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.js.naming.NameSuggestion
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
||||
import org.jetbrains.kotlin.resolve.IdentifierChecker
|
||||
|
||||
object JsIdentifierChecker : IdentifierChecker {
|
||||
override fun checkIdentifier(identifier: PsiElement?, diagnosticHolder: DiagnosticSink) {
|
||||
if (identifier == null) return
|
||||
override fun checkIdentifier(simpleNameExpression: KtSimpleNameExpression, diagnosticHolder: DiagnosticSink) {
|
||||
val simpleName = simpleNameExpression.getReferencedName()
|
||||
|
||||
val hasIllegalChars = identifier.text.split('.').any { NameSuggestion.sanitizeName(it) != it }
|
||||
val hasIllegalChars = simpleName.split('.').any { NameSuggestion.sanitizeName(it) != it }
|
||||
if (hasIllegalChars) {
|
||||
val identifier = simpleNameExpression.getIdentifier() ?: return
|
||||
diagnosticHolder.report(Errors.INVALID_CHARACTERS.on(identifier, "contains illegal characters"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user