mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-14 18:05:27 +07:00
[devkit] IJ-CR-145746 IJPL-163148: fix resolving actions from libraries
IJ-CR-145746 (cherry picked from commit 9be9bb7b5c646684069cc5885881c068f65b27ee) GitOrigin-RevId: 63f30a64360ff8716fca3e6a837e1e3574c0de29
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3edeaf4606
commit
9a9f103ced
@@ -44,7 +44,8 @@ final class ActionOrGroupIdReference extends PsiPolyVariantReferenceBase<PsiElem
|
||||
public ResolveResult @NotNull [] multiResolve(boolean incompleteCode) {
|
||||
Project project = getElement().getProject();
|
||||
|
||||
final GlobalSearchScope scope = ProjectScope.getContentScope(project);
|
||||
final GlobalSearchScope scope = ProjectScope.getContentScope(project)
|
||||
.union(ProjectScope.getLibrariesScope(project));
|
||||
|
||||
CommonProcessors.CollectUniquesProcessor<ActionOrGroup> processor = new CommonProcessors.CollectUniquesProcessor<>();
|
||||
collectResults(myId, scope, processor);
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.idea.devkit.kotlin.codeInsight
|
||||
|
||||
import com.intellij.codeInspection.LocalInspectionEP
|
||||
import com.intellij.openapi.actionSystem.ActionManager
|
||||
import com.intellij.openapi.application.PathManager
|
||||
import com.intellij.testFramework.PsiTestUtil
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
|
||||
import com.intellij.ui.components.JBList
|
||||
import com.intellij.util.PathUtil
|
||||
import org.jetbrains.idea.devkit.inspections.UnresolvedPluginConfigReferenceInspection
|
||||
|
||||
class KtActionReferenceTest : LightJavaCodeInsightFixtureTestCase() {
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
myFixture.addClass("package com.intellij.ui.components; public class JBList {}");
|
||||
myFixture.addClass("package com.intellij.openapi.actionSystem; public abstract class AnAction {}");
|
||||
myFixture.addClass("""
|
||||
package com.intellij.openapi.actionSystem;
|
||||
|
||||
public abstract class ActionManager {
|
||||
public abstract AnAction getAction(@NonNls @NotNull String actionId);
|
||||
}
|
||||
|
||||
""".trimIndent())
|
||||
PsiTestUtil.addLibrary(myFixture.module, PathUtil.getJarPathForClass(JBList::class.java))
|
||||
PsiTestUtil.addLibrary(myFixture.module, PathUtil.getJarPathForClass(ActionManager::class.java))
|
||||
PsiTestUtil.addLibrary(myFixture.module,
|
||||
PathManager.getResourceRoot(LocalInspectionEP::class.java, "/idea/PlatformActions.xml")!!)
|
||||
}
|
||||
|
||||
private fun pluginXmlActions(actionsText: String): String {
|
||||
@@ -49,6 +49,25 @@ class KtActionReferenceTest : LightJavaCodeInsightFixtureTestCase() {
|
||||
myFixture.testHighlighting()
|
||||
}
|
||||
|
||||
fun testResolveLibrariActionId() {
|
||||
val pluginXmlActions = pluginXmlActions("""
|
||||
<action id="myAction"/>
|
||||
""".trimIndent())
|
||||
myFixture.createFile("plugin.xml", pluginXmlActions)
|
||||
myFixture.createFile("anotherPlugin.xml", pluginXmlActions)
|
||||
myFixture.configureByText("Caller.kt", """
|
||||
fun usage(actionManager: com.intellij.openapi.actionSystem.ActionManager){
|
||||
|
||||
actionManager.getAction("$DLR{"\$DLR"}Undo")
|
||||
actionManager.getAction("Find")
|
||||
actionManager.getAction("<error>Unknown1</error>")
|
||||
|
||||
}
|
||||
""".trimIndent())
|
||||
myFixture.enableInspections(UnresolvedPluginConfigReferenceInspection::class.java)
|
||||
myFixture.testHighlighting()
|
||||
}
|
||||
|
||||
fun testRenameAction() {
|
||||
myFixture.createFile("plugin.xml", pluginXmlActions("""
|
||||
<group id="myGroup"></group>
|
||||
@@ -87,7 +106,6 @@ class KtActionReferenceTest : LightJavaCodeInsightFixtureTestCase() {
|
||||
}
|
||||
|
||||
fun testInvalidActionOrGroupReference() {
|
||||
val DLR = '$'.toString()
|
||||
myFixture.enableInspections(UnresolvedPluginConfigReferenceInspection::class.java)
|
||||
myFixture.createFile("plugin.xml", pluginXmlActions("""
|
||||
<group id="myGroup"></group>
|
||||
@@ -128,4 +146,6 @@ class KtActionReferenceTest : LightJavaCodeInsightFixtureTestCase() {
|
||||
), true)
|
||||
}
|
||||
|
||||
val DLR = '$'.toString()
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user