mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
simplify by extending ActionsTopHitProvider
(cherry picked from commit df6f25d9921457ff85317e7aa83236b2f07518fd)
This commit is contained in:
+12
-23
@@ -15,34 +15,23 @@
|
||||
*/
|
||||
package com.intellij.platform;
|
||||
|
||||
import com.intellij.ide.SearchTopHitProvider;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.ide.ActionsTopHitProvider;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class DefaultPlatformTopHitProvider implements SearchTopHitProvider {
|
||||
public class DefaultPlatformTopHitProvider extends ActionsTopHitProvider {
|
||||
private static final String[][] ACTION_MATRIX = {
|
||||
{"op", "open ", "OpenFile"},
|
||||
{"reo", "reopen ", "$LRU"},
|
||||
{"new", "new ", "NewGroup"},
|
||||
{"new c", "new class ", "NewClass"},
|
||||
{"new i", "new interface ", "NewClass"},
|
||||
{"new e", "new enum ", "NewClass"},
|
||||
};
|
||||
|
||||
@Override
|
||||
public void consumeTopHits(String pattern, Consumer<Object> collector) {
|
||||
//todo[kb] move to constant. Now it's better for hotswap
|
||||
String[][] ACTION_MATRIX = {
|
||||
{"op", "open ", "OpenFile"},
|
||||
{"reo", "reopen ", "$LRU"},
|
||||
{"new", "new ", "NewGroup"},
|
||||
{"new c", "new class ", "NewClass"},
|
||||
{"new i", "new interface ", "NewClass"},
|
||||
{"new e", "new enum ", "NewClass"},
|
||||
};
|
||||
final ActionManager actionManager = ActionManager.getInstance();
|
||||
for (String[] strings : ACTION_MATRIX) {
|
||||
if (StringUtil.isBetween(pattern, strings[0], strings[1])) {
|
||||
for (int i = 2; i < strings.length; i++) {
|
||||
collector.consume(actionManager.getAction(strings[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
protected String[][] getActionsMatrix() {
|
||||
return ACTION_MATRIX;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user