Skip to content

Commit

Permalink
[IJ plugin] Avoid a crash caught in inspection (#5139)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoD authored and martinbonnin committed Aug 2, 2023
1 parent 6481213 commit f4bb618
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ class KotlinFindUsagesHandlerFactoryCompat(project: Project) : FindUsagesHandler
.onFailure { logw(it, "Could not load either $POST_231_CLASS_NAME nor $PRE_231_CLASS_NAME") }
.getOrNull()

private val delegate: FindUsagesHandlerFactory? = delegateClass?.let { it.getConstructor(Project::class.java).newInstance(project) as FindUsagesHandlerFactory }
private val delegate: FindUsagesHandlerFactory? = try {
delegateClass?.let { it.getConstructor(Project::class.java).newInstance(project) as FindUsagesHandlerFactory }
} catch (e: Exception) {
// ProcessCanceledException can sometimes happen here
logw(e, "Could not instantiate KotlinFindUsagesHandlerFactory")
null
}


override fun canFindUsages(element: PsiElement): Boolean {
Expand Down

0 comments on commit f4bb618

Please sign in to comment.