1
0
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:
Alex Plate 2019-11-22 17:32:28 +03:00
parent 2e7cde3ca5
commit d45d56f330
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
3 changed files with 11 additions and 3 deletions

View File

@ -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

View File

@ -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")

View File

@ -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" }
}
}
}