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

Rename Ranges, and ExRanges.kt

This commit is contained in:
Matt Ellis 2024-04-02 01:00:02 +01:00 committed by Alex Pláte
parent 751f51c88f
commit 076aab1ccf
89 changed files with 263 additions and 264 deletions
src
main/java/com/maddyhome/idea/vim
test/java/org/jetbrains/plugins/ideavim/ex
vim-engine/src/main/kotlin/com/maddyhome/idea/vim

View File

@ -32,7 +32,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.command.TextObjectVisualType
import com.maddyhome.idea.vim.common.CommandAliasHandler
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.extension.ExtensionHandler
import com.maddyhome.idea.vim.extension.VimExtension
import com.maddyhome.idea.vim.extension.VimExtensionFacade
@ -248,8 +248,8 @@ internal class CommentaryExtension : VimExtension {
* Used like `:1,3Commentary` or `g/fun/Commentary`
*/
private class CommentaryCommandAliasHandler : CommandAliasHandler {
override fun execute(command: String, ranges: Ranges, editor: VimEditor, context: ExecutionContext) {
Util.doCommentary(editor, context, ranges.getTextRange(editor, -1), SelectionType.LINE_WISE, false)
override fun execute(command: String, range: Range, editor: VimEditor, context: ExecutionContext) {
Util.doCommentary(editor, context, range.getTextRange(editor, -1), SelectionType.LINE_WISE, false)
}
}
}

View File

@ -37,7 +37,7 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.common.CommandAlias
import com.maddyhome.idea.vim.common.CommandAliasHandler
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.extension.VimExtension
import com.maddyhome.idea.vim.group.KeyGroup
import com.maddyhome.idea.vim.helper.MessageHelper
@ -137,13 +137,13 @@ internal class NerdTree : VimExtension {
}
class IjCommandHandler(private val actionId: String) : CommandAliasHandler {
override fun execute(command: String, ranges: Ranges, editor: VimEditor, context: ExecutionContext) {
override fun execute(command: String, range: Range, editor: VimEditor, context: ExecutionContext) {
Util.callAction(editor, actionId, context)
}
}
class ToggleHandler : CommandAliasHandler {
override fun execute(command: String, ranges: Ranges, editor: VimEditor, context: ExecutionContext) {
override fun execute(command: String, range: Range, editor: VimEditor, context: ExecutionContext) {
val project = editor.ij.project ?: return
val toolWindow = ToolWindowManagerEx.getInstanceEx(project).getToolWindow(ToolWindowId.PROJECT_VIEW) ?: return
if (toolWindow.isVisible) {
@ -155,7 +155,7 @@ internal class NerdTree : VimExtension {
}
class CloseHandler : CommandAliasHandler {
override fun execute(command: String, ranges: Ranges, editor: VimEditor, context: ExecutionContext) {
override fun execute(command: String, range: Range, editor: VimEditor, context: ExecutionContext) {
val project = editor.ij.project ?: return
val toolWindow = ToolWindowManagerEx.getInstanceEx(project).getToolWindow(ToolWindowId.PROJECT_VIEW) ?: return
if (toolWindow.isVisible) {

View File

@ -16,7 +16,7 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ExOutputModel
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.MessageHelper
import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
@ -26,7 +26,7 @@ import java.util.*
* @author smartbomb
*/
@ExCommand(command = "actionl[ist]")
internal data class ActionListCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges) {
internal data class ActionListCommand(val range: Range, val argument: String) : Command.SingleExecution(range) {
override val argFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -15,7 +15,7 @@ import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.MessageHelper
import com.maddyhome.idea.vim.newapi.ij
@ -27,7 +27,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
* @author John Weigel
*/
@ExCommand(command = "b[uffer]")
internal data class BufferCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges) {
internal data class BufferCommand(val range: Range, val argument: String) : Command.SingleExecution(range) {
override val argFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -19,7 +19,7 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ExOutputModel
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.vimLine
import com.maddyhome.idea.vim.newapi.ij
@ -32,7 +32,7 @@ import org.jetbrains.annotations.NonNls
* @author John Weigel
*/
@ExCommand(command = "ls,files,buffers")
internal data class BufferListCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges) {
internal data class BufferListCommand(val range: Range, val argument: String) : Command.SingleExecution(range) {
override val argFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
companion object {

View File

@ -18,7 +18,7 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ExOutputModel
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.EditorHelper
import com.maddyhome.idea.vim.helper.MessageHelper
import com.maddyhome.idea.vim.newapi.ij
@ -28,7 +28,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
* see "h :!"
*/
@ExCommand(command = "!")
internal data class CmdFilterCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges) {
internal data class CmdFilterCommand(val range: Range, val argument: String) : Command.SingleExecution(range) {
override val argFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.SELF_SYNCHRONIZED)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
@ -70,7 +70,7 @@ internal data class CmdFilterCommand(val ranges: Ranges, val argument: String) :
val workingDirectory = editor.ij.project?.basePath
return try {
if (ranges.size() == 0) {
if (range.size() == 0) {
// Show command output in a window
VimPlugin.getProcess().executeCommand(editor, command, null, workingDirectory)?.let {
ExOutputModel.getInstance(editor.ij).output(it)

View File

@ -18,7 +18,7 @@ import com.maddyhome.idea.vim.api.getLineStartForOffset
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.LineRange
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.group.SearchGroup
import com.maddyhome.idea.vim.group.SearchGroup.RE_BOTH
import com.maddyhome.idea.vim.group.SearchGroup.RE_LAST
@ -38,7 +38,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
* see "h :global" / "h :vglobal"
*/
@ExCommand(command = "g[lobal],v[global]")
internal data class GlobalCommand(val ranges: Ranges, val argument: String, val invert: Boolean) : Command.SingleExecution(ranges, argument) {
internal data class GlobalCommand(val range: Range, val argument: String, val invert: Boolean) : Command.SingleExecution(range, argument) {
override val argFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.SELF_SYNCHRONIZED)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
@ -47,7 +47,7 @@ internal data class GlobalCommand(val ranges: Ranges, val argument: String, val
val caret = editor.currentCaret()
// For :g command the default range is %
val lineRange: LineRange = if (ranges.size() == 0) {
val lineRange: LineRange = if (range.size() == 0) {
LineRange(0, editor.lineCount() - 1)
} else {
getLineRange(editor, caret)

View File

@ -13,7 +13,7 @@ import com.intellij.vim.annotations.ExCommand
import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import org.jetbrains.annotations.NonNls
import java.io.UnsupportedEncodingException
@ -24,7 +24,7 @@ import java.net.URLEncoder
* see "h :help"
*/
@ExCommand(command = "h[elp]")
internal data class HelpCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
internal data class HelpCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
BrowserUtil.browse(helpTopicUrl(argument))

View File

@ -14,7 +14,7 @@ import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ranges.Address
import com.maddyhome.idea.vim.ex.ranges.Address.Companion.createRangeAddresses
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.newapi.globalIjOptions
import com.maddyhome.idea.vim.vimscript.model.commands.ActionCommand
import com.maddyhome.idea.vim.vimscript.model.commands.ActionListCommand
@ -147,7 +147,7 @@ internal object CommandVisitor : VimscriptBaseVisitor<Command>() {
}
}
private fun parseRangesUnit(ctx: VimscriptParser.RangeUnitContext): Array<Address> {
private fun parseRangeUnit(ctx: VimscriptParser.RangeUnitContext): Array<Address> {
val valueAndOffset = parseRangeExpression(ctx.rangeExpression())
val move = ctx.rangeSeparator()?.text == ";"
val addresses = createRangeAddresses(valueAndOffset.first, valueAndOffset.second, move)
@ -158,128 +158,128 @@ internal object CommandVisitor : VimscriptBaseVisitor<Command>() {
return addresses
}
private fun parseRanges(ctx: RangeContext?): Ranges {
val ranges = Ranges()
private fun parseRange(ctx: RangeContext?): Range {
val range = Range()
if (ctx?.rangeUnit() != null) {
for (unit in ctx.rangeUnit()) {
ranges.addAddresses(parseRangesUnit(unit))
range.addAddresses(parseRangeUnit(unit))
}
}
return ranges
return range
}
override fun visitLet1Command(ctx: VimscriptParser.Let1CommandContext): Command {
val ranges: Ranges = parseRanges(ctx.range())
val range: Range = parseRange(ctx.range())
val variable: Expression = expressionVisitor.visit(ctx.expr(0))
val operator = getByValue(ctx.assignmentOperator().text)
val expression: Expression = expressionVisitor.visit(ctx.expr(1))
val command = LetCommand(ranges, variable, operator, expression, true)
val command = LetCommand(range, variable, operator, expression, true)
command.rangeInScript = ctx.getTextRange()
return command
}
override fun visitLet2Command(ctx: VimscriptParser.Let2CommandContext): Command {
val command = LetCommand(Ranges(), SimpleExpression(0), AssignmentOperator.ASSIGNMENT, SimpleExpression(0), false)
val command = LetCommand(Range(), SimpleExpression(0), AssignmentOperator.ASSIGNMENT, SimpleExpression(0), false)
command.rangeInScript = ctx.getTextRange()
return command
}
override fun visitEchoCommand(ctx: EchoCommandContext): Command {
val ranges: Ranges = parseRanges(ctx.range())
val range: Range = parseRange(ctx.range())
val expressions = ctx.expr().stream()
.map { tree: ExprContext ->
expressionVisitor.visit(tree)
}
.collect(Collectors.toList())
val command = EchoCommand(ranges, expressions)
val command = EchoCommand(range, expressions)
command.rangeInScript = ctx.getTextRange()
return command
}
override fun visitCallCommand(ctx: CallCommandContext): Command {
val ranges: Ranges = parseRanges(ctx.range())
val range: Range = parseRange(ctx.range())
val functionCall = ExpressionVisitor.visit(ctx.expr())
val command = CallCommand(ranges, functionCall)
val command = CallCommand(range, functionCall)
command.rangeInScript = ctx.getTextRange()
return command
}
override fun visitDelfunctionCommand(ctx: DelfunctionCommandContext): DelfunctionCommand {
val ranges: Ranges = parseRanges(ctx.range())
val range: Range = parseRange(ctx.range())
val functionScope =
if (ctx.functionScope() != null) Scope.getByValue(ctx.functionScope().text) else null
val functionName = ctx.functionName().text
val ignoreIfMissing = ctx.replace != null
val command = DelfunctionCommand(ranges, functionScope, functionName, ignoreIfMissing)
val command = DelfunctionCommand(range, functionScope, functionName, ignoreIfMissing)
command.rangeInScript = ctx.getTextRange()
return command
}
override fun visitGoToLineCommand(ctx: VimscriptParser.GoToLineCommandContext): Command {
val ranges: Ranges
val range: Range
if (ctx.range() != null) {
ranges = parseRanges(ctx.range())
range = parseRange(ctx.range())
} else {
ranges = Ranges()
ranges.addAddresses(
range = Range()
range.addAddresses(
createRangeAddresses(ctx.shortRange().text, 0, false)
?: throw ExException("Could not create a range"),
)
}
val command = GoToLineCommand(ranges)
val command = GoToLineCommand(range)
command.rangeInScript = ctx.getTextRange()
return command
}
override fun visitCommandWithComment(ctx: VimscriptParser.CommandWithCommentContext): Command {
val ranges = parseRanges(ctx.range())
val ranges = parseRange(ctx.range())
val commandName = ctx.name.text
val argument = ctx.commandArgumentWithoutBars()?.text ?: ""
return createCommandByCommandContext(ranges, argument, commandName, ctx)
}
override fun visitCommandWithoutComments(ctx: VimscriptParser.CommandWithoutCommentsContext): Command {
val ranges = parseRanges(ctx.range())
val ranges = parseRange(ctx.range())
val commandName = ctx.name.text
val argument = ctx.commandArgumentWithoutBars()?.text ?: ""
return createCommandByCommandContext(ranges, argument, commandName, ctx)
}
override fun visitCommandWithBars(ctx: VimscriptParser.CommandWithBarsContext): Command {
val ranges = parseRanges(ctx.range())
val ranges = parseRange(ctx.range())
val commandName = ctx.name.text
val argument = ctx.commandArgumentWithBars()?.text ?: ""
return createCommandByCommandContext(ranges, argument, commandName, ctx)
}
private fun createCommandByCommandContext(ranges: Ranges, argument: String, commandName: String, ctx: ParserRuleContext): Command {
private fun createCommandByCommandContext(range: Range, argument: String, commandName: String, ctx: ParserRuleContext): Command {
val command = when (getCommandByName(commandName)) {
MapCommand::class -> MapCommand(ranges, argument, commandName)
MapClearCommand::class -> MapClearCommand(ranges, argument, commandName)
UnMapCommand::class -> UnMapCommand(ranges, argument, commandName)
MapCommand::class -> MapCommand(range, argument, commandName)
MapClearCommand::class -> MapClearCommand(range, argument, commandName)
UnMapCommand::class -> UnMapCommand(range, argument, commandName)
GlobalCommand::class -> {
if (commandName.startsWith("v")) {
GlobalCommand(ranges, argument, true)
GlobalCommand(range, argument, true)
} else {
if (argument.startsWith("!")) GlobalCommand(ranges, argument.substring(1), true) else GlobalCommand(ranges, argument, false)
if (argument.startsWith("!")) GlobalCommand(range, argument.substring(1), true) else GlobalCommand(range, argument, false)
}
}
SplitCommand::class -> {
if (commandName.startsWith("v")) {
SplitCommand(ranges, argument, SplitType.VERTICAL)
SplitCommand(range, argument, SplitType.VERTICAL)
} else {
SplitCommand(ranges, argument, SplitType.HORIZONTAL)
SplitCommand(range, argument, SplitType.HORIZONTAL)
}
}
SubstituteCommand::class -> SubstituteCommand(ranges, argument, commandName)
else -> getCommandByName(commandName).primaryConstructor!!.call(ranges, argument)
SubstituteCommand::class -> SubstituteCommand(range, argument, commandName)
else -> getCommandByName(commandName).primaryConstructor!!.call(range, argument)
}
command.rangeInScript = ctx.getTextRange()
return command
}
override fun visitShiftLeftCommand(ctx: VimscriptParser.ShiftLeftCommandContext): ShiftLeftCommand {
val ranges = parseRanges(ctx.range())
val ranges = parseRange(ctx.range())
val argument = (ctx.commandArgument?.text ?: "").trim()
val length = ctx.lShift().text.length
val command = ShiftLeftCommand(ranges, argument, length)
@ -288,7 +288,7 @@ internal object CommandVisitor : VimscriptBaseVisitor<Command>() {
}
override fun visitShiftRightCommand(ctx: VimscriptParser.ShiftRightCommandContext): ShiftRightCommand {
val ranges = parseRanges(ctx.range())
val ranges = parseRange(ctx.range())
val argument = (ctx.commandArgument?.text ?: "").trim()
val length = ctx.rShift().text.length
val command = ShiftRightCommand(ranges, argument, length)
@ -297,7 +297,7 @@ internal object CommandVisitor : VimscriptBaseVisitor<Command>() {
}
override fun visitExecuteCommand(ctx: VimscriptParser.ExecuteCommandContext): ExecuteCommand {
val ranges = parseRanges(ctx.range())
val ranges = parseRange(ctx.range())
val expressions = ctx.expr().stream()
.map { tree: ExprContext ->
expressionVisitor.visit(tree)
@ -309,26 +309,26 @@ internal object CommandVisitor : VimscriptBaseVisitor<Command>() {
}
override fun visitLetCommand(ctx: VimscriptParser.LetCommandContext): Command {
val command = com.maddyhome.idea.vim.vimscript.parser.VimscriptParser.parseLetCommand(ctx.text) ?: LetCommand(Ranges(), SimpleExpression(0), AssignmentOperator.ASSIGNMENT, SimpleExpression(0), false)
val command = com.maddyhome.idea.vim.vimscript.parser.VimscriptParser.parseLetCommand(ctx.text) ?: LetCommand(Range(), SimpleExpression(0), AssignmentOperator.ASSIGNMENT, SimpleExpression(0), false)
command.rangeInScript = ctx.getTextRange()
return command
}
override fun visitOtherCommand(ctx: OtherCommandContext): Command {
val ranges: Ranges = parseRanges(ctx.range())
val range: Range = parseRange(ctx.range())
val name = ctx.commandName().text
val argument = ctx.commandArgumentWithBars()?.text ?: ""
val alphabeticPart = name.split(Regex("\\P{Alpha}"))[0]
if (setOf("s", "su", "sub", "subs", "subst", "substi", "substit", "substitu", "substitut", "substitut", "substitute").contains(alphabeticPart)) {
val command = SubstituteCommand(ranges, name.replaceFirst(alphabeticPart, "") + argument, alphabeticPart)
val command = SubstituteCommand(range, name.replaceFirst(alphabeticPart, "") + argument, alphabeticPart)
command.rangeInScript = ctx.getTextRange()
return command
}
val commandConstructor = getCommandByName(name).constructors
.filter { it.parameters.size == 2 }
.firstOrNull { it.parameters[0].type == Ranges::class.createType() && it.parameters[1].type == String::class.createType() }
val command = commandConstructor?.call(ranges, argument) ?: UnknownCommand(ranges, name, argument)
.firstOrNull { it.parameters[0].type == Range::class.createType() && it.parameters[1].type == String::class.createType() }
val command = commandConstructor?.call(range, argument) ?: UnknownCommand(range, name, argument)
command.rangeInScript = ctx.getTextRange()
return command
}

View File

@ -8,7 +8,7 @@
package org.jetbrains.plugins.ideavim.ex
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.CommandLineVimLContext
import com.maddyhome.idea.vim.vimscript.model.Script
import com.maddyhome.idea.vim.vimscript.model.commands.EchoCommand
@ -22,7 +22,7 @@ class VimLContextTest {
@Test
fun `get first context test`() {
val echoCommand = EchoCommand(Ranges(), listOf(SimpleExpression("oh, hi Mark")))
val echoCommand = EchoCommand(Range(), listOf(SimpleExpression("oh, hi Mark")))
val ifStatement1 = IfStatement(listOf(Pair(SimpleExpression(1), listOf(echoCommand))))
val ifStatement2 = IfStatement(listOf(Pair(SimpleExpression(1), listOf(ifStatement1))))
val script = Script(listOf(ifStatement2))

View File

@ -79,9 +79,9 @@ class CommandTests : VimTestCase() {
assertTrue(command is SubstituteCommand)
assertEquals("s", command.command)
assertEquals("/a/b/g", command.argument)
assertEquals(2, command.ranges.size())
assertEquals(MarkAddress('a', 0, false), command.ranges.addresses[0])
assertEquals(MarkAddress('b', 0, false), command.ranges.addresses[1])
assertEquals(2, command.range.size())
assertEquals(MarkAddress('a', 0, false), command.range.addresses[0])
assertEquals(MarkAddress('b', 0, false), command.range.addresses[1])
}
// https://github.com/JetBrains/ideavim/discussions/386
@ -99,9 +99,9 @@ class CommandTests : VimTestCase() {
fun `spaces in range`(sp1: String, sp2: String, sp3: String) {
val command = VimscriptParser.parseCommand("10$sp1,${sp2}20${sp3}d")
assertTrue(command is DeleteLinesCommand)
assertEquals(2, command.ranges.size())
assertEquals(LineAddress(9, 0, false), command.ranges.addresses[0])
assertEquals(LineAddress(19, 0, false), command.ranges.addresses[1])
assertEquals(2, command.range.size())
assertEquals(LineAddress(9, 0, false), command.range.addresses[0])
assertEquals(LineAddress(19, 0, false), command.range.addresses[1])
}
// VIM-2450

View File

@ -11,7 +11,7 @@ package com.maddyhome.idea.vim.common
import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import org.jetbrains.annotations.NonNls
/**
@ -115,5 +115,5 @@ public sealed class GoalCommand {
}
public interface CommandAliasHandler {
public fun execute(command: String, ranges: Ranges, editor: VimEditor, context: ExecutionContext)
public fun execute(command: String, range: Range, editor: VimEditor, context: ExecutionContext)
}

View File

@ -19,7 +19,7 @@ import kotlin.math.min
/**
* Handles the set of range values entered as part of an Ex command.
*/
public class Ranges {
public class Range {
// This property should be private, but is used in tests
@TestOnly
public val addresses: MutableList<Address> = mutableListOf()
@ -224,7 +224,7 @@ public class Ranges {
override fun toString(): String = "Ranges[addresses=$addresses]"
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is Ranges) return false
if (other !is Range) return false
if (startLine != other.startLine) return false
if (endLine != other.endLine) return false

View File

@ -504,7 +504,7 @@ internal object PatternVisitor : RegexParserBaseVisitor<NFA>() {
private fun visitCollection(collectionElements: List<RegexParser.Collection_elemContext>, isNegated: Boolean, includesEOL: Boolean) : NFA {
val individualChars: HashSet<Char> = HashSet()
val ranges: ArrayList<CollectionRange> = ArrayList()
val range: ArrayList<CollectionRange> = ArrayList()
val charClasses: ArrayList<(Char) -> Boolean> = ArrayList()
val collectionElementVisitor = CollectionElementVisitor()
var containsEOL = false
@ -518,7 +518,7 @@ internal object PatternVisitor : RegexParserBaseVisitor<NFA>() {
hasUpperCase = hasUpperCase || element.char.isUpperCase()
individualChars.add(element.char)
}
is CollectionElement.CharacterRange -> ranges.add(CollectionRange(element.start, element.end))
is CollectionElement.CharacterRange -> range.add(CollectionRange(element.start, element.end))
is CollectionElement.CharacterClassExpression -> charClasses.add(element.predicate)
}
}
@ -526,7 +526,7 @@ internal object PatternVisitor : RegexParserBaseVisitor<NFA>() {
/**
* If the collection is empty, match literally with '[]', or '[^]' if negated
*/
if (individualChars.isEmpty() && ranges.isEmpty() && charClasses.isEmpty())
if (individualChars.isEmpty() && range.isEmpty() && charClasses.isEmpty())
return if (isNegated) NFA.fromMatcher(CharacterMatcher('['))
.concatenate(NFA.fromMatcher(CharacterMatcher('^')))
.concatenate(NFA.fromMatcher(CharacterMatcher(']')))
@ -536,7 +536,7 @@ internal object PatternVisitor : RegexParserBaseVisitor<NFA>() {
return NFA.fromMatcher(
CollectionMatcher(
individualChars,
ranges,
range,
charClasses,
isNegated,
includesEOL || containsEOL
@ -741,4 +741,4 @@ internal object PatternVisitor : RegexParserBaseVisitor<NFA>() {
else acc?.concatenate(elem) ?: elem
} ?: NFA.fromSingleState()
}
}
}

View File

@ -15,14 +15,14 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* @author smartbomb
*/
@ExCommand(command = "action")
public data class ActionCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges) {
public data class ActionCommand(val range: Range, val argument: String) : Command.SingleExecution(range) {
override val argFlags: CommandHandlerFlags = flags(
RangeFlag.RANGE_OPTIONAL,

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :ascii"
*/
@ExCommand(command = "as[cii]")
public data class AsciiCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class AsciiCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_FORBIDDEN, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :bdelete"
*/
@ExCommand(command = "bd[elete]")
public data class BufferCloseCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges) {
public data class BufferCloseCommand(val range: Range, val argument: String) : Command.SingleExecution(range) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -14,7 +14,7 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimFuncref
import com.maddyhome.idea.vim.vimscript.model.expressions.Expression
@ -28,7 +28,7 @@ import com.maddyhome.idea.vim.vimscript.model.statements.FunctionFlag
* see "h :call"
*/
@ExCommand(command = "cal[l]")
public class CallCommand(public val ranges: Ranges, public val functionCall: Expression) : Command.SingleExecution(ranges) {
public class CallCommand(public val range: Range, public val functionCall: Expression) : Command.SingleExecution(range) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.SELF_SYNCHRONIZED)
@ -46,7 +46,7 @@ public class CallCommand(public val ranges: Ranges, public val functionCall: Exp
(functionCall.scope?.toString() ?: "") + functionCall.functionName.evaluate(editor, context, vimContext),
)
}
function.ranges = ranges
function.range = range
function.executeFunction(functionCall.arguments, editor, context, this)
return ExecutionResult.Success
}
@ -54,14 +54,14 @@ public class CallCommand(public val ranges: Ranges, public val functionCall: Exp
val name = (functionCall.scope?.toString() ?: "") + functionCall.functionName.evaluate(editor, context, vimContext)
val funcref = injector.variableService.getNullableVariableValue(Variable(functionCall.scope, functionCall.functionName), editor, context, vimContext)
if (funcref is VimFuncref) {
funcref.handler.ranges = ranges
funcref.handler.range = range
funcref.execute(name, functionCall.arguments, editor, context, vimContext)
return ExecutionResult.Success
}
throw ExException("E117: Unknown function: $name")
} else if (functionCall is FuncrefCallExpression) {
functionCall.evaluateWithRange(ranges, editor, context, vimContext)
functionCall.evaluateWithRange(range, editor, context, vimContext)
return ExecutionResult.Success
} else {
// todo add more exceptions

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :comclear"
*/
@ExCommand(command = "comc[lear]")
public data class CmdClearCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class CmdClearCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_FORBIDDEN, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -15,7 +15,7 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.common.CommandAlias
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.VimNlsSafe
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
@ -24,7 +24,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
* see "h :command"
*/
@ExCommand(command = "com[mand]")
public data class CmdCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges) {
public data class CmdCommand(val range: Range, val argument: String) : Command.SingleExecution(range) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
private val unsupportedArgs = listOf(

View File

@ -22,7 +22,7 @@ import com.maddyhome.idea.vim.ex.MissingRangeException
import com.maddyhome.idea.vim.ex.NoArgumentAllowedException
import com.maddyhome.idea.vim.ex.NoRangeAllowedException
import com.maddyhome.idea.vim.ex.ranges.LineRange
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.Msg
import com.maddyhome.idea.vim.helper.noneOfEnum
import com.maddyhome.idea.vim.helper.vimStateMachine
@ -31,7 +31,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import com.maddyhome.idea.vim.vimscript.model.VimLContext
import java.util.*
public sealed class Command(public var commandRanges: Ranges, public val commandArgument: String) : Executable {
public sealed class Command(public var commandRange: Range, public val commandArgument: String) : Executable {
override lateinit var vimContext: VimLContext
override lateinit var rangeInScript: TextRange
@ -39,7 +39,7 @@ public sealed class Command(public var commandRanges: Ranges, public val command
protected open val optFlags: EnumSet<CommandFlags> = noneOfEnum()
private val logger = vimLogger<Command>()
public abstract class ForEachCaret(ranges: Ranges, argument: String = "") : Command(ranges, argument) {
public abstract class ForEachCaret(range: Range, argument: String = "") : Command(range, argument) {
public abstract fun processCommand(
editor: VimEditor,
caret: VimCaret,
@ -48,7 +48,7 @@ public sealed class Command(public var commandRanges: Ranges, public val command
): ExecutionResult
}
public abstract class SingleExecution(ranges: Ranges, argument: String = "") : Command(ranges, argument) {
public abstract class SingleExecution(range: Range, argument: String = "") : Command(range, argument) {
public abstract fun processCommand(
editor: VimEditor,
context: ExecutionContext,
@ -102,18 +102,18 @@ public sealed class Command(public var commandRanges: Ranges, public val command
}
private fun checkRanges(editor: VimEditor) {
if (RangeFlag.RANGE_FORBIDDEN == argFlags.rangeFlag && commandRanges.size() != 0) {
if (RangeFlag.RANGE_FORBIDDEN == argFlags.rangeFlag && commandRange.size() != 0) {
injector.messages.showStatusBarMessage(editor, injector.messages.message(Msg.e_norange))
throw NoRangeAllowedException()
}
if (RangeFlag.RANGE_REQUIRED == argFlags.rangeFlag && commandRanges.size() == 0) {
if (RangeFlag.RANGE_REQUIRED == argFlags.rangeFlag && commandRange.size() == 0) {
injector.messages.showStatusBarMessage(editor, injector.messages.message(Msg.e_rangereq))
throw MissingRangeException()
}
if (RangeFlag.RANGE_IS_COUNT == argFlags.rangeFlag) {
commandRanges.setDefaultLine(1)
commandRange.setDefaultLine(1)
}
}
@ -206,35 +206,35 @@ public sealed class Command(public var commandRanges: Ranges, public val command
public fun flags(rangeFlag: RangeFlag, argumentFlag: ArgumentFlag, access: Access, vararg flags: Flag): CommandHandlerFlags =
CommandHandlerFlags(rangeFlag, argumentFlag, access, flags.toSet())
public fun getLine(editor: VimEditor): Int = commandRanges.getLine(editor)
public fun getLine(editor: VimEditor): Int = commandRange.getLine(editor)
public fun getLine(editor: VimEditor, caret: VimCaret): Int = commandRanges.getLine(editor, caret)
public fun getLine(editor: VimEditor, caret: VimCaret): Int = commandRange.getLine(editor, caret)
public fun getCount(editor: VimEditor, defaultCount: Int, checkCount: Boolean): Int {
val count = if (checkCount) countArgument else -1
val res = commandRanges.getCount(editor, count)
val res = commandRange.getCount(editor, count)
return if (res == -1) defaultCount else res
}
public fun getCount(editor: VimEditor, caret: VimCaret, defaultCount: Int, checkCount: Boolean): Int {
val count = commandRanges.getCount(editor, caret, if (checkCount) countArgument else -1)
val count = commandRange.getCount(editor, caret, if (checkCount) countArgument else -1)
return if (count == -1) defaultCount else count
}
public fun getLineRange(editor: VimEditor): LineRange = commandRanges.getLineRange(editor, -1)
public fun getLineRange(editor: VimEditor): LineRange = commandRange.getLineRange(editor, -1)
public fun getLineRange(editor: VimEditor, caret: VimCaret, checkCount: Boolean = false): LineRange {
return commandRanges.getLineRange(editor, caret, if (checkCount) countArgument else -1)
return commandRange.getLineRange(editor, caret, if (checkCount) countArgument else -1)
}
public fun getTextRange(editor: VimEditor, checkCount: Boolean): TextRange {
val count = if (checkCount) countArgument else -1
return commandRanges.getTextRange(editor, count)
return commandRange.getTextRange(editor, count)
}
public fun getTextRange(editor: VimEditor, caret: VimCaret, checkCount: Boolean): TextRange {
return commandRanges.getTextRange(editor, caret, if (checkCount) countArgument else -1)
return commandRange.getTextRange(editor, caret, if (checkCount) countArgument else -1)
}
private val countArgument: Int

View File

@ -16,7 +16,7 @@ import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.put.PutData
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
@ -24,7 +24,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
* see "h :copy"
*/
@ExCommand(command = "t,co[py]")
public data class CopyTextCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class CopyTextCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_REQUIRED, Access.WRITABLE)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
@ -34,7 +34,7 @@ public data class CopyTextCommand(val ranges: Ranges, val argument: String) : Co
val text = editor.getText(range)
val goToLineCommand = injector.vimscriptParser.parseCommand(argument) ?: throw ExException("E16: Invalid range")
val line = goToLineCommand.commandRanges.getFirstLine(editor, caret)
val line = goToLineCommand.commandRange.getFirstLine(editor, caret)
val transferableData = injector.clipboardManager.getTransferableData(editor, range, text)
val textData = PutData.TextData(text, SelectionType.LINE_WISE, transferableData, null)

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :delcommand"
*/
@ExCommand(command = "delc[ommand]")
public data class DelCmdCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class DelCmdCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_REQUIRED, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
if (!injector.commandGroup.hasAlias(argument)) {

View File

@ -15,14 +15,14 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :delete"
*/
@ExCommand(command = "d[elete]")
public data class DeleteLinesCommand(val ranges: Ranges, var argument: String) : Command.ForEachCaret(ranges, argument) {
public data class DeleteLinesCommand(val range: Range, var argument: String) : Command.ForEachCaret(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.WRITABLE)
override fun processCommand(

View File

@ -13,7 +13,7 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.Msg
import com.maddyhome.idea.vim.mark.VimMarkConstants
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
@ -31,7 +31,7 @@ private const val ESCAPED_QUOTE = "\\\""
private const val UNESCAPED_QUOTE = "\""
@ExCommand(command = "delm[arks]")
public data class DeleteMarksCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class DeleteMarksCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_REQUIRED, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -14,7 +14,7 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import com.maddyhome.idea.vim.vimscript.model.expressions.Scope
@ -23,11 +23,11 @@ import com.maddyhome.idea.vim.vimscript.model.expressions.Scope
*/
@ExCommand(command = "delf[unction]")
public data class DelfunctionCommand(
val ranges: Ranges,
val range: Range,
val scope: Scope?,
val name: String,
val ignoreIfMissing: Boolean,
) : Command.SingleExecution(ranges) {
) : Command.SingleExecution(range) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)

View File

@ -14,14 +14,14 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.diagnostic.vimLogger
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :digraphs"
*/
@ExCommand(command = "dig[raphs]")
public data class DigraphCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class DigraphCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -13,7 +13,7 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import com.maddyhome.idea.vim.vimscript.model.expressions.Expression
@ -21,7 +21,7 @@ import com.maddyhome.idea.vim.vimscript.model.expressions.Expression
* see "h :echo"
*/
@ExCommand(command = "ec[ho]")
public data class EchoCommand(val ranges: Ranges, val args: List<Expression>) : Command.SingleExecution(ranges) {
public data class EchoCommand(val range: Range, val args: List<Expression>) : Command.SingleExecution(range) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :edit"
*/
@ExCommand(command = "e[dit],bro[wse]")
public data class EditFileCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class EditFileCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
val arg = argument

View File

@ -13,7 +13,7 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import com.maddyhome.idea.vim.vimscript.model.expressions.Expression
@ -21,7 +21,7 @@ import com.maddyhome.idea.vim.vimscript.model.expressions.Expression
* see "h :execute"
*/
@ExCommand(command = "exe[cute]")
public data class ExecuteCommand(val ranges: Ranges, val expressions: List<Expression>) : Command.SingleExecution(ranges) {
public data class ExecuteCommand(val range: Range, val expressions: List<Expression>) : Command.SingleExecution(range) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.SELF_SYNCHRONIZED)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :quitall"
*/
@ExCommand(command = "qa[ll],xa[ll],wqa[ll],quita[ll]")
public data class ExitCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class ExitCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :file"
*/
@ExCommand(command = "f[ile]")
public data class FileCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class FileCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_IS_COUNT, ArgumentFlag.ARGUMENT_FORBIDDEN, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :file"
*/
@ExCommand(command = "fin[d]")
public data class FindFileCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class FindFileCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
val arg = argument

View File

@ -13,15 +13,15 @@ import com.maddyhome.idea.vim.api.VimCaret
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import java.lang.Integer.min
/**
* see "h :[range]"
*/
public data class GoToLineCommand(val ranges: Ranges) :
Command.ForEachCaret(ranges) {
public data class GoToLineCommand(val range: Range) :
Command.ForEachCaret(range) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_REQUIRED, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)

View File

@ -13,7 +13,7 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimCaret
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import kotlin.math.max
import kotlin.math.min
@ -22,7 +22,7 @@ import kotlin.math.min
* see "h :goto"
*/
@ExCommand(command = "go[to]")
public data class GotoCharacterCommand(val ranges: Ranges, val argument: String) : Command.ForEachCaret(ranges, argument) {
public data class GotoCharacterCommand(val range: Range, val argument: String) : Command.ForEachCaret(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_IS_COUNT, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(

View File

@ -14,7 +14,7 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.diagnostic.vimLogger
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.history.HistoryConstants.COMMAND
import com.maddyhome.idea.vim.history.HistoryConstants.EXPRESSION
import com.maddyhome.idea.vim.history.HistoryConstants.INPUT
@ -25,7 +25,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
* see "h :history"
*/
@ExCommand(command = "his[tory]")
public data class HistoryCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class HistoryCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
logger.debug("execute")

View File

@ -15,14 +15,14 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :join"
*/
@ExCommand(command = "j[oin]")
public data class JoinLinesCommand(val ranges: Ranges, val argument: String) : Command.ForEachCaret(ranges, argument) {
public data class JoinLinesCommand(val range: Range, val argument: String) : Command.ForEachCaret(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.WRITABLE)
override fun processCommand(

View File

@ -15,7 +15,7 @@ import com.maddyhome.idea.vim.api.getJumpSpot
import com.maddyhome.idea.vim.api.getJumps
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.EngineStringHelper
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import kotlin.math.absoluteValue
@ -24,7 +24,7 @@ import kotlin.math.absoluteValue
* see "h :jumps"
*/
@ExCommand(command = "ju[mps]")
public data class JumpsCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class JumpsCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_FORBIDDEN, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
val jumps = injector.jumpService.getJumps(editor)

View File

@ -16,7 +16,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.diagnostic.vimLogger
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.exExceptionMessage
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.options.OptionAccessScope
import com.maddyhome.idea.vim.register.RegisterConstants
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
@ -45,12 +45,12 @@ import com.maddyhome.idea.vim.vimscript.model.statements.FunctionFlag
*/
@ExCommand(command = "let")
public data class LetCommand(
val ranges: Ranges,
val range: Range,
val variable: Expression,
val operator: AssignmentOperator,
val expression: Expression,
val isSyntaxSupported: Boolean,
) : Command.SingleExecution(ranges) {
) : Command.SingleExecution(range) {
private companion object {
private val logger = vimLogger<LetCommand>()

View File

@ -14,7 +14,7 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import com.maddyhome.idea.vim.vimscript.model.expressions.Scope
import com.maddyhome.idea.vim.vimscript.model.expressions.Variable
@ -23,7 +23,7 @@ import com.maddyhome.idea.vim.vimscript.model.expressions.Variable
* see :h lockvar
*/
@ExCommand(command = "lockv[ar]")
public class LockVarCommand(public val ranges: Ranges, public val argument: String) : Command.SingleExecution(ranges, argument) {
public class LockVarCommand(public val range: Range, public val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
// todo doesn't throw proper vim exceptions in case of wrong arguments
@ -38,7 +38,7 @@ public class LockVarCommand(public val ranges: Ranges, public val argument: Stri
* see :h unlockvar
*/
@ExCommand(command = "unlo[ckvar]")
public class UnlockVarCommand(public val ranges: Ranges, public val argument: String) : Command.SingleExecution(ranges, argument) {
public class UnlockVarCommand(public val range: Range, public val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
// todo doesn't throw proper vim exceptions in case of wrong arguments

View File

@ -13,7 +13,7 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.Msg
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
@ -21,7 +21,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
* see "h :mark"
*/
@ExCommand(command = "k,ma[rk]")
public data class MarkCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class MarkCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_REQUIRED, Access.READ_ONLY)
// todo make it multicaret

View File

@ -13,7 +13,7 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.EngineStringHelper
import com.maddyhome.idea.vim.mark.Mark
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
@ -22,7 +22,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
* see "h :marks"
*/
@ExCommand(command = "marks")
public data class MarksCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class MarksCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -23,7 +23,7 @@ import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.InvalidRangeException
import com.maddyhome.idea.vim.ex.ranges.LineRange
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.Msg
import com.maddyhome.idea.vim.mark.Mark
import com.maddyhome.idea.vim.mark.VimMark
@ -36,7 +36,7 @@ import kotlin.math.min
* see "h :move"
*/
@ExCommand(command = "m[ove]")
public data class MoveTextCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class MoveTextCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_REQUIRED, Access.WRITABLE)
@Throws(ExException::class)
@ -154,7 +154,7 @@ public data class MoveTextCommand(val ranges: Ranges, val argument: String) : Co
command: Command,
lineRange: LineRange,
): Int {
var line = command.commandRanges.getFirstLine(editor, caret)
var line = command.commandRange.getFirstLine(editor, caret)
val adj = lineRange.endLine - lineRange.startLine + 1
if (line >= lineRange.endLine) {
line -= adj

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :next" / "h :bnext"
*/
@ExCommand(command = "n[ext],bn[ext]")
public data class NextFileCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class NextFileCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_IS_COUNT, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :tabnext"
*/
@ExCommand(command = "tabn[ext]")
public data class NextTabCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class NextTabCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
injector.motion.moveCaretGotoNextTab(editor, context, argument.toIntOrNull() ?: 0)

View File

@ -12,14 +12,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :nohlsearch"
*/
@ExCommand(command = "noh[lsearch]")
public data class NoHLSearchCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class NoHLSearchCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_FORBIDDEN, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
injector.searchGroup.clearSearchHighlight()

View File

@ -17,15 +17,14 @@ import com.maddyhome.idea.vim.api.VimMarkService
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.state.mode.Mode
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.exitVisualMode
import com.maddyhome.idea.vim.state.mode.mode
import com.maddyhome.idea.vim.helper.vimStateMachine
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
// todo make it for each caret
@ExCommand(command = "norm[al]")
public data class NormalCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class NormalCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(
RangeFlag.RANGE_OPTIONAL,
ArgumentFlag.ARGUMENT_OPTIONAL,
@ -42,7 +41,7 @@ public data class NormalCommand(val ranges: Ranges, val argument: String) : Comm
}
val commandState = editor.vimStateMachine
val rangeUsed = ranges.size() != 0
val rangeUsed = range.size() != 0
when (editor.mode) {
is Mode.VISUAL -> {
editor.exitVisualMode()

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :only"
*/
@ExCommand(command = "on[ly]")
public data class OnlyCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class OnlyCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -14,14 +14,14 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.api.setToggleOption
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.options.OptionAccessScope
import com.maddyhome.idea.vim.options.ToggleOption
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
// Currently support only matchit
@ExCommand(command = "pa[ckadd]")
public class PackaddCommand(public val ranges: Ranges, public val argument: String) : Command.SingleExecution(ranges, argument) {
public class PackaddCommand(public val range: Range, public val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_REQUIRED, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* This handler is created to support `Plug` command from vim-plug and `Plugin` command from vundle.
*/
@ExCommand(command = "Plug[in]")
public data class PlugCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class PlugCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_REQUIRED, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :previous" / "h :bprevious"
*/
@ExCommand(command = "prev[ious],bp[revious],N[ext]")
public data class PreviousFileCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class PreviousFileCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_IS_COUNT, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
val count = getCount(editor, 1, true)

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :tabprevious"
*/
@ExCommand(command = "tabp[revious],tabN[ext]")
public data class PreviousTabCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class PreviousTabCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
injector.motion.moveCaretGotoPreviousTab(editor, context, argument.toIntOrNull() ?: 0)

View File

@ -14,14 +14,14 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.getText
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :print"
*/
@ExCommand(command = "p[rint],P[rint]")
public data class PrintCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class PrintCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -14,7 +14,7 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.put.PutData
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
@ -22,7 +22,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
* see "h :put"
*/
@ExCommand(command = "pu[t]")
public data class PutLinesCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class PutLinesCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
@ -38,7 +38,7 @@ public data class PutLinesCommand(val ranges: Ranges, val argument: String) : Co
registerGroup.selectRegister(registerGroup.defaultRegister)
}
val line = if (ranges.size() == 0) -1 else getLine(editor)
val line = if (range.size() == 0) -1 else getLine(editor)
val textData = registerGroup.lastRegister?.let {
PutData.TextData(
it.text ?: injector.parser.toKeyNotation(it.keys),

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :quit" / "h :close" / "h :quit"
*/
@ExCommand(command = "q[uit],clo[se],hi[de]")
public data class QuitCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class QuitCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
injector.file.closeFile(editor, context)

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :redo"
*/
@ExCommand(command = "red[o]")
public data class RedoCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class RedoCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_FORBIDDEN, Access.WRITABLE)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
return if (injector.undo.redo(editor, context)) ExecutionResult.Success else ExecutionResult.Error

View File

@ -14,7 +14,7 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.EngineStringHelper
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
@ -22,7 +22,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
* see "h :registers" / "h :display"
*/
@ExCommand(command = "dis[play],reg[isters]")
public data class RegistersCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class RegistersCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
val registerGroup = injector.registerGroup

View File

@ -15,14 +15,14 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :@"
*/
@ExCommand(command = "@")
public data class RepeatCommand(val ranges: Ranges, val argument: String) : Command.ForEachCaret(ranges, argument) {
public data class RepeatCommand(val range: Range, val argument: String) : Command.ForEachCaret(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_REQUIRED, Access.SELF_SYNCHRONIZED)
private var lastArg = ':'

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :argument"
*/
@ExCommand(command = "argu[ment]")
public data class SelectFileCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class SelectFileCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_IS_COUNT, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :first"
*/
@ExCommand(command = "fir[st]")
public data class SelectFirstFileCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class SelectFirstFileCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
val res = injector.file.selectFile(0, context)

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :last"
*/
@ExCommand(command = "la[st]")
public data class SelectLastFileCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class SelectLastFileCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
val res = injector.file.selectFile(999, context)

View File

@ -19,7 +19,7 @@ import com.maddyhome.idea.vim.api.unsetToggleOption
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.exExceptionMessage
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.Msg
import com.maddyhome.idea.vim.options.NumberOption
import com.maddyhome.idea.vim.options.Option
@ -38,21 +38,21 @@ import kotlin.math.ceil
* see "h :set"
*/
@ExCommand(command = "se[t]")
public data class SetCommand(val ranges: Ranges, val argument: String) : SetCommandBase(ranges, argument) {
public data class SetCommand(val range: Range, val argument: String) : SetCommandBase(range, argument) {
override fun getScope(editor: VimEditor): OptionAccessScope = OptionAccessScope.EFFECTIVE(editor)
}
@ExCommand(command = "setg[lobal]")
public data class SetglobalCommand(val ranges: Ranges, val argument: String) : SetCommandBase(ranges, argument) {
public data class SetglobalCommand(val range: Range, val argument: String) : SetCommandBase(range, argument) {
override fun getScope(editor: VimEditor): OptionAccessScope = OptionAccessScope.GLOBAL(editor)
}
@ExCommand(command = "setl[ocal]")
public data class SetlocalCommand(val ranges: Ranges, val argument: String) : SetCommandBase(ranges, argument) {
public data class SetlocalCommand(val range: Range, val argument: String) : SetCommandBase(range, argument) {
override fun getScope(editor: VimEditor): OptionAccessScope = OptionAccessScope.LOCAL(editor)
}
public abstract class SetCommandBase(ranges: Ranges, argument: String) : Command.SingleExecution(ranges, argument) {
public abstract class SetCommandBase(range: Range, argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags =
flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)

View File

@ -13,13 +13,13 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.key.ShortcutOwner
import com.maddyhome.idea.vim.key.ShortcutOwnerInfo
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
@ExCommand(command = "sethandler")
public data class SetHandlerCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class SetHandlerCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -12,7 +12,7 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
@ -20,7 +20,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
* see "h :shell"
*/
@ExCommand(command = "sh[ell]")
public data class ShellCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class ShellCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_FORBIDDEN, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
return if (injector.actionExecutor.executeAction("ActivateTerminalToolWindow", context)) ExecutionResult.Success else ExecutionResult.Error

View File

@ -15,14 +15,14 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :<"
*/
@ExCommand("<")
public data class ShiftLeftCommand(val ranges: Ranges, val argument: String, val length: Int) : Command.ForEachCaret(ranges, argument) {
public data class ShiftLeftCommand(val range: Range, val argument: String, val length: Int) : Command.ForEachCaret(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.WRITABLE)
override fun processCommand(

View File

@ -15,14 +15,14 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :>"
*/
@ExCommand(">")
public data class ShiftRightCommand(val ranges: Ranges, val argument: String, val length: Int) : Command.ForEachCaret(ranges, argument) {
public data class ShiftRightCommand(val range: Range, val argument: String, val length: Int) : Command.ForEachCaret(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.WRITABLE)
override fun processCommand(

View File

@ -16,7 +16,7 @@ import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ranges.LineRange
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.state.mode.inBlockSelection
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import java.util.*
@ -27,7 +27,7 @@ import java.util.*
*/
// todo make it multicaret
@ExCommand(command = "sor[t]")
public data class SortCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class SortCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.WRITABLE)
@Throws(ExException::class)

View File

@ -13,7 +13,7 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.CommandLineVimLContext
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import com.maddyhome.idea.vim.vimscript.services.VimRcService
@ -24,7 +24,7 @@ import java.io.File
* see "h :source"
*/
@ExCommand(command = "so[urce]")
public data class SourceCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class SourceCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_REQUIRED, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
val path = expandUser(argument.trim())

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :split" / "h :vsplit"
*/
@ExCommand(command = "sp[lit],vs[plit]")
public data class SplitCommand(val ranges: Ranges, val argument: String, val splitType: SplitType) : Command.SingleExecution(ranges, argument) {
public data class SplitCommand(val range: Range, val argument: String, val splitType: SplitType) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :substitute"
*/
@ExCommand(command = "~,&,s[ubstitute]")
public data class SubstituteCommand(val ranges: Ranges, val argument: String, val command: String) : Command.SingleExecution(ranges, argument) {
public data class SubstituteCommand(val range: Range, val argument: String, val command: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.SELF_SYNCHRONIZED)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
var result = true

View File

@ -13,7 +13,7 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
@ -21,7 +21,7 @@ import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
* see "h :tabclose"
*/
@ExCommand(command = "tabc[lose]")
public data class TabCloseCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class TabCloseCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)

View File

@ -14,18 +14,18 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/*
* see "h :tabmove"
*/
@ExCommand(command = "tabm[ove]")
public data class TabMoveCommand(val ranges: Ranges, var argument: String) : Command.SingleExecution(ranges, argument) {
public data class TabMoveCommand(val range: Range, var argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
if (ranges.size() != 0) {
if (range.size() != 0) {
throw ExException("Range form of tabmove command is not supported. Please use the argument form")
}

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :tabonly"
*/
@ExCommand(command = "tabo[nly]")
public data class TabOnlyCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class TabOnlyCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_IS_COUNT, ArgumentFlag.ARGUMENT_FORBIDDEN, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
injector.tabService.closeAllExceptCurrentTab(context)

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :undo"
*/
@ExCommand(command = "u[ndo]")
public data class UndoCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class UndoCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_FORBIDDEN, Access.WRITABLE)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -15,7 +15,7 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.common.GoalCommand
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.InvalidCommandException
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.helper.Msg
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import com.maddyhome.idea.vim.vimscript.model.commands.UnknownCommand.Constants.MAX_RECURSION
@ -23,8 +23,8 @@ import com.maddyhome.idea.vim.vimscript.model.commands.UnknownCommand.Constants.
/**
* any command with no parser rule. we assume that it is an alias
*/
public data class UnknownCommand(val ranges: Ranges, val name: String, val argument: String) :
Command.SingleExecution(ranges, argument) {
public data class UnknownCommand(val range: Range, val name: String, val argument: String) :
Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.SELF_SYNCHRONIZED)
private object Constants {
@ -55,7 +55,7 @@ public data class UnknownCommand(val ranges: Ranges, val name: String, val argum
}
}
is GoalCommand.Call -> {
commandAlias.handler.execute(name, ranges, editor, context)
commandAlias.handler.execute(name, range, editor, context)
return ExecutionResult.Success
}
}

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :wall"
*/
@ExCommand(command = "wa[ll]")
public data class WriteAllCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class WriteAllCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
injector.file.saveFiles(context)

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :write"
*/
@ExCommand(command = "w[rite]")
public data class WriteCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class WriteCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
injector.file.saveFile(context)

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :wnext"
*/
@ExCommand(command = "wn[ext]")
public data class WriteNextFileCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class WriteNextFileCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_IS_COUNT, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
val count = getCount(editor, 1, true)

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :wprevious"
*/
@ExCommand(command = "wp[revious],wN[ext]")
public data class WritePreviousFileCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class WritePreviousFileCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
val count = getCount(editor, 1, true)

View File

@ -13,14 +13,14 @@ import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :exit"
*/
@ExCommand(command = "wq,x[it],exi[t]")
public data class WriteQuitCommand(val ranges: Ranges, val argument: String) : Command.SingleExecution(ranges, argument) {
public data class WriteQuitCommand(val range: Range, val argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {
injector.file.saveFile(context)

View File

@ -16,14 +16,14 @@ import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.state.mode.SelectionType
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
/**
* see "h :yank"
*/
@ExCommand(command = "y[ank]")
public data class YankLinesCommand(val ranges: Ranges, var argument: String) : Command.SingleExecution(ranges, argument) {
public data class YankLinesCommand(val range: Range, var argument: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_OPTIONAL, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
@Throws(ExException::class)

View File

@ -14,12 +14,12 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import com.maddyhome.idea.vim.vimscript.model.commands.Command
@ExCommand(command = "mapc[lear],nmapc[lear],vmapc[lear],xmapc[lear],smapc[lear],omapc[lear],mapc[lear],imapc[lear],lmapc[lear],cmapc[lear]")
public data class MapClearCommand(val ranges: Ranges, val argument: String, val cmd: String) : Command.SingleExecution(ranges, argument) {
public data class MapClearCommand(val range: Range, val argument: String, val cmd: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_FORBIDDEN, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -16,7 +16,7 @@ import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.diagnostic.vimLogger
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.key.MappingOwner
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import com.maddyhome.idea.vim.vimscript.model.commands.Command
@ -32,7 +32,7 @@ import javax.swing.KeyStroke
* @author vlan
*/
@ExCommand(command = "map,nm[ap],vm[ap],xm[ap],smap,om[ap],im[ap],lm[ap],cm[ap],no[map],nn[oremap],vn[oremap],xn[oremap],snor[emap],ono[remap],no[remap],ino[remap],ln[oremap],cno[remap]")
public data class MapCommand(val ranges: Ranges, val argument: String, val cmd: String) : Command.SingleExecution(ranges, argument) {
public data class MapCommand(val range: Range, val argument: String, val cmd: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_OPTIONAL, Access.READ_ONLY)
@Throws(ExException::class)

View File

@ -14,12 +14,12 @@ import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.command.MappingMode
import com.maddyhome.idea.vim.command.OperatorArguments
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import com.maddyhome.idea.vim.vimscript.model.commands.Command
@ExCommand(command = "unm[ap],nun[map],vu[nmap],xu[nmap],sunm[ap],ou[nmap],unm[ap],iu[nmap],lu[nmap],cu[nmap]")
public data class UnMapCommand(val ranges: Ranges, val argument: String, val cmd: String) : Command.SingleExecution(ranges, argument) {
public data class UnMapCommand(val range: Range, val argument: String, val cmd: String) : Command.SingleExecution(range, argument) {
override val argFlags: CommandHandlerFlags = flags(RangeFlag.RANGE_FORBIDDEN, ArgumentFlag.ARGUMENT_REQUIRED, Access.READ_ONLY)
override fun processCommand(editor: VimEditor, context: ExecutionContext, operatorArguments: OperatorArguments): ExecutionResult {

View File

@ -11,17 +11,17 @@ package com.maddyhome.idea.vim.vimscript.model.expressions
import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.VimLContext
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimFuncref
public data class FuncrefCallExpression(val expression: Expression, val args: List<Expression>) : Expression() {
public fun evaluateWithRange(ranges: Ranges?, editor: VimEditor, context: ExecutionContext, vimContext: VimLContext): VimDataType {
public fun evaluateWithRange(range: Range?, editor: VimEditor, context: ExecutionContext, vimContext: VimLContext): VimDataType {
val value = expression.evaluate(editor, context, vimContext)
if (value is VimFuncref) {
value.handler.ranges = ranges
value.handler.range = range
return value.execute(value.handler.name, args, editor, context, vimContext)
} else {
// todo more exceptions

View File

@ -10,7 +10,7 @@ package com.maddyhome.idea.vim.vimscript.model.expressions
import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.Executable
import com.maddyhome.idea.vim.vimscript.model.VimLContext
import com.maddyhome.idea.vim.vimscript.model.commands.LetCommand
@ -39,7 +39,7 @@ public data class LambdaExpression(val args: List<String>, val expr: Expression)
for (argument in args) {
body.add(
LetCommand(
Ranges(),
Range(),
Variable(Scope.LOCAL_VARIABLE, argument),
AssignmentOperator.ASSIGNMENT,
Variable(

View File

@ -16,7 +16,7 @@ import com.maddyhome.idea.vim.diagnostic.vimLogger
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.FinishException
import com.maddyhome.idea.vim.ex.ranges.LineAddress
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.ExecutionResult
import com.maddyhome.idea.vim.vimscript.model.VimLContext
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
@ -41,12 +41,12 @@ public data class DefinedFunctionHandler(val function: FunctionDeclaration) : Fu
override fun doFunction(argumentValues: List<Expression>, editor: VimEditor, context: ExecutionContext, vimContext: VimLContext): VimDataType {
var returnValue: VimDataType? = null
val exceptionsCaught = mutableListOf<ExException>()
val isRangeGiven = (ranges?.size() ?: 0) > 0
val isRangeGiven = (range?.size() ?: 0) > 0
if (!isRangeGiven) {
val currentLine = editor.currentCaret().getBufferPosition().line
ranges = Ranges()
ranges!!.addAddresses(
range = Range()
range!!.addAddresses(
arrayOf(
LineAddress(currentLine, 0, false),
LineAddress(currentLine, 0, false),
@ -165,14 +165,14 @@ public data class DefinedFunctionHandler(val function: FunctionDeclaration) : Fu
}
injector.variableService.storeVariable(
Variable(Scope.FUNCTION_VARIABLE, "firstline"),
VimInt(ranges!!.getFirstLine(editor, editor.currentCaret()) + 1),
VimInt(range!!.getFirstLine(editor, editor.currentCaret()) + 1),
editor,
context,
function,
)
injector.variableService.storeVariable(
Variable(Scope.FUNCTION_VARIABLE, "lastline"),
VimInt(ranges!!.getLine(editor, editor.currentCaret()) + 1),
VimInt(range!!.getLine(editor, editor.currentCaret()) + 1),
editor,
context,
function,

View File

@ -11,7 +11,7 @@ package com.maddyhome.idea.vim.vimscript.model.functions
import com.maddyhome.idea.vim.api.ExecutionContext
import com.maddyhome.idea.vim.api.VimEditor
import com.maddyhome.idea.vim.ex.ExException
import com.maddyhome.idea.vim.ex.ranges.Ranges
import com.maddyhome.idea.vim.ex.ranges.Range
import com.maddyhome.idea.vim.vimscript.model.VimLContext
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimDataType
import com.maddyhome.idea.vim.vimscript.model.expressions.Expression
@ -22,14 +22,14 @@ public abstract class FunctionHandler {
public open val scope: Scope? = null
public abstract val minimumNumberOfArguments: Int?
public abstract val maximumNumberOfArguments: Int?
public var ranges: Ranges? = null
public var range: Range? = null
protected abstract fun doFunction(argumentValues: List<Expression>, editor: VimEditor, context: ExecutionContext, vimContext: VimLContext): VimDataType
public fun executeFunction(arguments: List<Expression>, editor: VimEditor, context: ExecutionContext, vimContext: VimLContext): VimDataType {
checkFunctionCall(arguments)
val result = doFunction(arguments, editor, context, vimContext)
ranges = null
range = null
return result
}