[devkit] KTIJ-29667 cleanup

GitOrigin-RevId: e6332f53bf9f3d0279963ed15808c66eedd48e81
This commit is contained in:
Andrew Kozlov
2024-04-19 14:21:15 +02:00
committed by intellij-monorepo-bot
parent ac8807e29c
commit e1e5ccb5fb
3 changed files with 16 additions and 7 deletions

View File

@@ -9,8 +9,8 @@ import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getCallNameExpression
internal val requiresBlockingContextAnnotation = FqName(REQUIRES_BLOCKING_CONTEXT_ANNOTATION)
internal val requiresBlockingContextAnnotationId = ClassId.topLevel(requiresBlockingContextAnnotation)
internal val RequiresBlockingContextAnnotation: FqName = FqName(REQUIRES_BLOCKING_CONTEXT_ANNOTATION)
internal val RequiresBlockingContextAnnotationId: ClassId = ClassId.topLevel(RequiresBlockingContextAnnotation)
internal abstract class BlockingContextFunctionBodyVisitor : KtTreeVisitorVoid() {
override fun visitLambdaExpression(lambdaExpression: KtLambdaExpression): Unit = Unit

View File

@@ -110,7 +110,7 @@ internal class ForbiddenInSuspectContextMethodInspection : LocalInspectionTool()
val calledSymbol = functionCall?.partiallyAppliedSymbol?.symbol
if (calledSymbol !is KtNamedSymbol) return
val hasAnnotation = calledSymbol.hasAnnotation(requiresBlockingContextAnnotationId)
val hasAnnotation = calledSymbol.hasAnnotation(RequiresBlockingContextAnnotationId)
if (!hasAnnotation) {
if (calledSymbol is KtFunctionSymbol) {

View File

@@ -43,7 +43,7 @@ internal class KtCallingFunctionShouldBeRequiresBlockingContextVisitorProvider :
val calledSymbol = functionCall?.partiallyAppliedSymbol?.symbol
if (calledSymbol !is KtNamedSymbol) return
val hasAnnotation = calledSymbol.hasAnnotation(requiresBlockingContextAnnotationId)
val hasAnnotation = calledSymbol.hasAnnotation(RequiresBlockingContextAnnotationId)
if (!hasAnnotation) {
if (calledSymbol is KtFunctionSymbol && calledSymbol.isInline) {
@@ -65,13 +65,22 @@ internal class KtCallingFunctionShouldBeRequiresBlockingContextVisitorProvider :
}
private class AnnotateFix(
element: PsiElement, callingMethod: KtNamedFunction
element: PsiElement,
callingMethod: KtNamedFunction,
) : QuickFixWithReferenceToElement<KtNamedFunction>(element, callingMethod) {
override fun getFamilyName(): String = DevKitBundle.message("inspections.calling.method.should.be.rbc.annotated.annotate.fix")
override fun getText(): String = familyName
override fun invoke(project: Project, file: PsiFile, editor: Editor?, startElement: PsiElement, endElement: PsiElement) {
referencedElement.element!!.addAnnotation(requiresBlockingContextAnnotation)
override fun invoke(
project: Project,
file: PsiFile,
editor: Editor?,
startElement: PsiElement,
endElement: PsiElement,
) {
referencedElement.element!!
.addAnnotation(RequiresBlockingContextAnnotation)
}
}