[FIR JS] Stop reporting NON_MEMBER_FUNCTION_NO_BODY for js natives

This commit is contained in:
Nikolay Lunyak
2023-01-04 16:56:39 +02:00
committed by Space Team
parent 85bcef537c
commit 2f9831ed99
16 changed files with 84 additions and 42 deletions
@@ -0,0 +1,22 @@
/*
* 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.fir.analysis.js.checkers
import org.jetbrains.kotlin.fir.analysis.checkers.FirPlatformDiagnosticSuppressor
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
import org.jetbrains.kotlin.fir.analysis.checkers.hasAnnotationOrInsideAnnotatedClass
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
import org.jetbrains.kotlin.name.JsStandardClassIds
private fun FirDeclaration.isLexicallyInsideJsNative(context: CheckerContext): Boolean {
return JsStandardClassIds.Annotations.nativeAnnotations.any { hasAnnotationOrInsideAnnotatedClass(it, context.session) }
}
object FirJsPlatformDiagnosticSuppressor : FirPlatformDiagnosticSuppressor {
override fun shouldReportNoBody(declaration: FirCallableDeclaration, context: CheckerContext) =
!declaration.isLexicallyInsideJsNative(context)
}
@@ -37,6 +37,7 @@ object JsDeclarationCheckers : DeclarationCheckers() {
override val simpleFunctionCheckers: Set<FirSimpleFunctionChecker>
get() = setOf(
FirJsTopLevelFunctionsChecker,
FirJsNativeInvokeChecker,
FirJsNativeGetterChecker,
FirJsNativeSetterChecker,
@@ -0,0 +1,13 @@
/*
* 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.fir.analysis.js.checkers.declaration
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirTopLevelFunctionsChecker
import org.jetbrains.kotlin.fir.analysis.js.checkers.FirJsPlatformDiagnosticSuppressor
object FirJsTopLevelFunctionsChecker : FirTopLevelFunctionsChecker() {
override val suppressor = FirJsPlatformDiagnosticSuppressor
}