detekt / detekt-intellij-plugin

detekt plugin for IntelliJ
https://plugins.jetbrains.com/plugin/10761-detekt
Apache License 2.0
290 stars 39 forks source link

use shaded libs to improve detekt stability #496

Open litols opened 9 months ago

litols commented 9 months ago

Motivation:

Modification:

arturbosch commented 8 months ago

Hi, which problems did you had with mixing the detekt and kotlin plugins? Detekt uses the embeddable compiler and Intellij the unshaded compiler, which conflicts occur? For example gradle runIde runs the detekt plugin besides the Kotlin 1.6 plugin and it works fine on my side.

You think this change also fix showing Kotlin compiler errors as detekt plugin errors https://github.com/detekt/detekt-intellij-plugin/issues/271 ?

Unfortunately shading the compiler lib does not help with using the normal compiler classes: https://github.com/detekt/detekt-intellij-plugin/issues/271 2023-11-05 16:45:29,195 [ 25461] SEVERE - #c.i.o.u.ObjectTree - class org.jetbrains.kotlin.psi.KtNamedFunction cannot be cast to class detekt.shadow.org.jetbrains.kotlin.psi.KtModifierListOwner

litols commented 8 months ago

sorry for too late response.

which problems did you had with mixing the detekt and kotlin plugins?

271. (but after upgrade the plugin to 2.2.0, running in IntelliJ IDEA 2023.2.4 + Kotlin plugin 232-1.9.20-release-507-IJ10072.2, these error is not occurring...)

Detekt uses the embeddable compiler and Intellij the unshaded compiler, which conflicts occur? You think this change also fix showing Kotlin compiler errors as detekt plugin errors https://github.com/detekt/detekt-intellij-plugin/issues/271 ?

I think kotlin plugin picking up the kotlin compiler from detekt plugin wrongly. Reasons:

Thus,I think we can mitigate #271 with relocating the classes which uses in kotlin plugin.

JFYI, kotlin-intellij-plugin is relocating kotlin PSI files, https://github.com/nbadal/ktlint-intellij-plugin/tree/main/lib but the relocating is applied partially, it seems we need picking up correct classes. maybe KtNamedFunction need to excluding from relocating in detekt-intellij-plugin.

Anyway, I've applied your review comments to this pull request. thank you for your review!