mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-10 15:40:37 +02:00
Create noneOfEnum helper function
This commit is contained in:
parent
778ddb0e75
commit
a1adb1eb43
src/com/maddyhome/idea/vim
test/org/jetbrains/plugins/ideavim/action/motion/gn
@ -30,6 +30,7 @@ import com.maddyhome.idea.vim.handler.ExecuteMethodNotOverriddenException
|
||||
import com.maddyhome.idea.vim.helper.MessageHelper
|
||||
import com.maddyhome.idea.vim.helper.Msg
|
||||
import com.maddyhome.idea.vim.helper.inVisualMode
|
||||
import com.maddyhome.idea.vim.helper.noneOfEnum
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@ -114,7 +115,7 @@ abstract class CommandHandler {
|
||||
argFlags: CommandHandlerFlags,
|
||||
runForEachCaret: Boolean = false,
|
||||
caretOrder: CaretOrder = CaretOrder.DECREASING_OFFSET,
|
||||
optFlags: EnumSet<CommandFlags> = EnumSet.noneOf<CommandFlags>(CommandFlags::class.java)
|
||||
optFlags: EnumSet<CommandFlags> = noneOfEnum()
|
||||
) {
|
||||
this.names = names
|
||||
this.argFlags = argFlags
|
||||
|
@ -22,6 +22,7 @@ import com.intellij.openapi.editor.Caret
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.UserDataHolder
|
||||
import java.util.*
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
@ -106,6 +107,7 @@ fun <T> userDataOr(default: UserDataHolder.() -> T): ReadWriteProperty<UserDataH
|
||||
}
|
||||
|
||||
fun <T : Comparable<T>> sort(a: T, b: T) = if (a > b) b to a else a to b
|
||||
inline fun <reified T : Enum<T>> noneOfEnum(): EnumSet<T> = EnumSet.noneOf(T::class.java)
|
||||
|
||||
inline fun Editor.vimForEachCaret(action: (caret: Caret) -> Unit) {
|
||||
if (this.inBlockSubMode) {
|
||||
|
@ -21,11 +21,10 @@
|
||||
package org.jetbrains.plugins.ideavim.action.motion.gn
|
||||
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.helper.StringHelper.parseKeys
|
||||
import com.maddyhome.idea.vim.helper.noneOfEnum
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import java.util.*
|
||||
import javax.swing.KeyStroke
|
||||
|
||||
class GnNextTextObjectTest : VimTestCase() {
|
||||
@ -69,7 +68,7 @@ class GnNextTextObjectTest : VimTestCase() {
|
||||
private fun doTestWithSearch(keys: List<KeyStroke>, before: String,
|
||||
after: String) {
|
||||
configureByText(before)
|
||||
VimPlugin.getSearch().search(myFixture.editor, "test", 1, EnumSet.noneOf(CommandFlags::class.java), false)
|
||||
VimPlugin.getSearch().search(myFixture.editor, "test", 1, noneOfEnum(), false)
|
||||
typeText(keys)
|
||||
myFixture.checkResult(after)
|
||||
assertState(CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
|
@ -21,11 +21,10 @@
|
||||
package org.jetbrains.plugins.ideavim.action.motion.gn
|
||||
|
||||
import com.maddyhome.idea.vim.VimPlugin
|
||||
import com.maddyhome.idea.vim.command.CommandFlags
|
||||
import com.maddyhome.idea.vim.command.CommandState
|
||||
import com.maddyhome.idea.vim.helper.StringHelper.parseKeys
|
||||
import com.maddyhome.idea.vim.helper.noneOfEnum
|
||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||
import java.util.*
|
||||
import javax.swing.KeyStroke
|
||||
|
||||
class GnPreviousTextObjectTest : VimTestCase() {
|
||||
@ -52,7 +51,7 @@ class GnPreviousTextObjectTest : VimTestCase() {
|
||||
private fun doTestWithSearch(keys: List<KeyStroke>, before: String,
|
||||
after: String) {
|
||||
configureByText(before)
|
||||
VimPlugin.getSearch().search(myFixture.editor, "test", 1, EnumSet.noneOf(CommandFlags::class.java), false)
|
||||
VimPlugin.getSearch().search(myFixture.editor, "test", 1, noneOfEnum(), false)
|
||||
typeText(keys)
|
||||
myFixture.checkResult(after)
|
||||
assertState(CommandState.Mode.COMMAND, CommandState.SubMode.NONE)
|
||||
|
Loading…
Reference in New Issue
Block a user