From cfb368a902d64d4de8ec29291e86ead344bcf476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20C=C3=A9bron?= Date: Tue, 16 Jun 2020 21:51:05 +0200 Subject: [PATCH] [devkit] IncorrectParentDisposableInspection: link to SDK docs GitOrigin-RevId: c0328cd2b50ca02bcd153733a456ea408c74a0ac --- .../inspectionDescriptions/IncorrectParentDisposable.html | 2 +- .../src/inspections/IncorrectParentDisposableInspection.kt | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/devkit/devkit-core/resources/inspectionDescriptions/IncorrectParentDisposable.html b/plugins/devkit/devkit-core/resources/inspectionDescriptions/IncorrectParentDisposable.html index 4c9d6223656e..231f4bc08771 100644 --- a/plugins/devkit/devkit-core/resources/inspectionDescriptions/IncorrectParentDisposable.html +++ b/plugins/devkit/devkit-core/resources/inspectionDescriptions/IncorrectParentDisposable.html @@ -1,6 +1,6 @@ This inspection detects passing Application or Project as a parent disposable in plugin code. Such usage will lead to plugins not being -unloaded correctly. +unloaded correctly. Please see Choosing a Disposable Parent in SDK Docs. diff --git a/plugins/devkit/devkit-core/src/inspections/IncorrectParentDisposableInspection.kt b/plugins/devkit/devkit-core/src/inspections/IncorrectParentDisposableInspection.kt index 073175cf4d56..ec178a2d2c84 100644 --- a/plugins/devkit/devkit-core/src/inspections/IncorrectParentDisposableInspection.kt +++ b/plugins/devkit/devkit-core/src/inspections/IncorrectParentDisposableInspection.kt @@ -32,6 +32,8 @@ class IncorrectParentDisposableInspection : DevKitUastInspectionBase(UCallExpres return "/platform/" in file.virtualFile.path // TODO expand this check } + private val sdkLink = "(Choosing a Disposable Parent)" + private fun checkCallExpression(node: UCallExpression, holder: ProblemsHolder) { val psiMethod = node.resolve() ?: return psiMethod.parameters.forEachIndexed { index, parameter -> @@ -41,10 +43,10 @@ class IncorrectParentDisposableInspection : DevKitUastInspectionBase(UCallExpres val argumentSourcePsi = argumentForParameter.sourcePsi ?: return@forEachIndexed val argumentType = (argumentForParameter.getExpressionType() as? PsiClassType)?.resolve() ?: return@forEachIndexed if (argumentType.qualifiedName == Project::class.java.name) { - holder.registerProblem(argumentSourcePsi, "Don't use Project as disposable in plugin code") + holder.registerProblem(argumentSourcePsi, "Don't use Project as disposable in plugin code $sdkLink") } else if (argumentType.qualifiedName == Application::class.java.name) { - holder.registerProblem(argumentSourcePsi, "Don't use Application as disposable in plugin code") + holder.registerProblem(argumentSourcePsi, "Don't use Application as disposable in plugin code $sdkLink") } } }