mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-10 15:40:37 +02:00
Find action by id without all actions initiation
This commit is contained in:
parent
2e7cde3ca5
commit
d45d56f330
src/com/maddyhome/idea/vim
@ -43,8 +43,8 @@ public class RegisterActions {
|
||||
|
||||
@Nullable
|
||||
public static EditorActionHandlerBase findAction(@NotNull String id) {
|
||||
return VIM_ACTIONS_EP.extensions().map(ActionBeanClass::getAction)
|
||||
.filter(vimActionBean -> vimActionBean.getId().equals(id)).findFirst().orElse(null);
|
||||
return VIM_ACTIONS_EP.extensions().filter(vimActionBean -> vimActionBean.getActionId().equals(id)).findFirst()
|
||||
.map(ActionBeanClass::getAction).orElse(null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
@ -33,6 +33,8 @@ class ActionBeanClass : AbstractExtensionPointBean() {
|
||||
@Attribute("keys")
|
||||
var keys: String? = null
|
||||
|
||||
val actionId: String get() = implementation?.let { EditorActionHandlerBase.getActionId(it) } ?: ""
|
||||
|
||||
val action: EditorActionHandlerBase by lazy {
|
||||
// FIXME. [VERSION UPDATE] change to instantiateClass for 193+
|
||||
@Suppress("DEPRECATION")
|
||||
|
@ -84,7 +84,7 @@ sealed class VimActionHandler(myRunForEachCaret: Boolean) : EditorActionHandlerB
|
||||
}
|
||||
|
||||
sealed class EditorActionHandlerBase(private val myRunForEachCaret: Boolean) {
|
||||
val id: String = this::class.java.simpleName.let { if (it.startsWith("Vim", true)) it else "Vim$it" }
|
||||
val id: String = getActionId(this::class.java.name)
|
||||
|
||||
abstract val type: Command.Type
|
||||
|
||||
@ -157,5 +157,11 @@ sealed class EditorActionHandlerBase(private val myRunForEachCaret: Boolean) {
|
||||
fun parseKeysSet(vararg keyStrings: String): Set<List<KeyStroke>> = List(keyStrings.size) {
|
||||
StringHelper.parseKeys(keyStrings[it])
|
||||
}.toSet()
|
||||
|
||||
fun getActionId(classFullName: String): String {
|
||||
return classFullName
|
||||
.takeLastWhile { it != '.' }
|
||||
.let { if (it.startsWith("Vim", true)) it else "Vim$it" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user