mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-241923 Search Everywhere: Misordering in Results
GitOrigin-RevId: f2bbe7b3bd263ff2c43b76bf443ce6c92890b9bb
This commit is contained in:
committed by
intellij-monorepo-bot
parent
660fe75d8e
commit
e39f13580b
@@ -372,10 +372,10 @@ class GotoActionTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
}
|
||||
|
||||
private MatchedValue matchedAction(String text, String pattern, MatchMode mode = MatchMode.NAME, boolean isAvailable = true) {
|
||||
return matchedAction(createAction(text), pattern, mode, isAvailable)
|
||||
return createMatchedAction(project, createAction(text), pattern, mode, isAvailable)
|
||||
}
|
||||
|
||||
private MatchedValue matchedAction(AnAction action, String pattern, MatchMode mode = MatchMode.NAME, boolean isAvailable = true) {
|
||||
public static MatchedValue createMatchedAction(Project project, AnAction action, String pattern, MatchMode mode = MatchMode.NAME, boolean isAvailable = true) {
|
||||
def model = new GotoActionModel(project, null, null)
|
||||
def wrapper = new ActionWrapper(action, null, mode, DataContext.EMPTY_CONTEXT, model) {
|
||||
@Override
|
||||
@@ -422,7 +422,7 @@ class GotoActionTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
return new MatchedValue(option, pattern)
|
||||
}
|
||||
|
||||
private static SearchEverywhereContributor<?> createActionContributor(Project project) {
|
||||
public static SearchEverywhereContributor<?> createActionContributor(Project project) {
|
||||
def res = new TestActionContributor(project, null, null)
|
||||
res.setShowDisabled(true)
|
||||
return res
|
||||
|
||||
@@ -3,9 +3,15 @@ package com.intellij.java.navigation
|
||||
|
||||
import com.intellij.ide.actions.searcheverywhere.*
|
||||
import com.intellij.ide.actions.searcheverywhere.mixed.SearchEverywhereUIMixedResults
|
||||
import com.intellij.ide.util.gotoByName.GotoActionTest
|
||||
import com.intellij.openapi.actionSystem.AbbreviationManager
|
||||
import com.intellij.openapi.actionSystem.ActionManager
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.application.Experiments
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
|
||||
import com.intellij.util.Processor
|
||||
import org.jetbrains.annotations.NotNull
|
||||
@@ -82,6 +88,72 @@ class SearchEverywhereTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
})
|
||||
}
|
||||
|
||||
void "test priority for actions with space in pattern"() {
|
||||
withMixingEnabled({
|
||||
def action1 = new StubAction("Imaginary Action")
|
||||
def action2 = new StubAction("Another Imaginary Action")
|
||||
def class1 = myFixture.addClass("class ImaginaryAction{}")
|
||||
def class2 = myFixture.addClass("class AnotherImaginaryAction{}")
|
||||
|
||||
def ui = createTestUI([
|
||||
ChooseByNameTest.createClassContributor(project),
|
||||
GotoActionTest.createActionContributor(project)
|
||||
])
|
||||
|
||||
def actions = ["ia1": action1, "ia2": action2]
|
||||
def actionManager = ActionManager.getInstance()
|
||||
actions.each {actionManager.registerAction(it.key, it.value)}
|
||||
try {
|
||||
def future = ui.findElementsForPattern("imaginaryaction")
|
||||
def matchedAction1 = GotoActionTest.createMatchedAction(project, action1, "imaginaryaction")
|
||||
def matchedAction2 = GotoActionTest.createMatchedAction(project, action2, "imaginaryaction")
|
||||
assert PlatformTestUtil.waitForFuture(future, SEARCH_TIMEOUT) == [class1, matchedAction1, class2, matchedAction2]
|
||||
|
||||
future = ui.findElementsForPattern("imaginary action")
|
||||
matchedAction1 = GotoActionTest.createMatchedAction(project, action1, "imaginary action")
|
||||
matchedAction2 = GotoActionTest.createMatchedAction(project, action2, "imaginary action")
|
||||
assert PlatformTestUtil.waitForFuture(future, SEARCH_TIMEOUT) == [matchedAction1, class1, matchedAction2, class2]
|
||||
}
|
||||
finally {
|
||||
actions.each {actionManager.unregisterAction(it.key)}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
void "test top hit priority"() {
|
||||
withMixingEnabled({
|
||||
def action1 = new StubAction("Imaginary Action")
|
||||
def action2 = new StubAction("Another Imaginary Action")
|
||||
def class1 = myFixture.addClass("class ImaginaryAction{}")
|
||||
def class2 = myFixture.addClass("class AnotherImaginaryAction{}")
|
||||
|
||||
def ui = createTestUI([
|
||||
ChooseByNameTest.createClassContributor(project),
|
||||
GotoActionTest.createActionContributor(project),
|
||||
new TopHitSEContributor(project, null, null)
|
||||
])
|
||||
|
||||
def actions = ["ia1": action1, "ia2": action2]
|
||||
def actionManager = ActionManager.getInstance()
|
||||
def abbreviationManager = AbbreviationManager.getInstance()
|
||||
actions.each {actionManager.registerAction(it.key, it.value)}
|
||||
try {
|
||||
def matchedAction1 = GotoActionTest.createMatchedAction(project, action1, "imaginary")
|
||||
def matchedAction2 = GotoActionTest.createMatchedAction(project, action2, "imaginary")
|
||||
def future = ui.findElementsForPattern("imaginary")
|
||||
assert PlatformTestUtil.waitForFuture(future, SEARCH_TIMEOUT) == [class1, matchedAction1, class2, matchedAction2]
|
||||
|
||||
abbreviationManager.register("imaginary", "ia2")
|
||||
future = ui.findElementsForPattern("imaginary")
|
||||
assert PlatformTestUtil.waitForFuture(future, SEARCH_TIMEOUT) == [action2, class1, matchedAction1, class2]
|
||||
}
|
||||
finally {
|
||||
actions.each {actionManager.unregisterAction(it.key)}
|
||||
abbreviationManager.removeAllAbbreviations("ia2" )
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private SearchEverywhereUIBase createTestUI(List<SearchEverywhereContributor<Object>> contributors) {
|
||||
if (mySearchUI != null) Disposer.dispose(mySearchUI)
|
||||
|
||||
@@ -160,4 +232,13 @@ class SearchEverywhereTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
private static class StubAction extends AnAction{
|
||||
StubAction(String text) {
|
||||
super(text)
|
||||
}
|
||||
|
||||
@Override
|
||||
void actionPerformed(@NotNull AnActionEvent e) {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user