mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-14 17:17:07 +02:00
Create bean class for ex commandsï¿¿
This commit is contained in:
@@ -45,8 +45,10 @@
|
||||
|
||||
<extensionPoints>
|
||||
<extensionPoint name="vimExtension" interface="com.maddyhome.idea.vim.extension.VimExtension"/>
|
||||
<extensionPoint name="vimExCommand" interface="com.maddyhome.idea.vim.ex.CommandHandler"/>
|
||||
|
||||
<extensionPoint name="vimExCommand" beanClass="com.maddyhome.idea.vim.ex.ExBeanClass">
|
||||
<with attribute="implementation" implements="com.maddyhome.idea.vim.ex.CommandHandler"/>
|
||||
</extensionPoint>
|
||||
<extensionPoint name="vimAction" beanClass="com.maddyhome.idea.vim.handler.ActionBeanClass">
|
||||
<with attribute="implementation" implements="com.maddyhome.idea.vim.handler.EditorActionHandlerBase"/>
|
||||
</extensionPoint>
|
||||
|
@@ -46,7 +46,7 @@ import java.util.regex.Pattern;
|
||||
public class CommandParser {
|
||||
private static final int MAX_RECURSION = 100;
|
||||
private static final Pattern TRIM_WHITESPACE = Pattern.compile("[ \\t]*(.*)[ \\t\\n\\r]+", Pattern.DOTALL);
|
||||
private final ExtensionPointName<CommandHandler> EX_COMMAND_EP = ExtensionPointName.create("IdeaVIM.vimExCommand");
|
||||
private final ExtensionPointName<ExBeanClass> EX_COMMAND_EP = ExtensionPointName.create("IdeaVIM.vimExCommand");
|
||||
|
||||
private static class CommandParserHolder {
|
||||
static final CommandParser INSTANCE = new CommandParser();
|
||||
@@ -73,8 +73,8 @@ public class CommandParser {
|
||||
public void registerHandlers() {
|
||||
if (registered.getAndSet(true)) return;
|
||||
|
||||
for (CommandHandler handler : EX_COMMAND_EP.getExtensions()) {
|
||||
handler.register();
|
||||
for (ExBeanClass handler : EX_COMMAND_EP.getExtensions()) {
|
||||
handler.getHandler().register();
|
||||
}
|
||||
}
|
||||
|
||||
|
15
src/com/maddyhome/idea/vim/ex/ExBeanClass.kt
Normal file
15
src/com/maddyhome/idea/vim/ex/ExBeanClass.kt
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.maddyhome.idea.vim.ex
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.extensions.AbstractExtensionPointBean
|
||||
import com.intellij.util.xmlb.annotations.Attribute
|
||||
|
||||
class ExBeanClass : AbstractExtensionPointBean() {
|
||||
@Attribute("implementation")
|
||||
var implementation: String? = null
|
||||
|
||||
val handler: CommandHandler by lazy {
|
||||
this.instantiateClass<CommandHandler>(
|
||||
implementation ?: "", ApplicationManager.getApplication().picoContainer)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user