mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[devkit] IncorrectParentDisposableInspection: link to SDK docs
GitOrigin-RevId: c0328cd2b50ca02bcd153733a456ea408c74a0ac
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8624927524
commit
cfb368a902
+1
-1
@@ -1,6 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
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 <a href="https://www.jetbrains.org/intellij/sdk/docs/basics/disposers.html#choosing-a-disposable-parent">Choosing a Disposable Parent</a> in SDK Docs.
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -32,6 +32,8 @@ class IncorrectParentDisposableInspection : DevKitUastInspectionBase(UCallExpres
|
||||
return "/platform/" in file.virtualFile.path // TODO expand this check
|
||||
}
|
||||
|
||||
private val sdkLink = "(<a href=\"https://www.jetbrains.org/intellij/sdk/docs/basics/disposers.html#choosing-a-disposable-parent\">Choosing a Disposable Parent</a>)"
|
||||
|
||||
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, "<html>Don't use Project as disposable in plugin code $sdkLink</html>")
|
||||
}
|
||||
else if (argumentType.qualifiedName == Application::class.java.name) {
|
||||
holder.registerProblem(argumentSourcePsi, "Don't use Application as disposable in plugin code")
|
||||
holder.registerProblem(argumentSourcePsi, "<html>Don't use Application as disposable in plugin code $sdkLink</html>")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user