1
0
mirror of https://github.com/chylex/IntelliJ-Inspection-Lens.git synced 2025-04-30 23:34:08 +02:00

Work around referencing an internal IntelliJ API class

This commit is contained in:
chylex 2025-01-14 23:09:07 +01:00
parent cde4d81afe
commit 0bc85fd69b
Signed by: chylex
SSH Key Fingerprint: SHA256:WqM8X/1DDn11LbYM0H5wsqZUjbcKxVsic37L+ERcF4o
2 changed files with 18 additions and 2 deletions
src
main/kotlin/com/chylex/intellij/inspectionlens/editor/lens
test/kotlin/com/chylex/intellij/inspectionlens/editor/lens

View File

@ -2,7 +2,6 @@ package com.chylex.intellij.inspectionlens.editor.lens
import com.intellij.codeInsight.daemon.impl.IntentionsUI import com.intellij.codeInsight.daemon.impl.IntentionsUI
import com.intellij.codeInsight.hint.HintManager import com.intellij.codeInsight.hint.HintManager
import com.intellij.codeInsight.intention.actions.ShowIntentionActionsAction
import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler import com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler
import com.intellij.lang.LangBundle import com.intellij.lang.LangBundle
import com.intellij.openapi.actionSystem.ActionManager import com.intellij.openapi.actionSystem.ActionManager
@ -26,7 +25,7 @@ internal object IntentionsPopup {
// If the IDE uses the default Show Intentions action and handler, // If the IDE uses the default Show Intentions action and handler,
// use the handler directly to bypass additional logic from the action. // use the handler directly to bypass additional logic from the action.
val action = ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS) val action = ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS)
if (action.javaClass === ShowIntentionActionsAction::class.java) { if (action.javaClass.name === DEFAULT_ACTION_CLASS) {
return tryShowWithDefaultHandler(editor) return tryShowWithDefaultHandler(editor)
} }
else { else {
@ -46,6 +45,11 @@ internal object IntentionsPopup {
return true return true
} }
/**
* New IDEA versions mark this class as internal, so the plugin verifier flags references to it as errors.
*/
const val DEFAULT_ACTION_CLASS = "com.intellij.codeInsight.intention.actions.ShowIntentionActionsAction"
private val HANDLER = object : ShowIntentionActionsHandler() { private val HANDLER = object : ShowIntentionActionsHandler() {
public override fun showIntentionHint(project: Project, editor: Editor, file: PsiFile, showFeedbackOnEmptyMenu: Boolean) { public override fun showIntentionHint(project: Project, editor: Editor, file: PsiFile, showFeedbackOnEmptyMenu: Boolean) {
super.showIntentionHint(project, editor, file, showFeedbackOnEmptyMenu) super.showIntentionHint(project, editor, file, showFeedbackOnEmptyMenu)

View File

@ -0,0 +1,12 @@
package com.chylex.intellij.inspectionlens.editor.lens
import com.intellij.codeInsight.intention.actions.ShowIntentionActionsAction
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
class IntentionsPopupTest {
@Test
fun showIntentionActionsActionClassHasNotChanged() {
assertEquals(IntentionsPopup.DEFAULT_ACTION_CLASS, ShowIntentionActionsAction::class.java.name)
}
}