1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-05-28 16:34:10 +02:00

Remove explicit API mode to enhance coding efficiency and maintain Kotlin's conciseness

Explicit API mode has been removed due to several reasons impacting developer productivity and the natural coding style in Kotlin.

Firstly, the mode was found to be more irritating than beneficial, as it forced unnecessary verbosity without enhancing thoughtfulness in coding. It often prompted automatic 'public' insertion reactions to red-highlighted code, which did not genuinely encourage more deliberate coding decisions.

Secondly, our aim is to form a robust API primarily through interfaces, which inherently define public scope and duty, rendering explicit API mode somewhat redundant.

Lastly, the additional verbosity caused by explicit API mode expanded code lines affecting code readability.

The compatibility with the existing plugins is verified via the compatibility checker, so no JetBrains plugins will be affected
This commit is contained in:
Alex Plate 2024-06-28 17:11:16 +03:00
parent ffd832d990
commit 9538714af1
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
660 changed files with 2927 additions and 2927 deletions
annotation-processors/src/main/kotlin/com/intellij/vim/providers
build.gradle.kts
src
vim-engine

View File

@ -13,7 +13,7 @@ import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
import com.google.devtools.ksp.processing.SymbolProcessorProvider import com.google.devtools.ksp.processing.SymbolProcessorProvider
import com.intellij.vim.processors.VimscriptFunctionProcessor import com.intellij.vim.processors.VimscriptFunctionProcessor
public class VimscriptFunctionProcessorProvider : SymbolProcessorProvider { class VimscriptFunctionProcessorProvider : SymbolProcessorProvider {
override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor { override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {
return VimscriptFunctionProcessor(environment) return VimscriptFunctionProcessor(environment)
} }

View File

@ -269,7 +269,6 @@ java {
} }
kotlin { kotlin {
explicitApi()
jvmToolchain { jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(javaVersion)) languageVersion.set(JavaLanguageVersion.of(javaVersion))
} }

View File

@ -14,28 +14,28 @@ import com.maddyhome.idea.vim.key.MappingOwner
import java.awt.event.KeyEvent import java.awt.event.KeyEvent
import javax.swing.KeyStroke import javax.swing.KeyStroke
public object RegisterActions { object RegisterActions {
/** /**
* Register all the key/action mappings for the plugin. * Register all the key/action mappings for the plugin.
*/ */
@JvmStatic @JvmStatic
public fun registerActions() { fun registerActions() {
registerVimCommandActions() registerVimCommandActions()
registerShortcutsWithoutActions() registerShortcutsWithoutActions()
} }
public fun findAction(id: String): EditorActionHandlerBase? { fun findAction(id: String): EditorActionHandlerBase? {
val commandBean = IntellijCommandProvider.getCommands().firstOrNull { it.actionId == id } val commandBean = IntellijCommandProvider.getCommands().firstOrNull { it.actionId == id }
?: EngineCommandProvider.getCommands().firstOrNull { it.actionId == id } ?: return null ?: EngineCommandProvider.getCommands().firstOrNull { it.actionId == id } ?: return null
return commandBean.instance return commandBean.instance
} }
public fun findActionOrDie(id: String): EditorActionHandlerBase { fun findActionOrDie(id: String): EditorActionHandlerBase {
return findAction(id) ?: throw RuntimeException("Action $id is not registered") return findAction(id) ?: throw RuntimeException("Action $id is not registered")
} }
@JvmStatic @JvmStatic
public fun unregisterActions() { fun unregisterActions() {
val keyGroup = VimPlugin.getKeyIfCreated() val keyGroup = VimPlugin.getKeyIfCreated()
keyGroup?.unregisterCommandActions() keyGroup?.unregisterCommandActions()
} }

View File

@ -32,7 +32,7 @@ import javax.swing.KeyStroke
* This class is used in Which-Key plugin, so don't make it internal. Generally, we should provide a proper * This class is used in Which-Key plugin, so don't make it internal. Generally, we should provide a proper
* way to get ideavim keys for this plugin. See VIM-3085 * way to get ideavim keys for this plugin. See VIM-3085
*/ */
public class VimTypedActionHandler(origHandler: TypedActionHandler) : TypedActionHandlerEx { class VimTypedActionHandler(origHandler: TypedActionHandler) : TypedActionHandlerEx {
private val handler = KeyHandler.getInstance() private val handler = KeyHandler.getInstance()
private val traceTime = injector.globalOptions().ideatracetime private val traceTime = injector.globalOptions().ideatracetime

View File

@ -8,6 +8,6 @@
package com.maddyhome.idea.vim.action package com.maddyhome.idea.vim.action
public object IntellijCommandProvider : CommandProvider { object IntellijCommandProvider : CommandProvider {
override val commandListFileName: String = "intellij_commands.json" override val commandListFileName: String = "intellij_commands.json"
} }

View File

@ -60,7 +60,7 @@ import javax.swing.KeyStroke
* This class is used in Which-Key plugin, so don't make it internal. Generally, we should provide a proper * This class is used in Which-Key plugin, so don't make it internal. Generally, we should provide a proper
* way to get ideavim keys for this plugin. See VIM-3085 * way to get ideavim keys for this plugin. See VIM-3085
*/ */
public class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatible*/ { class VimShortcutKeyAction : AnAction(), DumbAware/*, LightEditCompatible*/ {
private val traceTime: Boolean private val traceTime: Boolean
get() { get() {
// Make sure the injector is initialized // Make sure the injector is initialized

View File

@ -20,7 +20,7 @@ import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
import com.maddyhome.idea.vim.newapi.ijOptions import com.maddyhome.idea.vim.newapi.ijOptions
@CommandOrMotion(keys = ["gJ"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["gJ"], modes = [Mode.NORMAL])
public class DeleteJoinLinesAction : ChangeEditorActionHandler.ConditionalSingleExecution() { class DeleteJoinLinesAction : ChangeEditorActionHandler.ConditionalSingleExecution() {
override val type: Command.Type = Command.Type.DELETE override val type: Command.Type = Command.Type.DELETE
override fun runAsMulticaret( override fun runAsMulticaret(
editor: VimEditor, editor: VimEditor,

View File

@ -19,7 +19,7 @@ import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
import com.maddyhome.idea.vim.newapi.ijOptions import com.maddyhome.idea.vim.newapi.ijOptions
@CommandOrMotion(keys = ["J"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["J"], modes = [Mode.NORMAL])
public class DeleteJoinLinesSpacesAction : ChangeEditorActionHandler.SingleExecution() { class DeleteJoinLinesSpacesAction : ChangeEditorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.DELETE override val type: Command.Type = Command.Type.DELETE
override fun execute( override fun execute(

View File

@ -23,7 +23,7 @@ import com.maddyhome.idea.vim.newapi.ijOptions
* @author vlan * @author vlan
*/ */
@CommandOrMotion(keys = ["gJ"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["gJ"], modes = [Mode.VISUAL])
public class DeleteJoinVisualLinesAction : VisualOperatorActionHandler.SingleExecution() { class DeleteJoinVisualLinesAction : VisualOperatorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.DELETE override val type: Command.Type = Command.Type.DELETE
override fun executeForAllCarets( override fun executeForAllCarets(

View File

@ -23,7 +23,7 @@ import com.maddyhome.idea.vim.newapi.ijOptions
* @author vlan * @author vlan
*/ */
@CommandOrMotion(keys = ["J"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["J"], modes = [Mode.VISUAL])
public class DeleteJoinVisualLinesSpacesAction : VisualOperatorActionHandler.SingleExecution() { class DeleteJoinVisualLinesSpacesAction : VisualOperatorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.DELETE override val type: Command.Type = Command.Type.DELETE
override fun executeForAllCarets( override fun executeForAllCarets(

View File

@ -12,18 +12,18 @@ import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.LogicalPosition import com.intellij.openapi.editor.LogicalPosition
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
public class CharacterPosition(line: Int, col: Int) : LogicalPosition(line, col) { class CharacterPosition(line: Int, col: Int) : LogicalPosition(line, col) {
public fun toOffset(editor: Editor): Int = editor.vim.getLineStartOffset(line) + column fun toOffset(editor: Editor): Int = editor.vim.getLineStartOffset(line) + column
public companion object { companion object {
public fun fromOffset(editor: Editor, offset: Int): CharacterPosition { fun fromOffset(editor: Editor, offset: Int): CharacterPosition {
// logical position "expands" tabs // logical position "expands" tabs
val logicalPosition = editor.offsetToLogicalPosition(offset) val logicalPosition = editor.offsetToLogicalPosition(offset)
val lineStartOffset = editor.vim.getLineStartOffset(logicalPosition.line) val lineStartOffset = editor.vim.getLineStartOffset(logicalPosition.line)
return CharacterPosition(logicalPosition.line, offset - lineStartOffset) return CharacterPosition(logicalPosition.line, offset - lineStartOffset)
} }
public fun atCaret(editor: Editor): CharacterPosition { fun atCaret(editor: Editor): CharacterPosition {
return fromOffset(editor, editor.caretModel.offset) return fromOffset(editor, editor.caretModel.offset)
} }
} }

View File

@ -14,7 +14,7 @@ import com.maddyhome.idea.vim.helper.vimExOutput
import com.maddyhome.idea.vim.ui.ExOutputPanel import com.maddyhome.idea.vim.ui.ExOutputPanel
// TODO: We need a nicer way to handle output, especially wrt testing, appending + clearing // TODO: We need a nicer way to handle output, especially wrt testing, appending + clearing
public class ExOutputModel private constructor(private val myEditor: Editor) : VimExOutputPanel { class ExOutputModel private constructor(private val myEditor: Editor) : VimExOutputPanel {
private var isActiveInTestMode = false private var isActiveInTestMode = false
override val isActive: Boolean override val isActive: Boolean
@ -60,9 +60,9 @@ public class ExOutputModel private constructor(private val myEditor: Editor) : V
} }
} }
public companion object { companion object {
@JvmStatic @JvmStatic
public fun getInstance(editor: Editor): ExOutputModel { fun getInstance(editor: Editor): ExOutputModel {
var model = editor.vimExOutput var model = editor.vimExOutput
if (model == null) { if (model == null) {
model = ExOutputModel(editor) model = ExOutputModel(editor)

View File

@ -50,13 +50,13 @@ import javax.swing.KeyStroke
* *
* @author vlan * @author vlan
*/ */
public object VimExtensionFacade { object VimExtensionFacade {
private val LOG = logger<VimExtensionFacade>() private val LOG = logger<VimExtensionFacade>()
/** The 'map' command for mapping keys to handlers defined in extensions. */ /** The 'map' command for mapping keys to handlers defined in extensions. */
@JvmStatic @JvmStatic
public fun putExtensionHandlerMapping( fun putExtensionHandlerMapping(
modes: Set<MappingMode>, modes: Set<MappingMode>,
fromKeys: List<KeyStroke>, fromKeys: List<KeyStroke>,
pluginOwner: MappingOwner, pluginOwner: MappingOwner,
@ -74,7 +74,7 @@ public object VimExtensionFacade {
"com.maddyhome.idea.vim.VimPlugin" "com.maddyhome.idea.vim.VimPlugin"
) )
) )
public fun putExtensionHandlerMapping( fun putExtensionHandlerMapping(
modes: Set<MappingMode>, modes: Set<MappingMode>,
fromKeys: List<KeyStroke>, fromKeys: List<KeyStroke>,
pluginOwner: MappingOwner, pluginOwner: MappingOwner,
@ -86,7 +86,7 @@ public object VimExtensionFacade {
/** The 'map' command for mapping keys to other keys. */ /** The 'map' command for mapping keys to other keys. */
@JvmStatic @JvmStatic
public fun putKeyMapping( fun putKeyMapping(
modes: Set<MappingMode>, modes: Set<MappingMode>,
fromKeys: List<KeyStroke>, fromKeys: List<KeyStroke>,
pluginOwner: MappingOwner, pluginOwner: MappingOwner,
@ -98,7 +98,7 @@ public object VimExtensionFacade {
/** The 'map' command for mapping keys to other keys if there is no other mapping to these keys */ /** The 'map' command for mapping keys to other keys if there is no other mapping to these keys */
@JvmStatic @JvmStatic
public fun putKeyMappingIfMissing( fun putKeyMappingIfMissing(
modes: Set<MappingMode>, modes: Set<MappingMode>,
fromKeys: List<KeyStroke>, fromKeys: List<KeyStroke>,
pluginOwner: MappingOwner, pluginOwner: MappingOwner,
@ -112,7 +112,7 @@ public object VimExtensionFacade {
/** /**
* Equivalent to calling 'command' to set up a user-defined command or alias * Equivalent to calling 'command' to set up a user-defined command or alias
*/ */
public fun addCommand( fun addCommand(
name: String, name: String,
handler: CommandAliasHandler, handler: CommandAliasHandler,
) { ) {
@ -123,7 +123,7 @@ public object VimExtensionFacade {
* Equivalent to calling 'command' to set up a user-defined command or alias * Equivalent to calling 'command' to set up a user-defined command or alias
*/ */
@JvmStatic @JvmStatic
public fun addCommand( fun addCommand(
name: String, name: String,
minimumNumberOfArguments: Int, minimumNumberOfArguments: Int,
maximumNumberOfArguments: Int, maximumNumberOfArguments: Int,
@ -141,7 +141,7 @@ public object VimExtensionFacade {
* leaves the editor in the insert mode if it's been activated. * leaves the editor in the insert mode if it's been activated.
*/ */
@JvmStatic @JvmStatic
public fun executeNormalWithoutMapping(keys: List<KeyStroke>, editor: Editor) { fun executeNormalWithoutMapping(keys: List<KeyStroke>, editor: Editor) {
val context = injector.executionContextManager.getEditorExecutionContext(editor.vim) val context = injector.executionContextManager.getEditorExecutionContext(editor.vim)
val keyHandler = KeyHandler.getInstance() val keyHandler = KeyHandler.getInstance()
keys.forEach { keyHandler.handleKey(editor.vim, it, context, false, false, keyHandler.keyHandlerState) } keys.forEach { keyHandler.handleKey(editor.vim, it, context, false, false, keyHandler.keyHandlerState) }
@ -149,7 +149,7 @@ public object VimExtensionFacade {
/** Returns a single key stroke from the user input similar to 'getchar()'. */ /** Returns a single key stroke from the user input similar to 'getchar()'. */
@JvmStatic @JvmStatic
public fun inputKeyStroke(editor: Editor): KeyStroke { fun inputKeyStroke(editor: Editor): KeyStroke {
if (editor.vim.vimStateMachine.isDotRepeatInProgress) { if (editor.vim.vimStateMachine.isDotRepeatInProgress) {
val input = Extension.consumeKeystroke() val input = Extension.consumeKeystroke()
LOG.trace("inputKeyStroke: dot repeat in progress. Input: $input") LOG.trace("inputKeyStroke: dot repeat in progress. Input: $input")
@ -181,43 +181,43 @@ public object VimExtensionFacade {
/** Returns a string typed in the input box similar to 'input()'. */ /** Returns a string typed in the input box similar to 'input()'. */
@JvmStatic @JvmStatic
public fun inputString(editor: Editor, context: DataContext, prompt: String, finishOn: Char?): String { fun inputString(editor: Editor, context: DataContext, prompt: String, finishOn: Char?): String {
return injector.commandLine.inputString(editor.vim, context.vim, prompt, finishOn) ?: "" return injector.commandLine.inputString(editor.vim, context.vim, prompt, finishOn) ?: ""
} }
/** Get the current contents of the given register similar to 'getreg()'. */ /** Get the current contents of the given register similar to 'getreg()'. */
@JvmStatic @JvmStatic
public fun getRegister(register: Char): List<KeyStroke>? { fun getRegister(register: Char): List<KeyStroke>? {
val reg = VimPlugin.getRegister().getRegister(register) ?: return null val reg = VimPlugin.getRegister().getRegister(register) ?: return null
return reg.keys return reg.keys
} }
@JvmStatic @JvmStatic
public fun getRegisterForCaret(register: Char, caret: VimCaret): List<KeyStroke>? { fun getRegisterForCaret(register: Char, caret: VimCaret): List<KeyStroke>? {
val reg = caret.registerStorage.getRegister(register) ?: return null val reg = caret.registerStorage.getRegister(register) ?: return null
return reg.keys return reg.keys
} }
/** Set the current contents of the given register */ /** Set the current contents of the given register */
@JvmStatic @JvmStatic
public fun setRegister(register: Char, keys: List<KeyStroke?>?) { fun setRegister(register: Char, keys: List<KeyStroke?>?) {
VimPlugin.getRegister().setKeys(register, keys?.filterNotNull() ?: emptyList()) VimPlugin.getRegister().setKeys(register, keys?.filterNotNull() ?: emptyList())
} }
/** Set the current contents of the given register */ /** Set the current contents of the given register */
@JvmStatic @JvmStatic
public fun setRegisterForCaret(register: Char, caret: ImmutableVimCaret, keys: List<KeyStroke?>?) { fun setRegisterForCaret(register: Char, caret: ImmutableVimCaret, keys: List<KeyStroke?>?) {
caret.registerStorage.setKeys(register, keys?.filterNotNull() ?: emptyList()) caret.registerStorage.setKeys(register, keys?.filterNotNull() ?: emptyList())
} }
/** Set the current contents of the given register */ /** Set the current contents of the given register */
@JvmStatic @JvmStatic
public fun setRegister(register: Char, keys: List<KeyStroke?>?, type: SelectionType) { fun setRegister(register: Char, keys: List<KeyStroke?>?, type: SelectionType) {
VimPlugin.getRegister().setKeys(register, keys?.filterNotNull() ?: emptyList(), type) VimPlugin.getRegister().setKeys(register, keys?.filterNotNull() ?: emptyList(), type)
} }
@JvmStatic @JvmStatic
public fun exportScriptFunction( fun exportScriptFunction(
scope: Scope?, scope: Scope?,
name: String, name: String,
args: List<String>, args: List<String>,
@ -253,7 +253,7 @@ public object VimExtensionFacade {
} }
} }
public fun VimExtensionFacade.exportOperatorFunction(name: String, function: OperatorFunction) { fun VimExtensionFacade.exportOperatorFunction(name: String, function: OperatorFunction) {
exportScriptFunction(null, name, listOf("type"), emptyList(), false, noneOfEnum()) { exportScriptFunction(null, name, listOf("type"), emptyList(), false, noneOfEnum()) {
editor, context, args -> editor, context, args ->
@ -274,6 +274,6 @@ public fun VimExtensionFacade.exportOperatorFunction(name: String, function: Ope
} }
} }
public fun interface ScriptFunction { fun interface ScriptFunction {
public fun execute(editor: VimEditor, context: ExecutionContext, args: Map<String, VimDataType>): ExecutionResult fun execute(editor: VimEditor, context: ExecutionContext, args: Map<String, VimDataType>): ExecutionResult
} }

View File

@ -19,12 +19,12 @@ import com.maddyhome.idea.vim.newapi.ij
* COMPATIBILITY-LAYER: Created a class, renamed original class * COMPATIBILITY-LAYER: Created a class, renamed original class
* Please see: https://jb.gg/zo8n0r * Please see: https://jb.gg/zo8n0r
*/ */
public interface VimExtensionHandler : ExtensionHandler { interface VimExtensionHandler : ExtensionHandler {
override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) { override fun execute(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments) {
execute(editor.ij, context.ij) execute(editor.ij, context.ij)
} }
public fun execute(editor: Editor, context: DataContext) fun execute(editor: Editor, context: DataContext)
public abstract class WithCallback : ExtensionHandler.WithCallback(), VimExtensionHandler abstract class WithCallback : ExtensionHandler.WithCallback(), VimExtensionHandler
} }

View File

@ -85,7 +85,7 @@ import kotlin.math.min
/** /**
* Provides all the insert/replace related functionality * Provides all the insert/replace related functionality
*/ */
public class ChangeGroup : VimChangeGroupBase() { class ChangeGroup : VimChangeGroupBase() {
private val insertListeners = ContainerUtil.createLockFreeCopyOnWriteList<VimInsertListener>() private val insertListeners = ContainerUtil.createLockFreeCopyOnWriteList<VimInsertListener>()
private val listener: EditorMouseListener = object : EditorMouseListener { private val listener: EditorMouseListener = object : EditorMouseListener {
override fun mouseClicked(event: EditorMouseEvent) { override fun mouseClicked(event: EditorMouseEvent) {
@ -96,7 +96,7 @@ public class ChangeGroup : VimChangeGroupBase() {
} }
} }
public fun editorCreated(editor: Editor?, disposable: Disposable) { fun editorCreated(editor: Editor?, disposable: Disposable) {
EventFacade.getInstance().addEditorMouseListener(editor!!, listener, disposable) EventFacade.getInstance().addEditorMouseListener(editor!!, listener, disposable)
} }
@ -790,11 +790,11 @@ public class ChangeGroup : VimChangeGroupBase() {
return number return number
} }
public fun addInsertListener(listener: VimInsertListener) { fun addInsertListener(listener: VimInsertListener) {
insertListeners.add(listener) insertListeners.add(listener)
} }
public fun removeInsertListener(listener: VimInsertListener) { fun removeInsertListener(listener: VimInsertListener) {
insertListeners.remove(listener) insertListeners.remove(listener)
} }

View File

@ -47,7 +47,7 @@ import com.maddyhome.idea.vim.state.mode.Mode.VISUAL
import java.io.File import java.io.File
import java.util.* import java.util.*
public class FileGroup public constructor() : VimFileBase() { class FileGroup : VimFileBase() {
override fun openFile(filename: String, context: ExecutionContext): Boolean { override fun openFile(filename: String, context: ExecutionContext): Boolean {
if (logger.isDebugEnabled) { if (logger.isDebugEnabled) {
logger.debug("openFile($filename)") logger.debug("openFile($filename)")
@ -82,7 +82,7 @@ public class FileGroup public constructor() : VimFileBase() {
} }
} }
public fun findFile(filename: String, project: Project): VirtualFile? { fun findFile(filename: String, project: Project): VirtualFile? {
var found: VirtualFile? var found: VirtualFile?
// Vim supports both ~/ and ~\ (tested on Mac and Windows). On Windows, it supports forward- and back-slashes, but // Vim supports both ~/ and ~\ (tested on Mac and Windows). On Windows, it supports forward- and back-slashes, but
// it only supports forward slash on Unix (tested on Mac) // it only supports forward slash on Unix (tested on Mac)
@ -242,7 +242,7 @@ public class FileGroup public constructor() : VimFileBase() {
/** /**
* Returns the previous tab. * Returns the previous tab.
*/ */
public fun getPreviousTab(context: DataContext): VirtualFile? { fun getPreviousTab(context: DataContext): VirtualFile? {
val project = PlatformDataKeys.PROJECT.getData(context) ?: return null val project = PlatformDataKeys.PROJECT.getData(context) ?: return null
val vf = getInstance(project).lastTab val vf = getInstance(project).lastTab
if (vf != null && vf.isValid) { if (vf != null && vf.isValid) {
@ -251,7 +251,7 @@ public class FileGroup public constructor() : VimFileBase() {
return null return null
} }
public fun selectEditor(project: Project, file: VirtualFile): Editor? { fun selectEditor(project: Project, file: VirtualFile): Editor? {
val fMgr = FileEditorManager.getInstance(project) val fMgr = FileEditorManager.getInstance(project)
val feditors = fMgr.openFile(file, true) val feditors = fMgr.openFile(file, true)
if (feditors.size > 0) { if (feditors.size > 0) {
@ -418,7 +418,7 @@ public class FileGroup public constructor() : VimFileBase() {
return project.name + "-" + project.locationHash return project.name + "-" + project.locationHash
} }
public companion object { companion object {
private fun findByNameInProject(filename: String, project: Project): VirtualFile? { private fun findByNameInProject(filename: String, project: Project): VirtualFile? {
val projectScope = ProjectScope.getProjectScope(project) val projectScope = ProjectScope.getProjectScope(project)
val names = FilenameIndex.getVirtualFilesByName(filename, projectScope) val names = FilenameIndex.getVirtualFilesByName(filename, projectScope)
@ -435,7 +435,7 @@ public class FileGroup public constructor() : VimFileBase() {
/** /**
* Respond to editor tab selection and remember the last used tab * Respond to editor tab selection and remember the last used tab
*/ */
public fun fileEditorManagerSelectionChangedCallback(event: FileEditorManagerEvent) { fun fileEditorManagerSelectionChangedCallback(event: FileEditorManagerEvent) {
if (event.oldFile != null) { if (event.oldFile != null) {
getInstance(event.manager.project).lastTab = event.oldFile getInstance(event.manager.project).lastTab = event.oldFile
} }

View File

@ -19,22 +19,22 @@ import com.maddyhome.idea.vim.options.OptionAccessScope
* options * options
*/ */
@Suppress("SpellCheckingInspection") @Suppress("SpellCheckingInspection")
public open class GlobalIjOptions(scope: OptionAccessScope) : OptionsPropertiesBase(scope) { open class GlobalIjOptions(scope: OptionAccessScope) : OptionsPropertiesBase(scope) {
public var ide: String by optionProperty(IjOptions.ide) var ide: String by optionProperty(IjOptions.ide)
public var ideamarks: Boolean by optionProperty(IjOptions.ideamarks) var ideamarks: Boolean by optionProperty(IjOptions.ideamarks)
public var ideastatusicon: String by optionProperty(IjOptions.ideastatusicon) var ideastatusicon: String by optionProperty(IjOptions.ideastatusicon)
public val ideavimsupport: StringListOptionValue by optionProperty(IjOptions.ideavimsupport) val ideavimsupport: StringListOptionValue by optionProperty(IjOptions.ideavimsupport)
public var ideawrite: String by optionProperty(IjOptions.ideawrite) var ideawrite: String by optionProperty(IjOptions.ideawrite)
public val lookupkeys: StringListOptionValue by optionProperty(IjOptions.lookupkeys) val lookupkeys: StringListOptionValue by optionProperty(IjOptions.lookupkeys)
public var trackactionids: Boolean by optionProperty(IjOptions.trackactionids) var trackactionids: Boolean by optionProperty(IjOptions.trackactionids)
public var visualdelay: Int by optionProperty(IjOptions.visualdelay) var visualdelay: Int by optionProperty(IjOptions.visualdelay)
// Temporary options to control work-in-progress behaviour // Temporary options to control work-in-progress behaviour
public var closenotebooks: Boolean by optionProperty(IjOptions.closenotebooks) var closenotebooks: Boolean by optionProperty(IjOptions.closenotebooks)
public var commandOrMotionAnnotation: Boolean by optionProperty(IjOptions.commandOrMotionAnnotation) var commandOrMotionAnnotation: Boolean by optionProperty(IjOptions.commandOrMotionAnnotation)
public var oldundo: Boolean by optionProperty(IjOptions.oldundo) var oldundo: Boolean by optionProperty(IjOptions.oldundo)
public var unifyjumps: Boolean by optionProperty(IjOptions.unifyjumps) var unifyjumps: Boolean by optionProperty(IjOptions.unifyjumps)
public var vimscriptFunctionAnnotation: Boolean by optionProperty(IjOptions.vimscriptFunctionAnnotation) var vimscriptFunctionAnnotation: Boolean by optionProperty(IjOptions.vimscriptFunctionAnnotation)
} }
/** /**
@ -42,20 +42,20 @@ public open class GlobalIjOptions(scope: OptionAccessScope) : OptionsPropertiesB
* *
* As a convenience, this class also provides access to the IntelliJ specific global options, via inheritance. * As a convenience, this class also provides access to the IntelliJ specific global options, via inheritance.
*/ */
public class EffectiveIjOptions(scope: OptionAccessScope.EFFECTIVE): GlobalIjOptions(scope) { class EffectiveIjOptions(scope: OptionAccessScope.EFFECTIVE): GlobalIjOptions(scope) {
// Vim options that are implemented purely by existing IntelliJ features and not used by vim-engine // Vim options that are implemented purely by existing IntelliJ features and not used by vim-engine
public var breakindent: Boolean by optionProperty(IjOptions.breakindent) var breakindent: Boolean by optionProperty(IjOptions.breakindent)
public val colorcolumn: StringListOptionValue by optionProperty(IjOptions.colorcolumn) val colorcolumn: StringListOptionValue by optionProperty(IjOptions.colorcolumn)
public var cursorline: Boolean by optionProperty(IjOptions.cursorline) var cursorline: Boolean by optionProperty(IjOptions.cursorline)
public var fileformat: String by optionProperty(IjOptions.fileformat) var fileformat: String by optionProperty(IjOptions.fileformat)
public var list: Boolean by optionProperty(IjOptions.list) var list: Boolean by optionProperty(IjOptions.list)
public var number: Boolean by optionProperty(IjOptions.number) var number: Boolean by optionProperty(IjOptions.number)
public var relativenumber: Boolean by optionProperty(IjOptions.relativenumber) var relativenumber: Boolean by optionProperty(IjOptions.relativenumber)
public var textwidth: Int by optionProperty(IjOptions.textwidth) var textwidth: Int by optionProperty(IjOptions.textwidth)
public var wrap: Boolean by optionProperty(IjOptions.wrap) var wrap: Boolean by optionProperty(IjOptions.wrap)
// IntelliJ specific options // IntelliJ specific options
public var ideacopypreprocess: Boolean by optionProperty(IjOptions.ideacopypreprocess) var ideacopypreprocess: Boolean by optionProperty(IjOptions.ideacopypreprocess)
public var ideajoin: Boolean by optionProperty(IjOptions.ideajoin) var ideajoin: Boolean by optionProperty(IjOptions.ideajoin)
public var idearefactormode: String by optionProperty(IjOptions.idearefactormode) var idearefactormode: String by optionProperty(IjOptions.idearefactormode)
} }

View File

@ -26,9 +26,9 @@ import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString
@Suppress("SpellCheckingInspection") @Suppress("SpellCheckingInspection")
public object IjOptions { object IjOptions {
public fun initialise() { fun initialise() {
// Calling this method allows for deterministic initialisation of IjOptions, specifically initialising the // Calling this method allows for deterministic initialisation of IjOptions, specifically initialising the
// properties and registering the IJ specific options. Once added, they can be safely accessed by name, e.g. by the // properties and registering the IJ specific options. Once added, they can be safely accessed by name, e.g. by the
// implementation of `:set` while executing ~/.ideavimrc // implementation of `:set` while executing ~/.ideavimrc
@ -39,8 +39,8 @@ public object IjOptions {
} }
// Vim options that are implemented purely by existing IntelliJ features and not used by vim-engine // Vim options that are implemented purely by existing IntelliJ features and not used by vim-engine
public val breakindent: ToggleOption = addOption(ToggleOption("breakindent", LOCAL_TO_WINDOW, "bri", false)) val breakindent: ToggleOption = addOption(ToggleOption("breakindent", LOCAL_TO_WINDOW, "bri", false))
public val colorcolumn: StringListOption = addOption(object : StringListOption("colorcolumn", LOCAL_TO_WINDOW, "cc", "") { val colorcolumn: StringListOption = addOption(object : StringListOption("colorcolumn", LOCAL_TO_WINDOW, "cc", "") {
override fun checkIfValueValid(value: VimDataType, token: String) { override fun checkIfValueValid(value: VimDataType, token: String) {
super.checkIfValueValid(value, token) super.checkIfValueValid(value, token)
if (value != VimString.EMPTY) { if (value != VimString.EMPTY) {
@ -55,19 +55,19 @@ public object IjOptions {
} }
} }
}) })
public val cursorline: ToggleOption = addOption(ToggleOption("cursorline", LOCAL_TO_WINDOW, "cul", false)) val cursorline: ToggleOption = addOption(ToggleOption("cursorline", LOCAL_TO_WINDOW, "cul", false))
public val list: ToggleOption = addOption(ToggleOption("list", LOCAL_TO_WINDOW, "list", false)) val list: ToggleOption = addOption(ToggleOption("list", LOCAL_TO_WINDOW, "list", false))
public val number: ToggleOption = addOption(ToggleOption("number", LOCAL_TO_WINDOW, "nu", false)) val number: ToggleOption = addOption(ToggleOption("number", LOCAL_TO_WINDOW, "nu", false))
public val relativenumber: ToggleOption = addOption(ToggleOption("relativenumber", LOCAL_TO_WINDOW, "rnu", false)) val relativenumber: ToggleOption = addOption(ToggleOption("relativenumber", LOCAL_TO_WINDOW, "rnu", false))
public val textwidth: NumberOption = addOption(UnsignedNumberOption("textwidth", LOCAL_TO_BUFFER, "tw", 0)) val textwidth: NumberOption = addOption(UnsignedNumberOption("textwidth", LOCAL_TO_BUFFER, "tw", 0))
public val wrap: ToggleOption = addOption(ToggleOption("wrap", LOCAL_TO_WINDOW, "wrap", true)) val wrap: ToggleOption = addOption(ToggleOption("wrap", LOCAL_TO_WINDOW, "wrap", true))
// These options are not explicitly listed as local-noglobal in Vim's help, but are set when a new buffer is edited, // These options are not explicitly listed as local-noglobal in Vim's help, but are set when a new buffer is edited,
// based on the value of 'fileformats' or 'fileencodings'. To prevent unexpected file conversion, we treat them as // based on the value of 'fileformats' or 'fileencodings'. To prevent unexpected file conversion, we treat them as
// local-noglobal. See `:help local-noglobal`, `:help 'fileformats'` and `:help 'fileencodings'` // local-noglobal. See `:help local-noglobal`, `:help 'fileformats'` and `:help 'fileencodings'`
public val bomb: ToggleOption = val bomb: ToggleOption =
addOption(ToggleOption("bomb", LOCAL_TO_BUFFER, "bomb", false, isLocalNoGlobal = true)) addOption(ToggleOption("bomb", LOCAL_TO_BUFFER, "bomb", false, isLocalNoGlobal = true))
public val fileencoding: StringOption = addOption( val fileencoding: StringOption = addOption(
StringOption( StringOption(
"fileencoding", "fileencoding",
LOCAL_TO_BUFFER, LOCAL_TO_BUFFER,
@ -76,7 +76,7 @@ public object IjOptions {
isLocalNoGlobal = true isLocalNoGlobal = true
) )
) )
public val fileformat: StringOption = addOption( val fileformat: StringOption = addOption(
StringOption( StringOption(
"fileformat", "fileformat",
LOCAL_TO_BUFFER, LOCAL_TO_BUFFER,
@ -88,15 +88,15 @@ public object IjOptions {
) )
// IntelliJ specific functionality - custom options // IntelliJ specific functionality - custom options
public val ide: StringOption = addOption( val ide: StringOption = addOption(
StringOption("ide", GLOBAL, "ide", ApplicationNamesInfo.getInstance().fullProductNameWithEdition) StringOption("ide", GLOBAL, "ide", ApplicationNamesInfo.getInstance().fullProductNameWithEdition)
) )
public val ideacopypreprocess: ToggleOption = addOption( val ideacopypreprocess: ToggleOption = addOption(
ToggleOption("ideacopypreprocess", GLOBAL_OR_LOCAL_TO_BUFFER, "ideacopypreprocess", false) ToggleOption("ideacopypreprocess", GLOBAL_OR_LOCAL_TO_BUFFER, "ideacopypreprocess", false)
) )
public val ideajoin: ToggleOption = addOption(ToggleOption("ideajoin", GLOBAL_OR_LOCAL_TO_BUFFER, "ideajoin", false)) val ideajoin: ToggleOption = addOption(ToggleOption("ideajoin", GLOBAL_OR_LOCAL_TO_BUFFER, "ideajoin", false))
public val ideamarks: ToggleOption = addOption(ToggleOption("ideamarks", GLOBAL, "ideamarks", true)) val ideamarks: ToggleOption = addOption(ToggleOption("ideamarks", GLOBAL, "ideamarks", true))
public val idearefactormode: StringOption = addOption( val idearefactormode: StringOption = addOption(
StringOption( StringOption(
"idearefactormode", "idearefactormode",
GLOBAL_OR_LOCAL_TO_BUFFER, GLOBAL_OR_LOCAL_TO_BUFFER,
@ -105,7 +105,7 @@ public object IjOptions {
IjOptionConstants.ideaRefactorModeValues IjOptionConstants.ideaRefactorModeValues
) )
) )
public val ideastatusicon: StringOption = addOption( val ideastatusicon: StringOption = addOption(
StringOption( StringOption(
"ideastatusicon", "ideastatusicon",
GLOBAL, GLOBAL,
@ -114,7 +114,7 @@ public object IjOptions {
IjOptionConstants.ideaStatusIconValues IjOptionConstants.ideaStatusIconValues
) )
) )
public val ideavimsupport: StringListOption = addOption( val ideavimsupport: StringListOption = addOption(
StringListOption( StringListOption(
"ideavimsupport", "ideavimsupport",
GLOBAL, GLOBAL,
@ -123,25 +123,26 @@ public object IjOptions {
IjOptionConstants.ideavimsupportValues IjOptionConstants.ideavimsupportValues
) )
) )
@JvmField public val ideawrite: StringOption = addOption( @JvmField
val ideawrite: StringOption = addOption(
StringOption("ideawrite", GLOBAL, "ideawrite", "all", IjOptionConstants.ideaWriteValues) StringOption("ideawrite", GLOBAL, "ideawrite", "all", IjOptionConstants.ideaWriteValues)
) )
public val lookupkeys: StringListOption = addOption( val lookupkeys: StringListOption = addOption(
StringListOption( StringListOption(
"lookupkeys", "lookupkeys",
GLOBAL, GLOBAL,
"lookupkeys", "lookupkeys",
"<Tab>,<Down>,<Up>,<Enter>,<Left>,<Right>,<C-Down>,<C-Up>,<PageUp>,<PageDown>,<C-J>,<C-Q>") "<Tab>,<Down>,<Up>,<Enter>,<Left>,<Right>,<C-Down>,<C-Up>,<PageUp>,<PageDown>,<C-J>,<C-Q>")
) )
public val trackactionids: ToggleOption = addOption(ToggleOption("trackactionids", GLOBAL, "tai", false)) val trackactionids: ToggleOption = addOption(ToggleOption("trackactionids", GLOBAL, "tai", false))
public val visualdelay: UnsignedNumberOption = addOption(UnsignedNumberOption("visualdelay", GLOBAL, "visualdelay", 100)) val visualdelay: UnsignedNumberOption = addOption(UnsignedNumberOption("visualdelay", GLOBAL, "visualdelay", 100))
// Temporary feature flags during development, not really intended for external use // Temporary feature flags during development, not really intended for external use
public val closenotebooks: ToggleOption = addOption(ToggleOption("closenotebooks", GLOBAL, "closenotebooks", true, isHidden = true)) val closenotebooks: ToggleOption = addOption(ToggleOption("closenotebooks", GLOBAL, "closenotebooks", true, isHidden = true))
public val commandOrMotionAnnotation: ToggleOption = addOption(ToggleOption("commandormotionannotation", GLOBAL, "commandormotionannotation", true, isHidden = true)) val commandOrMotionAnnotation: ToggleOption = addOption(ToggleOption("commandormotionannotation", GLOBAL, "commandormotionannotation", true, isHidden = true))
public val oldundo: ToggleOption = addOption(ToggleOption("oldundo", GLOBAL, "oldundo", false, isHidden = true)) val oldundo: ToggleOption = addOption(ToggleOption("oldundo", GLOBAL, "oldundo", false, isHidden = true))
public val unifyjumps: ToggleOption = addOption(ToggleOption("unifyjumps", GLOBAL, "unifyjumps", true, isHidden = true)) val unifyjumps: ToggleOption = addOption(ToggleOption("unifyjumps", GLOBAL, "unifyjumps", true, isHidden = true))
public val vimscriptFunctionAnnotation: ToggleOption = addOption(ToggleOption("vimscriptfunctionannotation", GLOBAL, "vimscriptfunctionannotation", true, isHidden = true)) val vimscriptFunctionAnnotation: ToggleOption = addOption(ToggleOption("vimscriptfunctionannotation", GLOBAL, "vimscriptfunctionannotation", true, isHidden = true))
// This needs to be Option<out VimDataType> so that it can work with derived option types, such as NumberOption, which // This needs to be Option<out VimDataType> so that it can work with derived option types, such as NumberOption, which
// derives from Option<VimInt> // derives from Option<VimInt>

View File

@ -21,7 +21,7 @@ import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.newapi.vim import com.maddyhome.idea.vim.newapi.vim
@Service @Service
public class IjVimPsiService: VimPsiService { class IjVimPsiService: VimPsiService {
override fun getCommentAtPos(editor: VimEditor, pos: Int): Pair<TextRange, Pair<String, String>?>? { override fun getCommentAtPos(editor: VimEditor, pos: Int): Pair<TextRange, Pair<String, String>?>? {
val psiFile = PsiHelper.getFile(editor.ij) ?: return null val psiFile = PsiHelper.getFile(editor.ij) ?: return null
val psiElement = psiFile.findElementAt(pos) ?: return null val psiElement = psiFile.findElementAt(pos) ?: return null

View File

@ -15,7 +15,7 @@ import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.VimRedrawService import com.maddyhome.idea.vim.api.VimRedrawService
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
public class IjVimRedrawService : VimRedrawService { class IjVimRedrawService : VimRedrawService {
override fun redraw() { override fun redraw() {
// The only thing IntelliJ needs to redraw is the status line. Everything else is handled automatically. // The only thing IntelliJ needs to redraw is the status line. Everything else is handled automatically.
redrawStatusLine() redrawStatusLine()
@ -25,11 +25,11 @@ public class IjVimRedrawService : VimRedrawService {
injector.messages.clearStatusBarMessage() injector.messages.clearStatusBarMessage()
} }
public companion object { companion object {
/** /**
* Simulate Vim's redraw when the current editor changes * Simulate Vim's redraw when the current editor changes
*/ */
public fun fileEditorManagerSelectionChangedCallback(event: FileEditorManagerEvent) { fun fileEditorManagerSelectionChangedCallback(event: FileEditorManagerEvent) {
injector.redrawService.redraw() injector.redrawService.redraw()
} }
} }
@ -39,7 +39,7 @@ public class IjVimRedrawService : VimRedrawService {
* *
* Only redraw if lines are added/removed. * Only redraw if lines are added/removed.
*/ */
public object RedrawListener : DocumentListener { object RedrawListener : DocumentListener {
override fun documentChanged(event: DocumentEvent) { override fun documentChanged(event: DocumentEvent) {
if (VimPlugin.isNotEnabled()) return if (VimPlugin.isNotEnabled()) return
if (event.newFragment.contains("\n") || event.oldFragment.contains("\n")) { if (event.newFragment.contains("\n") || event.oldFragment.contains("\n")) {

View File

@ -1313,28 +1313,28 @@ private class WrapOptionMapper(wrapOption: ToggleOption, internalOptionValueAcce
} }
public class IjOptionConstants { class IjOptionConstants {
@Suppress("SpellCheckingInspection", "MemberVisibilityCanBePrivate", "ConstPropertyName") @Suppress("SpellCheckingInspection", "MemberVisibilityCanBePrivate", "ConstPropertyName")
public companion object { companion object {
public const val idearefactormode_keep: String = "keep" const val idearefactormode_keep: String = "keep"
public const val idearefactormode_select: String = "select" const val idearefactormode_select: String = "select"
public const val idearefactormode_visual: String = "visual" const val idearefactormode_visual: String = "visual"
public const val ideastatusicon_enabled: String = "enabled" const val ideastatusicon_enabled: String = "enabled"
public const val ideastatusicon_gray: String = "gray" const val ideastatusicon_gray: String = "gray"
public const val ideastatusicon_disabled: String = "disabled" const val ideastatusicon_disabled: String = "disabled"
public const val ideavimsupport_dialog: String = "dialog" const val ideavimsupport_dialog: String = "dialog"
public const val ideavimsupport_singleline: String = "singleline" const val ideavimsupport_singleline: String = "singleline"
public const val ideavimsupport_dialoglegacy: String = "dialoglegacy" const val ideavimsupport_dialoglegacy: String = "dialoglegacy"
public const val ideawrite_all: String = "all" const val ideawrite_all: String = "all"
public const val ideawrite_file: String = "file" const val ideawrite_file: String = "file"
public val ideaStatusIconValues: Set<String> = setOf(ideastatusicon_enabled, ideastatusicon_gray, ideastatusicon_disabled) val ideaStatusIconValues: Set<String> = setOf(ideastatusicon_enabled, ideastatusicon_gray, ideastatusicon_disabled)
public val ideaRefactorModeValues: Set<String> = setOf(idearefactormode_keep, idearefactormode_select, idearefactormode_visual) val ideaRefactorModeValues: Set<String> = setOf(idearefactormode_keep, idearefactormode_select, idearefactormode_visual)
public val ideaWriteValues: Set<String> = setOf(ideawrite_all, ideawrite_file) val ideaWriteValues: Set<String> = setOf(ideawrite_all, ideawrite_file)
public val ideavimsupportValues: Set<String> = setOf(ideavimsupport_dialog, ideavimsupport_singleline, ideavimsupport_dialoglegacy) val ideavimsupportValues: Set<String> = setOf(ideavimsupport_dialog, ideavimsupport_singleline, ideavimsupport_dialoglegacy)
} }
} }

View File

@ -31,9 +31,9 @@ import java.io.Reader
import java.io.Writer import java.io.Writer
public class ProcessGroup : VimProcessGroupBase() { class ProcessGroup : VimProcessGroupBase() {
@Throws(ExecutionException::class, ProcessCanceledException::class) @Throws(ExecutionException::class, ProcessCanceledException::class)
public override fun executeCommand( override fun executeCommand(
editor: VimEditor, editor: VimEditor,
command: String, command: String,
input: CharSequence?, input: CharSequence?,
@ -132,7 +132,7 @@ public class ProcessGroup : VimProcessGroupBase() {
} }
} }
public companion object { companion object {
private val logger = logger<ProcessGroup>() private val logger = logger<ProcessGroup>()
} }
} }

View File

@ -53,12 +53,12 @@ import javax.swing.Timer
* no adjustment gets performed and IdeaVim stays in insert mode. * no adjustment gets performed and IdeaVim stays in insert mode.
*/ */
// Do not remove until it's used in EasyMotion plugin in tests // Do not remove until it's used in EasyMotion plugin in tests
public object VimVisualTimer { object VimVisualTimer {
public var swingTimer: Timer? = null var swingTimer: Timer? = null
public var mode: Mode? = null var mode: Mode? = null
public inline fun singleTask(currentMode: Mode, crossinline task: (initialMode: Mode?) -> Unit) { inline fun singleTask(currentMode: Mode, crossinline task: (initialMode: Mode?) -> Unit) {
swingTimer?.stop() swingTimer?.stop()
if (mode == null) mode = currentMode if (mode == null) mode = currentMode
@ -70,7 +70,7 @@ public object VimVisualTimer {
swingTimer = timer swingTimer = timer
} }
public fun doNow() { fun doNow() {
val swingTimer1 = swingTimer val swingTimer1 = swingTimer
if (swingTimer1 != null) { if (swingTimer1 != null) {
swingTimer1.stop() swingTimer1.stop()
@ -80,12 +80,12 @@ public object VimVisualTimer {
} }
} }
public fun drop() { fun drop() {
swingTimer?.stop() swingTimer?.stop()
swingTimer = null swingTimer = null
} }
public inline fun timerAction(task: (initialMode: Mode?) -> Unit) { inline fun timerAction(task: (initialMode: Mode?) -> Unit) {
task(mode) task(mode)
swingTimer = null swingTimer = null
mode = null mode = null

View File

@ -144,7 +144,7 @@ private object AttributesCache {
@TestOnly @TestOnly
internal fun getGuiCursorMode(editor: Editor) = editor.guicursorMode() internal fun getGuiCursorMode(editor: Editor) = editor.guicursorMode()
public class CaretVisualAttributesListener : IsReplaceCharListener, ModeChangeListener { class CaretVisualAttributesListener : IsReplaceCharListener, ModeChangeListener {
override fun isReplaceCharChanged(editor: VimEditor) { override fun isReplaceCharChanged(editor: VimEditor) {
updateCaretsVisual(editor) updateCaretsVisual(editor)
} }
@ -163,7 +163,7 @@ public class CaretVisualAttributesListener : IsReplaceCharListener, ModeChangeLi
} }
} }
public fun updateAllEditorsCaretsVisual() { fun updateAllEditorsCaretsVisual() {
injector.editorGroup.getEditors().forEach { editor -> injector.editorGroup.getEditors().forEach { editor ->
val ijEditor = (editor as IjVimEditor).editor val ijEditor = (editor as IjVimEditor).editor
ijEditor.updateCaretsVisualAttributes() ijEditor.updateCaretsVisualAttributes()

View File

@ -21,15 +21,15 @@ internal val Mode.hasVisualSelection
else -> false else -> false
} }
public val Mode.inNormalMode: Boolean val Mode.inNormalMode: Boolean
get() = this is Mode.NORMAL get() = this is Mode.NORMAL
@get:JvmName("inInsertMode") @get:JvmName("inInsertMode")
public val Editor.inInsertMode: Boolean val Editor.inInsertMode: Boolean
get() = this.vim.mode == Mode.INSERT || this.vim.mode == Mode.REPLACE get() = this.vim.mode == Mode.INSERT || this.vim.mode == Mode.REPLACE
@get:JvmName("inVisualMode") @get:JvmName("inVisualMode")
public val Editor.inVisualMode: Boolean val Editor.inVisualMode: Boolean
get() = this.vim.inVisualMode get() = this.vim.inVisualMode
@get:JvmName("inExMode") @get:JvmName("inExMode")

View File

@ -25,7 +25,7 @@ import javax.swing.JComponent
import javax.swing.JTable import javax.swing.JTable
@Deprecated("Use fileSize from VimEditor") @Deprecated("Use fileSize from VimEditor")
public val Editor.fileSize: Int val Editor.fileSize: Int
get() = document.textLength get() = document.textLength
/** /**

View File

@ -58,7 +58,7 @@ private fun containsUpperCase(pattern: String): Boolean {
/** /**
* This counts all the words in the file. * This counts all the words in the file.
*/ */
public fun countWords( fun countWords(
vimEditor: VimEditor, vimEditor: VimEditor,
start: Int = 0, start: Int = 0,
end: Long = vimEditor.fileSize(), end: Long = vimEditor.fileSize(),
@ -97,7 +97,7 @@ public fun countWords(
return CountPosition(count, position) return CountPosition(count, position)
} }
public fun findNumbersInRange( fun findNumbersInRange(
editor: Editor, editor: Editor,
textRange: TextRange, textRange: TextRange,
alpha: Boolean, alpha: Boolean,
@ -133,7 +133,7 @@ public fun findNumbersInRange(
return result return result
} }
public fun findNumberUnderCursor( fun findNumberUnderCursor(
editor: Editor, editor: Editor,
caret: Caret, caret: Caret,
alpha: Boolean, alpha: Boolean,
@ -163,7 +163,7 @@ public fun findNumberUnderCursor(
* @param startPosOnLine - start offset to search * @param startPosOnLine - start offset to search
* @return - text range with number * @return - text range with number
*/ */
public fun findNumberInText( fun findNumberInText(
textInRange: String, textInRange: String,
startPosOnLine: Int, startPosOnLine: Int,
alpha: Boolean, alpha: Boolean,
@ -308,7 +308,7 @@ private fun isNumberChar(ch: Char, alpha: Boolean, hex: Boolean, octal: Boolean,
* @param caret The caret to find word under * @param caret The caret to find word under
* @return The text range of the found word or null if there is no word under/after the cursor on the line * @return The text range of the found word or null if there is no word under/after the cursor on the line
*/ */
public fun findWordUnderCursor(editor: Editor, caret: Caret): TextRange? { fun findWordUnderCursor(editor: Editor, caret: Caret): TextRange? {
val vimEditor = IjVimEditor(editor) val vimEditor = IjVimEditor(editor)
val chars = editor.document.charsSequence val chars = editor.document.charsSequence
val stop = vimEditor.getLineEndOffset(caret.logicalPosition.line, true) val stop = vimEditor.getLineEndOffset(caret.logicalPosition.line, true)
@ -359,7 +359,7 @@ public fun findWordUnderCursor(editor: Editor, caret: Caret): TextRange? {
return TextRange(start, end) return TextRange(start, end)
} }
public fun findMisspelledWords( fun findMisspelledWords(
editor: Editor, editor: Editor,
startOffset: Int, startOffset: Int,
endOffset: Int, endOffset: Int,
@ -401,7 +401,7 @@ private fun skip(iterator: IntIterator, n: Int) {
while (i-- != 0 && iterator.hasNext()) iterator.nextInt() while (i-- != 0 && iterator.hasNext()) iterator.nextInt()
} }
public class CountPosition(public val count: Int, public val position: Int) class CountPosition(val count: Int, val position: Int)
private val logger = logger<SearchLogger>() private val logger = logger<SearchLogger>()
private class SearchLogger private class SearchLogger

View File

@ -13,11 +13,11 @@ import java.util.*
import java.util.stream.Collectors import java.util.stream.Collectors
import javax.swing.KeyStroke import javax.swing.KeyStroke
public object StringHelper { object StringHelper {
@JvmStatic @JvmStatic
@Deprecated("Use injector.parser.parseKeys(string)") @Deprecated("Use injector.parser.parseKeys(string)")
@ApiStatus.ScheduledForRemoval @ApiStatus.ScheduledForRemoval
public fun parseKeys(vararg string: String): List<KeyStroke> { fun parseKeys(vararg string: String): List<KeyStroke> {
return Arrays.stream(string).flatMap { o: String -> injector.parser.parseKeys(o).stream() } return Arrays.stream(string).flatMap { o: String -> injector.parser.parseKeys(o).stream() }
.collect(Collectors.toList()) .collect(Collectors.toList())
} }

View File

@ -12,14 +12,14 @@ import com.intellij.openapi.editor.Editor
import javax.swing.KeyStroke import javax.swing.KeyStroke
// Do not remove until it's used in EasyMotion plugin in tests // Do not remove until it's used in EasyMotion plugin in tests
public class TestInputModel private constructor() { class TestInputModel private constructor() {
private val myKeyStrokes: MutableList<KeyStroke> = Lists.newArrayList() private val myKeyStrokes: MutableList<KeyStroke> = Lists.newArrayList()
public fun setKeyStrokes(keyStrokes: List<KeyStroke>) { fun setKeyStrokes(keyStrokes: List<KeyStroke>) {
myKeyStrokes.clear() myKeyStrokes.clear()
myKeyStrokes.addAll(keyStrokes) myKeyStrokes.addAll(keyStrokes)
} }
public fun nextKeyStroke(): KeyStroke? { fun nextKeyStroke(): KeyStroke? {
// Return key from the unfinished mapping // Return key from the unfinished mapping
/* /*
MappingStack mappingStack = KeyHandler.getInstance().getMappingStack(); MappingStack mappingStack = KeyHandler.getInstance().getMappingStack();
@ -34,9 +34,9 @@ if (mappingStack.hasStroke()) {
} }
} }
public companion object { companion object {
@JvmStatic @JvmStatic
public fun getInstance(editor: Editor): TestInputModel { fun getInstance(editor: Editor): TestInputModel {
var model = editor.vimTestInputModel var model = editor.vimTestInputModel
if (model == null) { if (model == null) {
model = TestInputModel() model = TestInputModel()

View File

@ -45,7 +45,7 @@ import kotlin.reflect.KProperty
/** /**
* Caret's offset when entering visual mode * Caret's offset when entering visual mode
*/ */
public var Caret.vimSelectionStart: Int var Caret.vimSelectionStart: Int
get() { get() {
val selectionStart = _vimSelectionStart val selectionStart = _vimSelectionStart
if (selectionStart == null) { if (selectionStart == null) {

View File

@ -10,6 +10,6 @@ package com.maddyhome.idea.vim.listener
import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.Editor
public interface VimInsertListener { interface VimInsertListener {
public fun insertModeStarted(editor: Editor) fun insertModeStarted(editor: Editor)
} }

View File

@ -24,8 +24,8 @@ internal val runFromVimKey = Key.create<Boolean>("RunFromVim")
internal val DataContext.actionStartedFromVim: Boolean internal val DataContext.actionStartedFromVim: Boolean
get() = (this as? UserDataHolder)?.getUserData(runFromVimKey) ?: false get() = (this as? UserDataHolder)?.getUserData(runFromVimKey) ?: false
public val DataContext.vim: ExecutionContext val DataContext.vim: ExecutionContext
get() = IjEditorExecutionContext(this) get() = IjEditorExecutionContext(this)
public val ExecutionContext.ij: DataContext val ExecutionContext.ij: DataContext
get() = (this as IjEditorExecutionContext).context get() = (this as IjEditorExecutionContext).context

View File

@ -16,8 +16,8 @@ internal class IjLiveRange(val marker: RangeMarker) : LiveRange {
get() = marker.startOffset get() = marker.startOffset
} }
public val RangeMarker.vim: LiveRange val RangeMarker.vim: LiveRange
get() = IjLiveRange(this) get() = IjLiveRange(this)
public val LiveRange.ij: RangeMarker val LiveRange.ij: RangeMarker
get() = (this as IjLiveRange).marker get() = (this as IjLiveRange).marker

View File

@ -31,10 +31,10 @@ internal class IjNativeActionManager : NativeActionManager {
} }
} }
public val AnAction.vim: IjNativeAction val AnAction.vim: IjNativeAction
get() = IjNativeAction(this) get() = IjNativeAction(this)
public class IjNativeAction(override val action: AnAction) : NativeAction { class IjNativeAction(override val action: AnAction) : NativeAction {
override fun toString(): String { override fun toString(): String {
return "IjNativeAction(action=$action)" return "IjNativeAction(action=$action)"
} }

View File

@ -206,10 +206,10 @@ internal class IjVimCaret(val caret: Caret) : VimCaretBase() {
override fun hashCode(): Int = this.caret.hashCode() override fun hashCode(): Int = this.caret.hashCode()
} }
public val VimCaret.ij: Caret val VimCaret.ij: Caret
get() = (this as IjVimCaret).caret get() = (this as IjVimCaret).caret
public val ImmutableVimCaret.ij: Caret val ImmutableVimCaret.ij: Caret
get() = (this as IjVimCaret).caret get() = (this as IjVimCaret).caret
public val Caret.vim: VimCaret val Caret.vim: VimCaret
get() = IjVimCaret(this) get() = IjVimCaret(this)

View File

@ -499,12 +499,12 @@ internal class IjVimEditor(editor: Editor) : MutableLinearEditor() {
} }
} }
public val Editor.vim: VimEditor val Editor.vim: VimEditor
get() = IjVimEditor(this) get() = IjVimEditor(this)
public val VimEditor.ij: Editor val VimEditor.ij: Editor
get() = (this as IjVimEditor).editor get() = (this as IjVimEditor).editor
public val com.intellij.openapi.util.TextRange.vim: TextRange val com.intellij.openapi.util.TextRange.vim: TextRange
get() = TextRange(this.startOffset, this.endOffset) get() = TextRange(this.startOffset, this.endOffset)
internal class InsertTimeRecorder: ModeChangeListener { internal class InsertTimeRecorder: ModeChangeListener {

View File

@ -232,10 +232,10 @@ internal class IjVimInjector : VimInjectorBase() {
/** /**
* Convenience function to get the IntelliJ implementation specific global option accessor * Convenience function to get the IntelliJ implementation specific global option accessor
*/ */
public fun VimInjector.globalIjOptions(): GlobalIjOptions = (this.optionGroup as IjVimOptionGroup).getGlobalIjOptions() fun VimInjector.globalIjOptions(): GlobalIjOptions = (this.optionGroup as IjVimOptionGroup).getGlobalIjOptions()
/** /**
* Convenience function to get the IntelliJ implementation specific option accessor for the given editor's scope * Convenience function to get the IntelliJ implementation specific option accessor for the given editor's scope
*/ */
public fun VimInjector.ijOptions(editor: VimEditor): EffectiveIjOptions = fun VimInjector.ijOptions(editor: VimEditor): EffectiveIjOptions =
(this.optionGroup as IjVimOptionGroup).getEffectiveIjOptions(editor) (this.optionGroup as IjVimOptionGroup).getEffectiveIjOptions(editor)

View File

@ -50,8 +50,8 @@ import javax.swing.KeyStroke
name = "VimSearchSettings", name = "VimSearchSettings",
storages = [Storage(value = "\$APP_CONFIG$/vim_settings_local.xml", roamingType = RoamingType.DISABLED)] storages = [Storage(value = "\$APP_CONFIG$/vim_settings_local.xml", roamingType = RoamingType.DISABLED)]
) )
public open class IjVimSearchGroup : VimSearchGroupBase(), PersistentStateComponent<Element> { open class IjVimSearchGroup : VimSearchGroupBase(), PersistentStateComponent<Element> {
public companion object { companion object {
private val logger = vimLogger<IjVimSearchGroup>() private val logger = vimLogger<IjVimSearchGroup>()
} }
@ -195,7 +195,7 @@ public open class IjVimSearchGroup : VimSearchGroupBase(), PersistentStateCompon
updateSearchHighlights(false) updateSearchHighlights(false)
} }
public fun saveData(element: Element) { fun saveData(element: Element) {
logger.debug("saveData") logger.debug("saveData")
val search = Element("search") val search = Element("search")
@ -220,7 +220,7 @@ public open class IjVimSearchGroup : VimSearchGroupBase(), PersistentStateCompon
} }
} }
public fun readData(element: Element) { fun readData(element: Element) {
logger.debug("readData") logger.debug("readData")
val search = element.getChild("search") ?: return val search = element.getChild("search") ?: return
@ -266,28 +266,28 @@ public open class IjVimSearchGroup : VimSearchGroupBase(), PersistentStateCompon
return defaultValue return defaultValue
} }
public override fun getState(): Element? { override fun getState(): Element? {
val element = Element("search") val element = Element("search")
saveData(element) saveData(element)
return element return element
} }
public override fun loadState(state: Element) { override fun loadState(state: Element) {
readData(state) readData(state)
} }
/** /**
* Updates search highlights when the selected editor changes * Updates search highlights when the selected editor changes
*/ */
public fun fileEditorManagerSelectionChangedCallback(@Suppress("unused") event: FileEditorManagerEvent) { fun fileEditorManagerSelectionChangedCallback(@Suppress("unused") event: FileEditorManagerEvent) {
updateSearchHighlights(false) updateSearchHighlights(false)
} }
public fun turnOn() { fun turnOn() {
updateSearchHighlights(false) updateSearchHighlights(false)
} }
public fun turnOff() { fun turnOff() {
val show = showSearchHighlight val show = showSearchHighlight
clearSearchHighlight() clearSearchHighlight()
showSearchHighlight = show showSearchHighlight = show
@ -305,8 +305,8 @@ public open class IjVimSearchGroup : VimSearchGroupBase(), PersistentStateCompon
/** /**
* Removes and adds highlights for current search pattern when the document is edited * Removes and adds highlights for current search pattern when the document is edited
*/ */
public class DocumentSearchListener @Contract(pure = true) private constructor() : DocumentListener { class DocumentSearchListener @Contract(pure = true) private constructor() : DocumentListener {
public override fun documentChanged(event: DocumentEvent) { override fun documentChanged(event: DocumentEvent) {
// Loop over all local editors for the changed document, across all projects, and update search highlights. // Loop over all local editors for the changed document, across all projects, and update search highlights.
// Note that the change may have come from a remote guest in Code With Me scenarios (in which case // Note that the change may have come from a remote guest in Code With Me scenarios (in which case
// ClientId.current will be a guest ID), but we don't care - we still need to add/remove highlights for the // ClientId.current will be a guest ID), but we don't care - we still need to add/remove highlights for the
@ -352,8 +352,8 @@ public open class IjVimSearchGroup : VimSearchGroupBase(), PersistentStateCompon
} }
} }
public companion object { companion object {
public var INSTANCE: DocumentSearchListener = DocumentSearchListener() var INSTANCE: DocumentSearchListener = DocumentSearchListener()
} }
} }
} }

View File

@ -18,7 +18,7 @@ import com.intellij.openapi.wm.WindowManager
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.ui.widgets.mode.ModeWidgetFactory import com.maddyhome.idea.vim.ui.widgets.mode.ModeWidgetFactory
public class WidgetState : ApplicationUsagesCollector() { class WidgetState : ApplicationUsagesCollector() {
override fun getGroup(): EventLogGroup = GROUP override fun getGroup(): EventLogGroup = GROUP
override fun getMetrics(): Set<MetricEvent> { override fun getMetrics(): Set<MetricEvent> {
@ -54,7 +54,7 @@ public class WidgetState : ApplicationUsagesCollector() {
} }
} }
public companion object { companion object {
private val GROUP = EventLogGroup("vim.widget", 1, "FUS") private val GROUP = EventLogGroup("vim.widget", 1, "FUS")
private val IS_MODE_WIDGET_SHOWN = EventFields.Boolean("is-mode-widget-shown") private val IS_MODE_WIDGET_SHOWN = EventFields.Boolean("is-mode-widget-shown")

View File

@ -24,11 +24,11 @@ import javax.swing.KeyStroke
/** /**
* @author dhleong * @author dhleong
*/ */
public object ModalEntry { object ModalEntry {
public val LOG: Logger = logger<ModalEntry>() val LOG: Logger = logger<ModalEntry>()
public inline fun activate(editor: VimEditor, crossinline processor: (KeyStroke) -> Boolean) { inline fun activate(editor: VimEditor, crossinline processor: (KeyStroke) -> Boolean) {
// Firstly we pull the unfinished keys of the current mapping // Firstly we pull the unfinished keys of the current mapping
val mappingStack = KeyHandler.getInstance().keyStack val mappingStack = KeyHandler.getInstance().keyStack
LOG.trace("Dumping key stack:") LOG.trace("Dumping key stack:")

View File

@ -23,8 +23,8 @@ import com.maddyhome.idea.vim.ui.ModalEntry
import java.awt.event.KeyEvent import java.awt.event.KeyEvent
import javax.swing.KeyStroke import javax.swing.KeyStroke
public class ExEntryPanelService : VimCommandLineService { class ExEntryPanelService : VimCommandLineService {
public override fun getActiveCommandLine(): VimCommandLine? { override fun getActiveCommandLine(): VimCommandLine? {
val instance = ExEntryPanel.instance ?: ExEntryPanel.instanceWithoutShortcuts ?: return null val instance = ExEntryPanel.instance ?: ExEntryPanel.instanceWithoutShortcuts ?: return null
return if (instance.isActive) instance else null return if (instance.isActive) instance else null
} }
@ -89,13 +89,13 @@ public class ExEntryPanelService : VimCommandLineService {
} }
} }
public override fun create(editor: VimEditor, context: ExecutionContext, label: String, initText: String): VimCommandLine { override fun create(editor: VimEditor, context: ExecutionContext, label: String, initText: String): VimCommandLine {
val panel = ExEntryPanel.getInstance() val panel = ExEntryPanel.getInstance()
panel.activate(editor.ij, context.ij, label, initText) panel.activate(editor.ij, context.ij, label, initText)
return panel return panel
} }
public override fun createWithoutShortcuts(editor: VimEditor, context: ExecutionContext, label: String, initText: String): VimCommandLine { override fun createWithoutShortcuts(editor: VimEditor, context: ExecutionContext, label: String, initText: String): VimCommandLine {
val panel = ExEntryPanel.getInstanceWithoutShortcuts() val panel = ExEntryPanel.getInstanceWithoutShortcuts()
panel.activate(editor.ij, context.ij, label, initText) panel.activate(editor.ij, context.ij, label, initText)
return panel return panel

View File

@ -11,7 +11,7 @@ package com.maddyhome.idea.vim.ui.widgets
import com.maddyhome.idea.vim.common.VimPluginListener import com.maddyhome.idea.vim.common.VimPluginListener
import com.maddyhome.idea.vim.options.GlobalOptionChangeListener import com.maddyhome.idea.vim.options.GlobalOptionChangeListener
public open class VimWidgetListener(private val updateWidget: Runnable) : GlobalOptionChangeListener, VimPluginListener { open class VimWidgetListener(private val updateWidget: Runnable) : GlobalOptionChangeListener, VimPluginListener {
override fun onGlobalOptionChanged() { override fun onGlobalOptionChanged() {
updateWidget.run() updateWidget.run()
} }

View File

@ -43,8 +43,8 @@ internal class MacroWidgetFactory : StatusBarWidgetFactory {
} }
} }
public class VimMacroWidget : StatusBarWidget, VimStatusBarWidget { class VimMacroWidget : StatusBarWidget, VimStatusBarWidget {
public var content: String = "" var content: String = ""
override fun ID(): String { override fun ID(): String {
return ID return ID
@ -69,7 +69,7 @@ public class VimMacroWidget : StatusBarWidget, VimStatusBarWidget {
} }
} }
public fun updateMacroWidget() { fun updateMacroWidget() {
val factory = StatusBarWidgetFactory.EP_NAME.findExtension(MacroWidgetFactory::class.java) ?: return val factory = StatusBarWidgetFactory.EP_NAME.findExtension(MacroWidgetFactory::class.java) ?: return
for (project in ProjectManager.getInstance().openProjects) { for (project in ProjectManager.getInstance().openProjects) {
val statusBarWidgetsManager = project.service<StatusBarWidgetsManager>() val statusBarWidgetsManager = project.service<StatusBarWidgetsManager>()
@ -79,7 +79,7 @@ public fun updateMacroWidget() {
// TODO: At the moment recording macro & RegisterGroup is bound to application, so macro will be recorded even if we // TODO: At the moment recording macro & RegisterGroup is bound to application, so macro will be recorded even if we
// move between projects. BUT it's not a good idea. Maybe RegisterGroup should have it's own project scope instances // move between projects. BUT it's not a good idea. Maybe RegisterGroup should have it's own project scope instances
public class MacroWidgetListener : MacroRecordingListener, VimWidgetListener({ updateMacroWidget() }) { class MacroWidgetListener : MacroRecordingListener, VimWidgetListener({ updateMacroWidget() }) {
override fun recordingStarted() { override fun recordingStarted() {
for (project in ProjectManager.getInstance().openProjects) { for (project in ProjectManager.getInstance().openProjects) {
val macroWidget = getWidget(project) ?: continue val macroWidget = getWidget(project) ?: continue
@ -103,4 +103,4 @@ public class MacroWidgetListener : MacroRecordingListener, VimWidgetListener({ u
} }
} }
public val macroWidgetOptionListener: VimWidgetListener = VimWidgetListener { updateMacroWidget() } val macroWidgetOptionListener: VimWidgetListener = VimWidgetListener { updateMacroWidget() }

View File

@ -17,9 +17,9 @@ import com.maddyhome.idea.vim.api.globalOptions
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.ui.widgets.VimWidgetListener import com.maddyhome.idea.vim.ui.widgets.VimWidgetListener
public class ModeWidgetFactory : StatusBarWidgetFactory { class ModeWidgetFactory : StatusBarWidgetFactory {
public companion object { companion object {
public const val ID: String = "IdeaVimMode" const val ID: String = "IdeaVimMode"
} }
override fun getId(): String { override fun getId(): String {
@ -42,4 +42,4 @@ public class ModeWidgetFactory : StatusBarWidgetFactory {
} }
} }
public val modeWidgetOptionListener: VimWidgetListener = VimWidgetListener { updateModeWidget() } val modeWidgetOptionListener: VimWidgetListener = VimWidgetListener { updateModeWidget() }

View File

@ -44,18 +44,18 @@ import javax.swing.JPanel
import kotlin.properties.ReadWriteProperty import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty import kotlin.reflect.KProperty
public class ModeWidgetPopup : AnAction() { class ModeWidgetPopup : AnAction() {
public override fun actionPerformed(e: AnActionEvent) { override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return val project = e.project ?: return
val popup = createPopup() ?: return val popup = createPopup() ?: return
popup.showCenteredInCurrentWindow(project) popup.showCenteredInCurrentWindow(project)
} }
public companion object { companion object {
@Volatile @Volatile
private var currentPopup: JBPopup? = null private var currentPopup: JBPopup? = null
public fun createPopup(): JBPopup? { fun createPopup(): JBPopup? {
synchronized(this) { synchronized(this) {
if (currentPopup?.isDisposed == false) return null if (currentPopup?.isDisposed == false) return null
val mainPanel = JPanel(BorderLayout()) val mainPanel = JPanel(BorderLayout())
@ -350,7 +350,7 @@ public class ModeWidgetPopup : AnAction() {
} }
} }
public enum class ModeWidgetTheme(private var value: String) { enum class ModeWidgetTheme(private var value: String) {
TERM("Term"), TERM("Term"),
COLORLESS("Colorless"); COLORLESS("Colorless");
@ -358,11 +358,11 @@ public enum class ModeWidgetTheme(private var value: String) {
return value return value
} }
public companion object { companion object {
public fun parseString(string: String): ModeWidgetTheme? { fun parseString(string: String): ModeWidgetTheme? {
return entries.firstOrNull { it.value == string } return entries.firstOrNull { it.value == string }
} }
public fun getDefaultTheme(): ModeWidgetTheme = TERM fun getDefaultTheme(): ModeWidgetTheme = TERM
} }
} }

View File

@ -15,7 +15,7 @@ import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.SelectionType import com.maddyhome.idea.vim.state.mode.SelectionType
import java.awt.Color import java.awt.Color
public fun getModeBackground(mode: Mode?): Color { fun getModeBackground(mode: Mode?): Color {
val isLight = !(LafManager.getInstance()?.currentUIThemeLookAndFeel?.isDark ?: false) val isLight = !(LafManager.getInstance()?.currentUIThemeLookAndFeel?.isDark ?: false)
val keyPostfix = if (isLight) "_light" else "_dark" val keyPostfix = if (isLight) "_light" else "_dark"
if (injector.variableService.getVimVariable("widget_mode_is_full_customization$keyPostfix")?.asBoolean() != true) { if (injector.variableService.getVimVariable("widget_mode_is_full_customization$keyPostfix")?.asBoolean() != true) {
@ -75,7 +75,7 @@ public fun getModeBackground(mode: Mode?): Color {
} }
} }
public fun getModeForeground(mode: Mode?): Color { fun getModeForeground(mode: Mode?): Color {
val isLight = !(LafManager.getInstance()?.currentUIThemeLookAndFeel?.isDark ?: false) val isLight = !(LafManager.getInstance()?.currentUIThemeLookAndFeel?.isDark ?: false)
val keyPostfix = if (isLight) "_light" else "_dark" val keyPostfix = if (isLight) "_light" else "_dark"
if (injector.variableService.getVimVariable("widget_mode_is_full_customization$keyPostfix")?.asBoolean() != true) { if (injector.variableService.getVimVariable("widget_mode_is_full_customization$keyPostfix")?.asBoolean() != true) {

View File

@ -30,7 +30,7 @@ import java.awt.event.MouseEvent
import javax.swing.JComponent import javax.swing.JComponent
import kotlin.math.max import kotlin.math.max
public class VimModeWidget(public val project: Project) : CustomStatusBarWidget, VimStatusBarWidget { class VimModeWidget(val project: Project) : CustomStatusBarWidget, VimStatusBarWidget {
private companion object { private companion object {
private const val INSERT = "INSERT" private const val INSERT = "INSERT"
private const val NORMAL = "NORMAL" private const val NORMAL = "NORMAL"
@ -71,12 +71,12 @@ public class VimModeWidget(public val project: Project) : CustomStatusBarWidget,
return label return label
} }
public fun updateWidget() { fun updateWidget() {
val mode = getFocusedEditor(project)?.vim?.mode val mode = getFocusedEditor(project)?.vim?.mode
updateWidget(mode) updateWidget(mode)
} }
public fun updateWidget(mode: Mode?) { fun updateWidget(mode: Mode?) {
updateLabel(mode) updateLabel(mode)
updateWidgetInStatusBar(ModeWidgetFactory.ID, project) updateWidgetInStatusBar(ModeWidgetFactory.ID, project)
} }
@ -140,7 +140,7 @@ public class VimModeWidget(public val project: Project) : CustomStatusBarWidget,
} }
} }
public fun updateModeWidget() { fun updateModeWidget() {
val factory = StatusBarWidgetFactory.EP_NAME.findExtension(ModeWidgetFactory::class.java) ?: return val factory = StatusBarWidgetFactory.EP_NAME.findExtension(ModeWidgetFactory::class.java) ?: return
for (project in ProjectManager.getInstance().openProjects) { for (project in ProjectManager.getInstance().openProjects) {
val statusBarWidgetsManager = project.service<StatusBarWidgetsManager>() val statusBarWidgetsManager = project.service<StatusBarWidgetsManager>()
@ -148,7 +148,7 @@ public fun updateModeWidget() {
} }
} }
public fun repaintModeWidget() { fun repaintModeWidget() {
for (project in ProjectManager.getInstance().openProjects) { for (project in ProjectManager.getInstance().openProjects) {
val widgets = WindowManager.getInstance()?.getStatusBar(project)?.allWidgets ?: continue val widgets = WindowManager.getInstance()?.getStatusBar(project)?.allWidgets ?: continue

View File

@ -12,8 +12,8 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.wm.WindowManager import com.intellij.openapi.wm.WindowManager
import java.util.* import java.util.*
public interface VimStatusBarWidget { interface VimStatusBarWidget {
public fun updateWidgetInStatusBar(widgetID: String, project: Project?) { fun updateWidgetInStatusBar(widgetID: String, project: Project?) {
if (project == null) return if (project == null) return
val windowManager = WindowManager.getInstance() val windowManager = WindowManager.getInstance()
windowManager.getStatusBar(project)?.updateWidget(widgetID) ?: run { windowManager.getStatusBar(project)?.updateWidget(widgetID) ?: run {

View File

@ -8,6 +8,6 @@
package com.maddyhome.idea.vim.vimscript.model.commands package com.maddyhome.idea.vim.vimscript.model.commands
public object IntellijExCommandProvider : ExCommandProvider { object IntellijExCommandProvider : ExCommandProvider {
override val exCommandsFileName: String = "intellij_ex_commands.json" override val exCommandsFileName: String = "intellij_ex_commands.json"
} }

View File

@ -8,6 +8,6 @@
package com.maddyhome.idea.vim.vimscript.model.functions package com.maddyhome.idea.vim.vimscript.model.functions
public object IntellijFunctionProvider : VimscriptFunctionProvider { object IntellijFunctionProvider : VimscriptFunctionProvider {
override val functionListFileName: String = "intellij_vimscript_functions.json" override val functionListFileName: String = "intellij_vimscript_functions.json"
} }

View File

@ -26,10 +26,10 @@ import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.state.mode.Mode import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.state.mode.selectionType import com.maddyhome.idea.vim.state.mode.selectionType
public val VimEditor.isIdeaRefactorModeKeep: Boolean val VimEditor.isIdeaRefactorModeKeep: Boolean
get() = injector.ijOptions(this).idearefactormode.contains(IjOptionConstants.idearefactormode_keep) get() = injector.ijOptions(this).idearefactormode.contains(IjOptionConstants.idearefactormode_keep)
public val VimEditor.isIdeaRefactorModeSelect: Boolean val VimEditor.isIdeaRefactorModeSelect: Boolean
get() = injector.ijOptions(this).idearefactormode.contains(IjOptionConstants.idearefactormode_select) get() = injector.ijOptions(this).idearefactormode.contains(IjOptionConstants.idearefactormode_select)
internal object IdeaRefactorModeHelper { internal object IdeaRefactorModeHelper {

View File

@ -165,7 +165,7 @@ object NeovimTesting {
assertEquals(neovimContent, editor.document.text) assertEquals(neovimContent, editor.document.text)
} }
public fun vimMode() = neovimApi.mode.get().mode fun vimMode() = neovimApi.mode.get().mode
private fun assertMode(editor: Editor) { private fun assertMode(editor: Editor) {
val ideavimState = editor.vim.vimStateMachine.mode.toVimNotation() val ideavimState = editor.vim.vimStateMachine.mode.toVimNotation()
@ -207,8 +207,8 @@ object NeovimTesting {
} }
} }
public fun getRegister(register: Char) = neovimApi.callFunction("getreg", listOf(register)).get().toString() fun getRegister(register: Char) = neovimApi.callFunction("getreg", listOf(register)).get().toString()
public fun getMark(register: String) = neovimApi.callFunction("getpos", listOf(register)).get().toString() fun getMark(register: String) = neovimApi.callFunction("getpos", listOf(register)).get().toString()
} }
annotation class TestWithoutNeovim(val reason: SkipNeovimReason, val description: String = "") annotation class TestWithoutNeovim(val reason: SkipNeovimReason, val description: String = "")

View File

@ -320,7 +320,7 @@ abstract class VimTestCase {
return fixture.editor return fixture.editor
} }
public fun configureByTextX(fileName: String, content: String): Editor { fun configureByTextX(fileName: String, content: String): Editor {
fixture.configureByText(fileName, content) fixture.configureByText(fileName, content)
setDefaultIntelliJSettings(fixture.editor) setDefaultIntelliJSettings(fixture.editor)
NeovimTesting.setupEditor(fixture.editor, testInfo) NeovimTesting.setupEditor(fixture.editor, testInfo)

View File

@ -102,7 +102,7 @@ annotation class OptionTest(vararg val value: VimOption)
* - Without bounded list: * - Without bounded list:
* - Not supported, please specify possible values using [limitedValues] * - Not supported, please specify possible values using [limitedValues]
*/ */
public annotation class VimOption( annotation class VimOption(
val name: String, val name: String,
val limitedValues: Array<String> = [], val limitedValues: Array<String> = [],
val doesntAffectTest: Boolean = false, val doesntAffectTest: Boolean = false,

View File

@ -98,10 +98,6 @@ tasks {
// version.set("0.48.2") // version.set("0.48.2")
//} //}
kotlin {
explicitApi()
}
java { java {
withSourcesJar() withSourcesJar()
withJavadocJar() withJavadocJar()

View File

@ -50,15 +50,15 @@ import javax.swing.KeyStroke
// TODO for future refactorings (PRs are welcome) // TODO for future refactorings (PRs are welcome)
// 1. avoid using handleKeyRecursionCount & shouldRecord // 1. avoid using handleKeyRecursionCount & shouldRecord
// 2. maybe we can live without allowKeyMappings: Boolean & mappingCompleted: Boolean // 2. maybe we can live without allowKeyMappings: Boolean & mappingCompleted: Boolean
public class KeyHandler { class KeyHandler {
private val keyConsumers: List<KeyConsumer> = listOf(MappingProcessor, CommandCountConsumer(), DeleteCommandConsumer(), EditorResetConsumer(), CharArgumentConsumer(), RegisterConsumer(), DigraphConsumer(), CommandConsumer(), SelectRegisterConsumer(), ModeInputConsumer()) private val keyConsumers: List<KeyConsumer> = listOf(MappingProcessor, CommandCountConsumer(), DeleteCommandConsumer(), EditorResetConsumer(), CharArgumentConsumer(), RegisterConsumer(), DigraphConsumer(), CommandConsumer(), SelectRegisterConsumer(), ModeInputConsumer())
private var handleKeyRecursionCount = 0 private var handleKeyRecursionCount = 0
public var keyHandlerState: KeyHandlerState = KeyHandlerState() var keyHandlerState: KeyHandlerState = KeyHandlerState()
private set private set
public val keyStack: KeyStack = KeyStack() val keyStack: KeyStack = KeyStack()
public val modalEntryKeys: MutableList<KeyStroke> = ArrayList() val modalEntryKeys: MutableList<KeyStroke> = ArrayList()
/** /**
* This is the main key handler for the Vim plugin. Every keystroke not handled directly by Idea is sent here for * This is the main key handler for the Vim plugin. Every keystroke not handled directly by Idea is sent here for
@ -68,7 +68,7 @@ public class KeyHandler {
* @param key The keystroke typed by the user * @param key The keystroke typed by the user
* @param context The data context * @param context The data context
*/ */
public fun handleKey(editor: VimEditor, key: KeyStroke, context: ExecutionContext, keyState: KeyHandlerState) { fun handleKey(editor: VimEditor, key: KeyStroke, context: ExecutionContext, keyState: KeyHandlerState) {
handleKey(editor, key, context, allowKeyMappings = true, mappingCompleted = false, keyState) handleKey(editor, key, context, allowKeyMappings = true, mappingCompleted = false, keyState)
} }
@ -78,7 +78,7 @@ public class KeyHandler {
* @param allowKeyMappings - If we allow key mappings or not * @param allowKeyMappings - If we allow key mappings or not
* @param mappingCompleted - if true, we don't check if the mapping is incomplete * @param mappingCompleted - if true, we don't check if the mapping is incomplete
*/ */
public fun handleKey( fun handleKey(
editor: VimEditor, editor: VimEditor,
key: KeyStroke, key: KeyStroke,
context: ExecutionContext, context: ExecutionContext,
@ -99,7 +99,7 @@ public class KeyHandler {
* Alternatively, if we understand the key, we return a 'KeyProcessResult.Executable', which contains a runnable that * Alternatively, if we understand the key, we return a 'KeyProcessResult.Executable', which contains a runnable that
* could execute the key if needed. * could execute the key if needed.
*/ */
public fun processKey( fun processKey(
key: KeyStroke, key: KeyStroke,
editor: VimEditor, editor: VimEditor,
allowKeyMappings: Boolean, allowKeyMappings: Boolean,
@ -191,16 +191,16 @@ public class KeyHandler {
reset(keyState, editor.mode) reset(keyState, editor.mode)
} }
public fun setBadCommand(editor: VimEditor, keyState: KeyHandlerState) { fun setBadCommand(editor: VimEditor, keyState: KeyHandlerState) {
onUnknownKey(editor, keyState) onUnknownKey(editor, keyState)
injector.messages.indicateError() injector.messages.indicateError()
} }
public fun isDuplicateOperatorKeyStroke(key: KeyStroke, mode: Mode, keyState: KeyHandlerState): Boolean { fun isDuplicateOperatorKeyStroke(key: KeyStroke, mode: Mode, keyState: KeyHandlerState): Boolean {
return isOperatorPending(mode, keyState) && keyState.commandBuilder.isDuplicateOperatorKeyStroke(key) return isOperatorPending(mode, keyState) && keyState.commandBuilder.isDuplicateOperatorKeyStroke(key)
} }
public fun isOperatorPending(mode: Mode, keyState: KeyHandlerState): Boolean { fun isOperatorPending(mode: Mode, keyState: KeyHandlerState): Boolean {
return mode is Mode.OP_PENDING && !keyState.commandBuilder.isEmpty return mode is Mode.OP_PENDING && !keyState.commandBuilder.isEmpty
} }
@ -255,7 +255,7 @@ public class KeyHandler {
* *
* @param editor The editor to reset. * @param editor The editor to reset.
*/ */
public fun partialReset(editor: VimEditor) { fun partialReset(editor: VimEditor) {
logger.trace { "Partial reset is executed" } logger.trace { "Partial reset is executed" }
keyHandlerState.partialReset(editor.mode) keyHandlerState.partialReset(editor.mode)
} }
@ -265,13 +265,13 @@ public class KeyHandler {
* *
* @param editor The editor to reset. * @param editor The editor to reset.
*/ */
public fun reset(editor: VimEditor) { fun reset(editor: VimEditor) {
logger.trace { "Reset is executed" } logger.trace { "Reset is executed" }
keyHandlerState.partialReset(editor.mode) keyHandlerState.partialReset(editor.mode)
keyHandlerState.commandBuilder.resetAll(getKeyRoot(editor.mode.toMappingMode())) keyHandlerState.commandBuilder.resetAll(getKeyRoot(editor.mode.toMappingMode()))
} }
public fun reset(keyState: KeyHandlerState, mode: Mode) { fun reset(keyState: KeyHandlerState, mode: Mode) {
logger.trace { "Reset is executed" } logger.trace { "Reset is executed" }
keyHandlerState.partialReset(mode) keyHandlerState.partialReset(mode)
keyState.commandBuilder.resetAll(getKeyRoot(mode.toMappingMode())) keyState.commandBuilder.resetAll(getKeyRoot(mode.toMappingMode()))
@ -281,7 +281,7 @@ public class KeyHandler {
return injector.keyGroup.getKeyRoot(mappingMode) return injector.keyGroup.getKeyRoot(mappingMode)
} }
public fun updateState(keyState: KeyHandlerState) { fun updateState(keyState: KeyHandlerState) {
logger.trace { "State updated" } logger.trace { "State updated" }
logger.trace { keyState.toString() } logger.trace { keyState.toString() }
this.keyHandlerState = keyState this.keyHandlerState = keyState
@ -293,7 +293,7 @@ public class KeyHandler {
* *
* @param editor The editor to reset. * @param editor The editor to reset.
*/ */
public fun fullReset(editor: VimEditor) { fun fullReset(editor: VimEditor) {
logger.trace { "Full reset" } logger.trace { "Full reset" }
injector.messages.clearError() injector.messages.clearError()
@ -306,7 +306,7 @@ public class KeyHandler {
editor.removeSelection() editor.removeSelection()
} }
public fun setPromptCharacterEx(promptCharacter: Char) { fun setPromptCharacterEx(promptCharacter: Char) {
val commandLine = injector.commandLine.getActiveCommandLine() ?: return val commandLine = injector.commandLine.getActiveCommandLine() ?: return
commandLine.setPromptCharacter(promptCharacter) commandLine.setPromptCharacter(promptCharacter)
} }
@ -362,8 +362,8 @@ public class KeyHandler {
} }
} }
public companion object { companion object {
public val lock: Any = Object() val lock: Any = Object()
private val logger: VimLogger = vimLogger<KeyHandler>() private val logger: VimLogger = vimLogger<KeyHandler>()
internal fun <T> isPrefix(list1: List<T>, list2: List<T>): Boolean { internal fun <T> isPrefix(list1: List<T>, list2: List<T>): Boolean {
@ -381,10 +381,10 @@ public class KeyHandler {
private val instance = KeyHandler() private val instance = KeyHandler()
@JvmStatic @JvmStatic
public fun getInstance(): KeyHandler = instance fun getInstance(): KeyHandler = instance
} }
public data class MutableBoolean(public var value: Boolean) data class MutableBoolean(var value: Boolean)
} }
/** /**
@ -392,11 +392,11 @@ public class KeyHandler {
* Fleet needs to synchronously determine if the key will be handled by the plugin or should be passed elsewhere. * Fleet needs to synchronously determine if the key will be handled by the plugin or should be passed elsewhere.
* The key processing itself will be executed asynchronously at a later time. * The key processing itself will be executed asynchronously at a later time.
*/ */
public sealed interface KeyProcessResult { sealed interface KeyProcessResult {
/** /**
* Key input that is not recognized by IdeaVim and should be passed to IDE. * Key input that is not recognized by IdeaVim and should be passed to IDE.
*/ */
public object Unknown: KeyProcessResult object Unknown: KeyProcessResult
/** /**
* Key input that is recognized by IdeaVim and can be executed. * Key input that is recognized by IdeaVim and can be executed.
@ -406,17 +406,17 @@ public sealed interface KeyProcessResult {
* This class should be returned after the first step is complete. * This class should be returned after the first step is complete.
* It will continue the key handling and finish the process. * It will continue the key handling and finish the process.
*/ */
public class Executable( class Executable(
private val originalState: KeyHandlerState, private val originalState: KeyHandlerState,
private val preProcessState: KeyHandlerState, private val preProcessState: KeyHandlerState,
private val processing: KeyProcessing, private val processing: KeyProcessing,
): KeyProcessResult { ): KeyProcessResult {
public companion object { companion object {
private val logger = vimLogger<KeyProcessResult>() private val logger = vimLogger<KeyProcessResult>()
} }
public fun execute(editor: VimEditor, context: ExecutionContext) { fun execute(editor: VimEditor, context: ExecutionContext) {
synchronized(KeyHandler.lock) { synchronized(KeyHandler.lock) {
val keyHandler = KeyHandler.getInstance() val keyHandler = KeyHandler.getInstance()
if (keyHandler.keyHandlerState != originalState) { if (keyHandler.keyHandlerState != originalState) {
@ -442,23 +442,23 @@ public sealed interface KeyProcessResult {
* If there's need to alter the state following any of the execution steps, wrap the state modification as an * If there's need to alter the state following any of the execution steps, wrap the state modification as an
* execution step. This will allow state modification to occur later rather than immediately. * execution step. This will allow state modification to occur later rather than immediately.
*/ */
public abstract class KeyProcessResultBuilder { abstract class KeyProcessResultBuilder {
public abstract val state: KeyHandlerState abstract val state: KeyHandlerState
protected val processings: MutableList<KeyProcessing> = mutableListOf() protected val processings: MutableList<KeyProcessing> = mutableListOf()
public var onFinish: (() -> Unit)? = null // FIXME I'm a dirty hack to support recursion counter var onFinish: (() -> Unit)? = null // FIXME I'm a dirty hack to support recursion counter
public fun addExecutionStep(keyProcessing: KeyProcessing) { fun addExecutionStep(keyProcessing: KeyProcessing) {
processings.add(keyProcessing) processings.add(keyProcessing)
} }
public abstract fun build(): KeyProcessResult abstract fun build(): KeyProcessResult
} }
// Works with existing state and modifies it during execution // Works with existing state and modifies it during execution
// It's the way IdeaVim worked for the long time and for this class we do not create // It's the way IdeaVim worked for the long time and for this class we do not create
// unnecessary objects and assume that the code will be executed immediately // unnecessary objects and assume that the code will be executed immediately
public class SynchronousKeyProcessBuilder(public override val state: KeyHandlerState): KeyProcessResultBuilder() { class SynchronousKeyProcessBuilder(override val state: KeyHandlerState): KeyProcessResultBuilder() {
public override fun build(): KeyProcessResult { override fun build(): KeyProcessResult {
return Executable(state, state) { keyHandlerState, vimEditor, executionContext -> return Executable(state, state) { keyHandlerState, vimEditor, executionContext ->
try { try {
for (processing in processings) { for (processing in processings) {
@ -473,11 +473,11 @@ public sealed interface KeyProcessResult {
// Works with a clone of current state, nothing is modified during the builder work (key processing) // Works with a clone of current state, nothing is modified during the builder work (key processing)
// The new state will be applied later, when we run Executable.execute() (it may not be run at all) // The new state will be applied later, when we run Executable.execute() (it may not be run at all)
public class AsyncKeyProcessBuilder(originalState: KeyHandlerState): KeyProcessResultBuilder() { class AsyncKeyProcessBuilder(originalState: KeyHandlerState): KeyProcessResultBuilder() {
private val originalState: KeyHandlerState = KeyHandler.getInstance().keyHandlerState private val originalState: KeyHandlerState = KeyHandler.getInstance().keyHandlerState
public override val state: KeyHandlerState = originalState.clone() override val state: KeyHandlerState = originalState.clone()
public override fun build(): KeyProcessResult { override fun build(): KeyProcessResult {
return Executable(originalState, state) { keyHandlerState, vimEditor, executionContext -> return Executable(originalState, state) { keyHandlerState, vimEditor, executionContext ->
try { try {
for (processing in processings) { for (processing in processings) {
@ -492,7 +492,7 @@ public sealed interface KeyProcessResult {
} }
} }
public class KeyHandlerStateResetter : EditorListener { class KeyHandlerStateResetter : EditorListener {
override fun focusGained(editor: VimEditor) { override fun focusGained(editor: VimEditor) {
KeyHandler.getInstance().reset(editor) KeyHandler.getInstance().reset(editor)
} }
@ -503,4 +503,4 @@ public class KeyHandlerStateResetter : EditorListener {
} }
} }
public typealias KeyProcessing = (KeyHandlerState, VimEditor, ExecutionContext) -> Unit typealias KeyProcessing = (KeyHandlerState, VimEditor, ExecutionContext) -> Unit

View File

@ -23,11 +23,11 @@ import java.io.InputStream
* The primary functionality of this interface is to transform the JSON data into a collection of * The primary functionality of this interface is to transform the JSON data into a collection of
* {@code LazyVimCommand} instances. * {@code LazyVimCommand} instances.
*/ */
public interface CommandProvider { interface CommandProvider {
public val commandListFileName: String val commandListFileName: String
@OptIn(ExperimentalSerializationApi::class) @OptIn(ExperimentalSerializationApi::class)
public fun getCommands(): Collection<LazyVimCommand> { fun getCommands(): Collection<LazyVimCommand> {
val classLoader = this.javaClass.classLoader val classLoader = this.javaClass.classLoader
val commands: List<CommandBean> = Json.decodeFromStream(getFile()) val commands: List<CommandBean> = Json.decodeFromStream(getFile())
return commands return commands
@ -46,4 +46,4 @@ public interface CommandProvider {
} }
@Serializable @Serializable
public data class CommandBean(val keys: String, val `class`: String, val modes: String) data class CommandBean(val keys: String, val `class`: String, val modes: String)

View File

@ -8,6 +8,6 @@
package com.maddyhome.idea.vim.action package com.maddyhome.idea.vim.action
public object EngineCommandProvider : CommandProvider { object EngineCommandProvider : CommandProvider {
override val commandListFileName: String = "engine_commands.json" override val commandListFileName: String = "engine_commands.json"
} }

View File

@ -21,7 +21,7 @@ import com.maddyhome.idea.vim.handler.VimActionHandler
import com.maddyhome.idea.vim.state.mode.mode import com.maddyhome.idea.vim.state.mode.mode
@CommandOrMotion(keys = ["<C-\\><C-N>"], modes = [Mode.NORMAL, Mode.VISUAL, Mode.SELECT, Mode.OP_PENDING, Mode.INSERT, Mode.CMD_LINE]) @CommandOrMotion(keys = ["<C-\\><C-N>"], modes = [Mode.NORMAL, Mode.VISUAL, Mode.SELECT, Mode.OP_PENDING, Mode.INSERT, Mode.CMD_LINE])
public class ResetModeAction : VimActionHandler.ConditionalMulticaret() { class ResetModeAction : VimActionHandler.ConditionalMulticaret() {
private lateinit var modeBeforeReset: com.maddyhome.idea.vim.state.mode.Mode private lateinit var modeBeforeReset: com.maddyhome.idea.vim.state.mode.Mode
override val type: Command.Type = Command.Type.OTHER_WRITABLE override val type: Command.Type = Command.Type.OTHER_WRITABLE
override fun runAsMulticaret( override fun runAsMulticaret(

View File

@ -18,7 +18,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.handler.VimActionHandler import com.maddyhome.idea.vim.handler.VimActionHandler
@CommandOrMotion(keys = ["<C-G>u"], modes = [Mode.INSERT]) @CommandOrMotion(keys = ["<C-G>u"], modes = [Mode.INSERT])
public class BreakUndoSequenceAction : VimActionHandler.SingleExecution() { class BreakUndoSequenceAction : VimActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
override fun execute( override fun execute(

View File

@ -11,8 +11,8 @@ package com.maddyhome.idea.vim.action.change
import com.maddyhome.idea.vim.extension.ExtensionHandler import com.maddyhome.idea.vim.extension.ExtensionHandler
import javax.swing.KeyStroke import javax.swing.KeyStroke
public object Extension { object Extension {
public var lastExtensionHandler: ExtensionHandler? = null var lastExtensionHandler: ExtensionHandler? = null
private val keyStrokes = mutableListOf<KeyStroke>() private val keyStrokes = mutableListOf<KeyStroke>()
private val strings = mutableListOf<String>() private val strings = mutableListOf<String>()
@ -20,10 +20,10 @@ public object Extension {
private var keystrokePointer = 0 private var keystrokePointer = 0
private var stringPointer = 0 private var stringPointer = 0
public fun addKeystroke(key: KeyStroke): Boolean = keyStrokes.add(key) fun addKeystroke(key: KeyStroke): Boolean = keyStrokes.add(key)
public fun addString(key: String): Boolean = strings.add(key) fun addString(key: String): Boolean = strings.add(key)
public fun consumeKeystroke(): KeyStroke? { fun consumeKeystroke(): KeyStroke? {
if (keystrokePointer in keyStrokes.indices) { if (keystrokePointer in keyStrokes.indices) {
keystrokePointer += 1 keystrokePointer += 1
return keyStrokes[keystrokePointer - 1] return keyStrokes[keystrokePointer - 1]
@ -31,7 +31,7 @@ public object Extension {
return null return null
} }
public fun consumeString(): String? { fun consumeString(): String? {
if (stringPointer in strings.indices) { if (stringPointer in strings.indices) {
stringPointer += 1 stringPointer += 1
return strings[stringPointer - 1] return strings[stringPointer - 1]
@ -39,12 +39,12 @@ public object Extension {
return null return null
} }
public fun reset() { fun reset() {
keystrokePointer = 0 keystrokePointer = 0
stringPointer = 0 stringPointer = 0
} }
public fun clean() { fun clean() {
keyStrokes.clear() keyStrokes.clear()
strings.clear() strings.clear()
keystrokePointer = 0 keystrokePointer = 0

View File

@ -13,13 +13,13 @@ import com.maddyhome.idea.vim.handler.EditorActionHandlerBase
import com.maddyhome.idea.vim.vimscript.model.LazyInstance import com.maddyhome.idea.vim.vimscript.model.LazyInstance
import javax.swing.KeyStroke import javax.swing.KeyStroke
public open class LazyVimCommand( open class LazyVimCommand(
public val keys: Set<List<KeyStroke>>, val keys: Set<List<KeyStroke>>,
public val modes: Set<MappingMode>, val modes: Set<MappingMode>,
className: String, className: String,
classLoader: ClassLoader, classLoader: ClassLoader,
) : LazyInstance<EditorActionHandlerBase>(className, classLoader) { ) : LazyInstance<EditorActionHandlerBase>(className, classLoader) {
public val actionId: String = EditorActionHandlerBase.getActionId(className) val actionId: String = EditorActionHandlerBase.getActionId(className)
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true

View File

@ -17,7 +17,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.handler.VimActionHandler import com.maddyhome.idea.vim.handler.VimActionHandler
@CommandOrMotion(keys = ["<C-R>"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["<C-R>"], modes = [Mode.NORMAL])
public class RedoAction : VimActionHandler.SingleExecution() { class RedoAction : VimActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
override fun execute( override fun execute(

View File

@ -17,7 +17,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.handler.VimActionHandler import com.maddyhome.idea.vim.handler.VimActionHandler
@CommandOrMotion(keys = ["u", "<Undo>"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["u", "<Undo>"], modes = [Mode.NORMAL])
public class UndoAction : VimActionHandler.SingleExecution() { class UndoAction : VimActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
override fun execute( override fun execute(

View File

@ -11,14 +11,14 @@ package com.maddyhome.idea.vim.action.change
import com.maddyhome.idea.vim.api.injector import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.Command import com.maddyhome.idea.vim.command.Command
public object VimRepeater { object VimRepeater {
public var repeatHandler: Boolean = false var repeatHandler: Boolean = false
public var lastChangeCommand: Command? = null var lastChangeCommand: Command? = null
private set private set
public var lastChangeRegister: Char = injector.registerGroup.defaultRegister var lastChangeRegister: Char = injector.registerGroup.defaultRegister
public fun saveLastChange(command: Command) { fun saveLastChange(command: Command) {
lastChangeCommand = command lastChangeCommand = command
lastChangeRegister = injector.registerGroup.currentRegister lastChangeRegister = injector.registerGroup.currentRegister
} }

View File

@ -25,7 +25,7 @@ import java.util.*
* @author vlan * @author vlan
*/ */
@CommandOrMotion(keys = ["="], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["="], modes = [Mode.VISUAL])
public class AutoIndentLinesVisualAction : VisualOperatorActionHandler.ForEachCaret() { class AutoIndentLinesVisualAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE) override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE)

View File

@ -21,7 +21,7 @@ import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
import com.maddyhome.idea.vim.helper.CharacterHelper import com.maddyhome.idea.vim.helper.CharacterHelper
@CommandOrMotion(keys = ["gu"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["gu"], modes = [Mode.NORMAL])
public class ChangeCaseLowerMotionAction : ChangeEditorActionHandler.ForEachCaret(), DuplicableOperatorAction { class ChangeCaseLowerMotionAction : ChangeEditorActionHandler.ForEachCaret(), DuplicableOperatorAction {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val argumentType: Argument.Type = Argument.Type.MOTION override val argumentType: Argument.Type = Argument.Type.MOTION

View File

@ -23,7 +23,7 @@ import com.maddyhome.idea.vim.helper.CharacterHelper
* @author vlan * @author vlan
*/ */
@CommandOrMotion(keys = ["u"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["u"], modes = [Mode.VISUAL])
public class ChangeCaseLowerVisualAction : VisualOperatorActionHandler.ForEachCaret() { class ChangeCaseLowerVisualAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override fun executeAction( override fun executeAction(

View File

@ -19,7 +19,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
@CommandOrMotion(keys = ["~"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["~"], modes = [Mode.NORMAL])
public class ChangeCaseToggleCharacterAction : ChangeEditorActionHandler.ForEachCaret() { class ChangeCaseToggleCharacterAction : ChangeEditorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override fun execute( override fun execute(

View File

@ -21,7 +21,7 @@ import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
import com.maddyhome.idea.vim.helper.CharacterHelper import com.maddyhome.idea.vim.helper.CharacterHelper
@CommandOrMotion(keys = ["g~"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["g~"], modes = [Mode.NORMAL])
public class ChangeCaseToggleMotionAction : ChangeEditorActionHandler.ForEachCaret(), DuplicableOperatorAction { class ChangeCaseToggleMotionAction : ChangeEditorActionHandler.ForEachCaret(), DuplicableOperatorAction {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val argumentType: Argument.Type = Argument.Type.MOTION override val argumentType: Argument.Type = Argument.Type.MOTION

View File

@ -23,7 +23,7 @@ import com.maddyhome.idea.vim.helper.CharacterHelper
* @author vlan * @author vlan
*/ */
@CommandOrMotion(keys = ["~"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["~"], modes = [Mode.VISUAL])
public class ChangeCaseToggleVisualAction : VisualOperatorActionHandler.ForEachCaret() { class ChangeCaseToggleVisualAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override fun executeAction( override fun executeAction(

View File

@ -21,7 +21,7 @@ import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
import com.maddyhome.idea.vim.helper.CharacterHelper import com.maddyhome.idea.vim.helper.CharacterHelper
@CommandOrMotion(keys = ["gU"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["gU"], modes = [Mode.NORMAL])
public class ChangeCaseUpperMotionAction : ChangeEditorActionHandler.ForEachCaret(), DuplicableOperatorAction { class ChangeCaseUpperMotionAction : ChangeEditorActionHandler.ForEachCaret(), DuplicableOperatorAction {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val argumentType: Argument.Type = Argument.Type.MOTION override val argumentType: Argument.Type = Argument.Type.MOTION

View File

@ -23,7 +23,7 @@ import com.maddyhome.idea.vim.helper.CharacterHelper
* @author vlan * @author vlan
*/ */
@CommandOrMotion(keys = ["U"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["U"], modes = [Mode.VISUAL])
public class ChangeCaseUpperVisualAction : VisualOperatorActionHandler.ForEachCaret() { class ChangeCaseUpperVisualAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override fun executeAction( override fun executeAction(

View File

@ -26,7 +26,7 @@ import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.* import java.util.*
@CommandOrMotion(keys = ["r"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["r"], modes = [Mode.NORMAL])
public class ChangeCharacterAction : ChangeEditorActionHandler.ForEachCaret() { class ChangeCharacterAction : ChangeEditorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val argumentType: Argument.Type = Argument.Type.DIGRAPH override val argumentType: Argument.Type = Argument.Type.DIGRAPH

View File

@ -22,7 +22,7 @@ import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.* import java.util.*
@CommandOrMotion(keys = ["s"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["s"], modes = [Mode.NORMAL])
public class ChangeCharactersAction : ChangeInInsertSequenceAction() { class ChangeCharactersAction : ChangeInInsertSequenceAction() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_NO_REPEAT_INSERT) override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_NO_REPEAT_INSERT)

View File

@ -22,7 +22,7 @@ import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.* import java.util.*
@CommandOrMotion(keys = ["C"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["C"], modes = [Mode.NORMAL])
public class ChangeEndOfLineAction : ChangeInInsertSequenceAction() { class ChangeEndOfLineAction : ChangeInInsertSequenceAction() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_NO_REPEAT_INSERT) override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_NO_REPEAT_INSERT)

View File

@ -16,7 +16,7 @@ import com.maddyhome.idea.vim.command.Argument
import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
public abstract class ChangeInInsertSequenceAction : ChangeEditorActionHandler.ForEachCaret() { abstract class ChangeInInsertSequenceAction : ChangeEditorActionHandler.ForEachCaret() {
final override fun execute( final override fun execute(
editor: VimEditor, editor: VimEditor,
caret: VimCaret, caret: VimCaret,
@ -31,7 +31,7 @@ public abstract class ChangeInInsertSequenceAction : ChangeEditorActionHandler.F
return result return result
} }
public abstract fun executeInInsertSequence( abstract fun executeInInsertSequence(
editor: VimEditor, editor: VimEditor,
caret: VimCaret, caret: VimCaret,
context: ExecutionContext, context: ExecutionContext,

View File

@ -20,7 +20,7 @@ import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
import com.maddyhome.idea.vim.vimscript.model.Script import com.maddyhome.idea.vim.vimscript.model.Script
@CommandOrMotion(keys = ["g&"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["g&"], modes = [Mode.NORMAL])
public class ChangeLastGlobalSearchReplaceAction : ChangeEditorActionHandler.SingleExecution() { class ChangeLastGlobalSearchReplaceAction : ChangeEditorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
override fun execute( override fun execute(

View File

@ -20,7 +20,7 @@ import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
import com.maddyhome.idea.vim.vimscript.model.Script import com.maddyhome.idea.vim.vimscript.model.Script
@CommandOrMotion(keys = ["&"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["&"], modes = [Mode.NORMAL])
public class ChangeLastSearchReplaceAction : ChangeEditorActionHandler.SingleExecution() { class ChangeLastSearchReplaceAction : ChangeEditorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED override val type: Command.Type = Command.Type.OTHER_SELF_SYNCHRONIZED
override fun execute( override fun execute(

View File

@ -23,7 +23,7 @@ import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.* import java.util.*
@CommandOrMotion(keys = ["S"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["S"], modes = [Mode.NORMAL])
public class ChangeLineAction : ChangeInInsertSequenceAction() { class ChangeLineAction : ChangeInInsertSequenceAction() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_NO_REPEAT_INSERT) override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_NO_REPEAT_INSERT)

View File

@ -19,7 +19,7 @@ import com.maddyhome.idea.vim.command.DuplicableOperatorAction
import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.command.OperatorArguments
@CommandOrMotion(keys = ["c"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["c"], modes = [Mode.NORMAL])
public class ChangeMotionAction : ChangeInInsertSequenceAction(), DuplicableOperatorAction { class ChangeMotionAction : ChangeInInsertSequenceAction(), DuplicableOperatorAction {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val argumentType: Argument.Type = Argument.Type.MOTION override val argumentType: Argument.Type = Argument.Type.MOTION

View File

@ -18,7 +18,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
@CommandOrMotion(keys = ["R"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["R"], modes = [Mode.NORMAL])
public class ChangeReplaceAction : ChangeEditorActionHandler.SingleExecution() { class ChangeReplaceAction : ChangeEditorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override fun execute( override fun execute(

View File

@ -22,7 +22,7 @@ import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
* @author vlan * @author vlan
*/ */
@CommandOrMotion(keys = ["c", "s"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["c", "s"], modes = [Mode.VISUAL])
public class ChangeVisualAction : VisualOperatorActionHandler.ForEachCaret() { class ChangeVisualAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override fun executeAction( override fun executeAction(

View File

@ -29,7 +29,7 @@ import java.util.*
* @author vlan * @author vlan
*/ */
@CommandOrMotion(keys = ["r"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["r"], modes = [Mode.VISUAL])
public class ChangeVisualCharacterAction : VisualOperatorActionHandler.ForEachCaret() { class ChangeVisualCharacterAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val argumentType: Argument.Type = Argument.Type.DIGRAPH override val argumentType: Argument.Type = Argument.Type.DIGRAPH

View File

@ -30,7 +30,7 @@ import java.util.*
* @author vlan * @author vlan
*/ */
@CommandOrMotion(keys = ["R", "S"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["R", "S"], modes = [Mode.VISUAL])
public class ChangeVisualLinesAction : VisualOperatorActionHandler.ForEachCaret() { class ChangeVisualLinesAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_MOT_LINEWISE) override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_MOT_LINEWISE)

View File

@ -30,7 +30,7 @@ import java.util.*
* @author vlan * @author vlan
*/ */
@CommandOrMotion(keys = ["C"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["C"], modes = [Mode.VISUAL])
public class ChangeVisualLinesEndAction : VisualOperatorActionHandler.ForEachCaret() { class ChangeVisualLinesEndAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_MOT_LINEWISE) override val flags: EnumSet<CommandFlags> = enumSetOf(FLAG_MOT_LINEWISE)

View File

@ -24,7 +24,7 @@ import com.maddyhome.idea.vim.helper.enumSetOf
import java.util.* import java.util.*
@CommandOrMotion(keys = ["!"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["!"], modes = [Mode.VISUAL])
public class FilterVisualLinesAction : VimActionHandler.SingleExecution(), FilterCommand { class FilterVisualLinesAction : VimActionHandler.SingleExecution(), FilterCommand {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE) override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE)
@ -43,7 +43,7 @@ public class FilterVisualLinesAction : VimActionHandler.SingleExecution(), Filte
* the ex command line is started with the initial text `:[range]!`. The {filter} will be typed into the ex entry field. * the ex command line is started with the initial text `:[range]!`. The {filter} will be typed into the ex entry field.
*/ */
@CommandOrMotion(keys = ["!"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["!"], modes = [Mode.NORMAL])
public class FilterMotionAction : VimActionHandler.SingleExecution(), FilterCommand, DuplicableOperatorAction { class FilterMotionAction : VimActionHandler.SingleExecution(), FilterCommand, DuplicableOperatorAction {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val argumentType: Argument.Type = Argument.Type.MOTION override val argumentType: Argument.Type = Argument.Type.MOTION
@ -68,8 +68,8 @@ public class FilterMotionAction : VimActionHandler.SingleExecution(), FilterComm
} }
} }
public interface FilterCommand { interface FilterCommand {
public fun startFilterCommand(editor: VimEditor, context: ExecutionContext, cmd: Command) { fun startFilterCommand(editor: VimEditor, context: ExecutionContext, cmd: Command) {
injector.processGroup.startExEntry(editor, context, cmd, initialCommandText = "!") injector.processGroup.startExEntry(editor, context, cmd, initialCommandText = "!")
} }
} }

View File

@ -20,7 +20,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
@CommandOrMotion(keys = ["gq"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["gq"], modes = [Mode.NORMAL])
public class ReformatCodeMotionAction : ChangeEditorActionHandler.ForEachCaret(), DuplicableOperatorAction { class ReformatCodeMotionAction : ChangeEditorActionHandler.ForEachCaret(), DuplicableOperatorAction {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val argumentType: Argument.Type = Argument.Type.MOTION override val argumentType: Argument.Type = Argument.Type.MOTION

View File

@ -25,7 +25,7 @@ import java.util.*
* @author vlan * @author vlan
*/ */
@CommandOrMotion(keys = ["gq"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["gq"], modes = [Mode.VISUAL])
public class ReformatCodeVisualAction : VisualOperatorActionHandler.ForEachCaret() { class ReformatCodeVisualAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE) override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE)

View File

@ -18,7 +18,7 @@ import com.maddyhome.idea.vim.command.Command
import com.maddyhome.idea.vim.command.OperatorArguments import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
public sealed class IncAction(public val inc: Int) : ChangeEditorActionHandler.ForEachCaret() { sealed class IncAction(val inc: Int) : ChangeEditorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override fun execute( override fun execute(
@ -33,7 +33,7 @@ public sealed class IncAction(public val inc: Int) : ChangeEditorActionHandler.F
} }
@CommandOrMotion(keys = ["<C-A>"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["<C-A>"], modes = [Mode.NORMAL])
public class ChangeNumberIncAction : IncAction(1) class ChangeNumberIncAction : IncAction(1)
@CommandOrMotion(keys = ["<C-X>"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["<C-X>"], modes = [Mode.NORMAL])
public class ChangeNumberDecAction : IncAction(-1) class ChangeNumberDecAction : IncAction(-1)

View File

@ -18,7 +18,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.group.visual.VimSelection import com.maddyhome.idea.vim.group.visual.VimSelection
import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
public sealed class IncNumber(public val inc: Int, private val avalanche: Boolean) : VisualOperatorActionHandler.ForEachCaret() { sealed class IncNumber(val inc: Int, private val avalanche: Boolean) : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.CHANGE override val type: Command.Type = Command.Type.CHANGE
override fun executeAction( override fun executeAction(
@ -34,13 +34,13 @@ public sealed class IncNumber(public val inc: Int, private val avalanche: Boolea
} }
@CommandOrMotion(keys = ["<C-A>"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["<C-A>"], modes = [Mode.VISUAL])
public class ChangeVisualNumberIncAction : IncNumber(1, false) class ChangeVisualNumberIncAction : IncNumber(1, false)
@CommandOrMotion(keys = ["<C-X>"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["<C-X>"], modes = [Mode.VISUAL])
public class ChangeVisualNumberDecAction : IncNumber(-1, false) class ChangeVisualNumberDecAction : IncNumber(-1, false)
@CommandOrMotion(keys = ["g<C-A>"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["g<C-A>"], modes = [Mode.VISUAL])
public class ChangeVisualNumberAvalancheIncAction : IncNumber(1, true) class ChangeVisualNumberAvalancheIncAction : IncNumber(1, true)
@CommandOrMotion(keys = ["g<C-X>"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["g<C-X>"], modes = [Mode.VISUAL])
public class ChangeVisualNumberAvalancheDecAction : IncNumber(-1, true) class ChangeVisualNumberAvalancheDecAction : IncNumber(-1, true)

View File

@ -19,15 +19,15 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
@CommandOrMotion(keys = ["<Del>"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["<Del>"], modes = [Mode.NORMAL])
public class DeleteCharacterAction : DeleteCharacter({ 1 }) class DeleteCharacterAction : DeleteCharacter({ 1 })
@CommandOrMotion(keys = ["X"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["X"], modes = [Mode.NORMAL])
public class DeleteCharacterLeftAction : DeleteCharacter({ -it }) class DeleteCharacterLeftAction : DeleteCharacter({ -it })
@CommandOrMotion(keys = ["x"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["x"], modes = [Mode.NORMAL])
public class DeleteCharacterRightAction : DeleteCharacter({ it }) class DeleteCharacterRightAction : DeleteCharacter({ it })
public abstract class DeleteCharacter(private val countModifier: (Int) -> Int) : ChangeEditorActionHandler.ForEachCaret() { abstract class DeleteCharacter(private val countModifier: (Int) -> Int) : ChangeEditorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.DELETE override val type: Command.Type = Command.Type.DELETE
override fun execute( override fun execute(

View File

@ -19,7 +19,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
@CommandOrMotion(keys = ["D"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["D"], modes = [Mode.NORMAL])
public class DeleteEndOfLineAction : ChangeEditorActionHandler.ForEachCaret() { class DeleteEndOfLineAction : ChangeEditorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.DELETE override val type: Command.Type = Command.Type.DELETE
override fun execute( override fun execute(

View File

@ -20,7 +20,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
@CommandOrMotion(keys = ["d"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["d"], modes = [Mode.NORMAL])
public class DeleteMotionAction : ChangeEditorActionHandler.ForEachCaret(), DuplicableOperatorAction { class DeleteMotionAction : ChangeEditorActionHandler.ForEachCaret(), DuplicableOperatorAction {
override val type: Command.Type = Command.Type.DELETE override val type: Command.Type = Command.Type.DELETE
override val argumentType: Argument.Type = Argument.Type.MOTION override val argumentType: Argument.Type = Argument.Type.MOTION

View File

@ -22,7 +22,7 @@ import com.maddyhome.idea.vim.handler.VisualOperatorActionHandler
* @author vlan * @author vlan
*/ */
@CommandOrMotion(keys = ["d", "x", "<Del>"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["d", "x", "<Del>"], modes = [Mode.VISUAL])
public class DeleteVisualAction : VisualOperatorActionHandler.ForEachCaret() { class DeleteVisualAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.DELETE override val type: Command.Type = Command.Type.DELETE
override fun executeAction( override fun executeAction(

View File

@ -29,7 +29,7 @@ import java.util.*
* @author vlan * @author vlan
*/ */
@CommandOrMotion(keys = ["X"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["X"], modes = [Mode.VISUAL])
public class DeleteVisualLinesAction : VisualOperatorActionHandler.ForEachCaret() { class DeleteVisualLinesAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.DELETE override val type: Command.Type = Command.Type.DELETE
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE) override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE)

View File

@ -29,7 +29,7 @@ import java.util.*
* @author vlan * @author vlan
*/ */
@CommandOrMotion(keys = ["D"], modes = [Mode.VISUAL]) @CommandOrMotion(keys = ["D"], modes = [Mode.VISUAL])
public class DeleteVisualLinesEndAction : VisualOperatorActionHandler.ForEachCaret() { class DeleteVisualLinesEndAction : VisualOperatorActionHandler.ForEachCaret() {
override val type: Command.Type = Command.Type.DELETE override val type: Command.Type = Command.Type.DELETE
override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE) override val flags: EnumSet<CommandFlags> = enumSetOf(CommandFlags.FLAG_MOT_LINEWISE)

View File

@ -18,7 +18,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
@CommandOrMotion(keys = ["a"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["a"], modes = [Mode.NORMAL])
public class InsertAfterCursorAction : ChangeEditorActionHandler.SingleExecution() { class InsertAfterCursorAction : ChangeEditorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.INSERT override val type: Command.Type = Command.Type.INSERT
override fun execute( override fun execute(

View File

@ -18,7 +18,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
@CommandOrMotion(keys = ["A"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["A"], modes = [Mode.NORMAL])
public class InsertAfterLineEndAction : ChangeEditorActionHandler.SingleExecution() { class InsertAfterLineEndAction : ChangeEditorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.INSERT override val type: Command.Type = Command.Type.INSERT
override fun execute( override fun execute(

View File

@ -20,7 +20,7 @@ import com.maddyhome.idea.vim.handler.ChangeEditorActionHandler
import com.maddyhome.idea.vim.handler.Motion import com.maddyhome.idea.vim.handler.Motion
@CommandOrMotion(keys = ["gi"], modes = [Mode.NORMAL]) @CommandOrMotion(keys = ["gi"], modes = [Mode.NORMAL])
public class InsertAtPreviousInsertAction : ChangeEditorActionHandler.SingleExecution() { class InsertAtPreviousInsertAction : ChangeEditorActionHandler.SingleExecution() {
override val type: Command.Type = Command.Type.INSERT override val type: Command.Type = Command.Type.INSERT
override fun execute( override fun execute(

Some files were not shown because too many files have changed in this diff Show More