mirror of
https://github.com/chylex/IntelliJ-AceJump.git
synced 2024-11-26 02:42:45 +01:00
Compare commits
No commits in common. "6de52d21b67746c06f2dcc9ad6ba1e1798453d23" and "8062cf5cab36e12aabac2d09a32f80a308f48647" have entirely different histories.
6de52d21b6
...
8062cf5cab
23
.gitignore
vendored
23
.gitignore
vendored
@ -1,5 +1,20 @@
|
|||||||
/.idea/*
|
### JetBrains template
|
||||||
!/.idea/runConfigurations
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio
|
||||||
|
|
||||||
/.gradle/
|
## Directory-based project format:
|
||||||
/build/
|
.idea
|
||||||
|
*.iml
|
||||||
|
|
||||||
|
## Plugin-specific files:
|
||||||
|
# IntelliJ
|
||||||
|
/out/
|
||||||
|
|
||||||
|
### Gradle template
|
||||||
|
.gradle
|
||||||
|
build/
|
||||||
|
|
||||||
|
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||||
|
!gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Mac OS
|
||||||
|
.DS_Store
|
||||||
|
@ -1,43 +1,26 @@
|
|||||||
@file:Suppress("ConvertLambdaToReference")
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.8.0"
|
idea
|
||||||
id("org.jetbrains.intellij") version "1.15.0"
|
kotlin("jvm") version "1.5.10"
|
||||||
|
id("org.jetbrains.intellij") version "1.11.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "org.acejump"
|
|
||||||
version = "chylex-12"
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
|
||||||
jvmToolchain(17)
|
|
||||||
}
|
|
||||||
|
|
||||||
intellij {
|
intellij {
|
||||||
version.set("2023.1")
|
version.set("2022.3.1")
|
||||||
updateSinceUntilBuild.set(false)
|
updateSinceUntilBuild.set(false)
|
||||||
|
pluginsRepositories.custom("https://intellij.chylex.com")
|
||||||
plugins.add("IdeaVIM:chylex-15")
|
plugins.add("IdeaVIM:chylex-15")
|
||||||
|
|
||||||
pluginsRepositories {
|
|
||||||
custom("https://intellij.chylex.com")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.patchPluginXml {
|
|
||||||
sinceBuild.set("231")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.buildSearchableOptions {
|
|
||||||
enabled = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinCompile> {
|
tasks.withType<KotlinCompile> {
|
||||||
kotlinOptions.freeCompilerArgs = listOf(
|
kotlinOptions.jvmTarget = "11"
|
||||||
"-Xjvm-default=all"
|
kotlinOptions.freeCompilerArgs = listOf("-Xjvm-default=all")
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
group = "org.acejump"
|
||||||
|
version = "chylex-11"
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -23,7 +23,7 @@ val Project.openEditors: List<Editor>
|
|||||||
return try {
|
return try {
|
||||||
FileEditorManagerEx.getInstanceEx(this)
|
FileEditorManagerEx.getInstanceEx(this)
|
||||||
.splitters
|
.splitters
|
||||||
.getSelectedEditors()
|
.selectedEditors
|
||||||
.mapNotNull { (it as? TextEditor)?.editor }
|
.mapNotNull { (it as? TextEditor)?.editor }
|
||||||
} catch (e: IncorrectOperationException) {
|
} catch (e: IncorrectOperationException) {
|
||||||
emptyList()
|
emptyList()
|
||||||
|
52
src/main/kotlin/org/acejump/action/AceKeyboardAction.kt
Normal file
52
src/main/kotlin/org/acejump/action/AceKeyboardAction.kt
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package org.acejump.action
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||||
|
import com.intellij.openapi.actionSystem.CommonDataKeys.EDITOR
|
||||||
|
import com.intellij.openapi.project.DumbAwareAction
|
||||||
|
import org.acejump.boundaries.Boundaries
|
||||||
|
import org.acejump.openEditors
|
||||||
|
import org.acejump.search.Pattern
|
||||||
|
import org.acejump.session.Session
|
||||||
|
import org.acejump.session.SessionManager
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class for keyboard-activated actions that create or update an AceJump [Session].
|
||||||
|
*/
|
||||||
|
abstract class AceKeyboardAction : DumbAwareAction() {
|
||||||
|
final override fun update(action: AnActionEvent) {
|
||||||
|
action.presentation.isEnabled = action.getData(EDITOR) != null
|
||||||
|
}
|
||||||
|
|
||||||
|
final override fun actionPerformed(e: AnActionEvent) {
|
||||||
|
val editor = e.getData(EDITOR) ?: return
|
||||||
|
val project = e.project
|
||||||
|
if (project != null) {
|
||||||
|
val jumpEditors = project.openEditors
|
||||||
|
.sortedBy { if (it === editor) 0 else 1 }
|
||||||
|
.ifEmpty { listOf(editor) }
|
||||||
|
invoke(SessionManager.start(editor, jumpEditors))
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
invoke(SessionManager.start(editor))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract operator fun invoke(session: Session)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic action type that starts a regex search.
|
||||||
|
*/
|
||||||
|
abstract class BaseRegexSearchAction(private val pattern: Pattern, private val boundaries: Boundaries) : AceKeyboardAction() {
|
||||||
|
override fun invoke(session: Session) {
|
||||||
|
session.defaultBoundary = boundaries
|
||||||
|
session.startRegexSearch(pattern)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts or ends an AceJump session in quick jump mode.
|
||||||
|
*/
|
||||||
|
object ActivateAceJump : AceKeyboardAction() {
|
||||||
|
override fun invoke(session: Session) = session.startJumpMode()
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,9 @@
|
|||||||
package org.acejump.action
|
package org.acejump.action
|
||||||
|
|
||||||
|
import com.intellij.find.actions.ShowUsagesAction
|
||||||
|
import com.intellij.openapi.actionSystem.ActionManager
|
||||||
|
import com.intellij.openapi.actionSystem.IdeActions
|
||||||
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.command.CommandProcessor
|
import com.intellij.openapi.command.CommandProcessor
|
||||||
import com.intellij.openapi.command.UndoConfirmationPolicy
|
import com.intellij.openapi.command.UndoConfirmationPolicy
|
||||||
import com.intellij.openapi.editor.Document
|
import com.intellij.openapi.editor.Document
|
||||||
@ -9,7 +13,12 @@ import com.intellij.openapi.fileEditor.TextEditor
|
|||||||
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
|
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
|
||||||
import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory
|
import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
|
import com.intellij.openapi.ui.playback.commands.ActionCommand
|
||||||
|
import org.acejump.countMatchingCharacters
|
||||||
|
import org.acejump.immutableText
|
||||||
|
import org.acejump.isWordPart
|
||||||
import org.acejump.search.SearchProcessor
|
import org.acejump.search.SearchProcessor
|
||||||
|
import org.acejump.wordStart
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for actions available after typing a tag.
|
* Base class for actions available after typing a tag.
|
||||||
@ -38,7 +47,23 @@ sealed class AceTagAction {
|
|||||||
abstract fun getCaretOffset(editor: Editor, searchProcessor: SearchProcessor, offset: Int): Int
|
abstract fun getCaretOffset(editor: Editor, searchProcessor: SearchProcessor, offset: Int): Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract class BaseWordAction : BaseJumpAction() {
|
||||||
|
final override fun getCaretOffset(editor: Editor, searchProcessor: SearchProcessor, offset: Int): Int {
|
||||||
|
val matchingChars = countMatchingCharacters(editor, searchProcessor, offset)
|
||||||
|
val targetOffset = offset + matchingChars
|
||||||
|
val isInsideWord = matchingChars > 0 && editor.immutableText.let { it[targetOffset - 1].isWordPart && it[targetOffset].isWordPart }
|
||||||
|
|
||||||
|
return getCaretOffset(editor, offset, targetOffset, isInsideWord)
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract fun getCaretOffset(editor: Editor, queryStartOffset: Int, queryEndOffset: Int, isInsideWord: Boolean): Int
|
||||||
|
}
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
|
fun countMatchingCharacters(editor: Editor, searchProcessor: SearchProcessor, offset: Int): Int {
|
||||||
|
return editor.immutableText.countMatchingCharacters(offset, searchProcessor.query.rawText)
|
||||||
|
}
|
||||||
|
|
||||||
fun recordCaretPosition(editor: Editor) = with(editor) {
|
fun recordCaretPosition(editor: Editor) = with(editor) {
|
||||||
project?.let { addCurrentPositionToHistory(it, document) }
|
project?.let { addCurrentPositionToHistory(it, document) }
|
||||||
}
|
}
|
||||||
@ -49,11 +74,19 @@ sealed class AceTagAction {
|
|||||||
caretModel.moveToOffset(offset)
|
caretModel.moveToOffset(offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun performAction(actionName: String) {
|
||||||
|
val actionManager = ActionManager.getInstance()
|
||||||
|
val action = actionManager.getAction(actionName)
|
||||||
|
if (action != null) {
|
||||||
|
actionManager.tryToExecute(action, ActionCommand.getInputEvent(null), null, null, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun ensureEditorFocused(editor: Editor) {
|
fun ensureEditorFocused(editor: Editor) {
|
||||||
val project = editor.project ?: return
|
val project = editor.project ?: return
|
||||||
val fem = FileEditorManagerEx.getInstanceEx(project)
|
val fem = FileEditorManagerEx.getInstanceEx(project)
|
||||||
|
|
||||||
val window = fem.windows.firstOrNull { (it.selectedComposite?.selectedWithProvider?.fileEditor as? TextEditor)?.editor === editor }
|
val window = fem.windows.firstOrNull { (it.selectedEditor?.selectedWithProvider?.fileEditor as? TextEditor)?.editor === editor }
|
||||||
if (window != null && window !== fem.currentWindow) {
|
if (window != null && window !== fem.currentWindow) {
|
||||||
fem.currentWindow = window
|
fem.currentWindow = window
|
||||||
}
|
}
|
||||||
@ -81,4 +114,67 @@ sealed class AceTagAction {
|
|||||||
return offset
|
return offset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On default action, places the caret at the start of a word. Word detection uses [Character.isJavaIdentifierPart] to count some special
|
||||||
|
* characters, such as underscores, as part of a word. If there is no word at the last character of the search query, then the caret is
|
||||||
|
* placed at the first character of the search query.
|
||||||
|
*
|
||||||
|
* On shift action, adds the new caret to existing carets.
|
||||||
|
*/
|
||||||
|
object JumpToWordStart : BaseWordAction() {
|
||||||
|
override fun getCaretOffset(editor: Editor, queryStartOffset: Int, queryEndOffset: Int, isInsideWord: Boolean): Int {
|
||||||
|
return if (isInsideWord)
|
||||||
|
editor.immutableText.wordStart(queryEndOffset)
|
||||||
|
else
|
||||||
|
queryStartOffset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On default action, performs the Go To Declaration action, available via `Navigate | Declaration or Usages`.
|
||||||
|
* On shift action, performs the Go To Type Declaration action, available via `Navigate | Type Declaration`.
|
||||||
|
* Always places the caret at the start of the word.
|
||||||
|
*/
|
||||||
|
object GoToDeclaration : AceTagAction() {
|
||||||
|
override fun invoke(editor: Editor, searchProcessor: SearchProcessor, offset: Int, shiftMode: Boolean, isFinal: Boolean) {
|
||||||
|
JumpToWordStart(editor, searchProcessor, offset, shiftMode = false, isFinal = isFinal)
|
||||||
|
ApplicationManager.getApplication().invokeLater { performAction(if (shiftMode) IdeActions.ACTION_GOTO_TYPE_DECLARATION else IdeActions.ACTION_GOTO_DECLARATION) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On default action, performs the Show Usages action, available via the context menu.
|
||||||
|
* On shift action, performs the Find Usages action, available via the context menu.
|
||||||
|
* Always places the caret at the start of the word.
|
||||||
|
*/
|
||||||
|
object ShowUsages : AceTagAction() {
|
||||||
|
override fun invoke(editor: Editor, searchProcessor: SearchProcessor, offset: Int, shiftMode: Boolean, isFinal: Boolean) {
|
||||||
|
JumpToWordStart(editor, searchProcessor, offset, shiftMode = false, isFinal = isFinal)
|
||||||
|
ApplicationManager.getApplication().invokeLater { performAction(if (shiftMode) IdeActions.ACTION_FIND_USAGES else ShowUsagesAction.ID) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs the Show Context Actions action, available via the context menu or Alt+Enter.
|
||||||
|
* Always places the caret at the start of the word.
|
||||||
|
*/
|
||||||
|
object ShowIntentions : AceTagAction() {
|
||||||
|
override fun invoke(editor: Editor, searchProcessor: SearchProcessor, offset: Int, shiftMode: Boolean, isFinal: Boolean) {
|
||||||
|
JumpToWordStart(editor, searchProcessor, offset, shiftMode = false, isFinal = isFinal)
|
||||||
|
ApplicationManager.getApplication().invokeLater { performAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On default action, performs the Refactor This action, available via the main menu.
|
||||||
|
* On shift action, performs the Rename... refactoring, available via the main menu.
|
||||||
|
* Always places the caret at the start of the word.
|
||||||
|
*/
|
||||||
|
object Refactor : AceTagAction() {
|
||||||
|
override fun invoke(editor: Editor, searchProcessor: SearchProcessor, offset: Int, shiftMode: Boolean, isFinal: Boolean) {
|
||||||
|
JumpToWordStart(editor, searchProcessor, offset, shiftMode = false, isFinal = isFinal)
|
||||||
|
ApplicationManager.getApplication().invokeLater { performAction(if (shiftMode) IdeActions.ACTION_RENAME else "Refactorings.QuickListPopupAction") }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,169 +1,66 @@
|
|||||||
package org.acejump.action
|
package org.acejump.action
|
||||||
|
|
||||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
import org.acejump.boundaries.Boundaries
|
||||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
|
||||||
import com.intellij.openapi.application.WriteAction
|
|
||||||
import com.intellij.openapi.project.DumbAwareAction
|
|
||||||
import com.maddyhome.idea.vim.KeyHandler
|
|
||||||
import com.maddyhome.idea.vim.VimPlugin
|
|
||||||
import com.maddyhome.idea.vim.action.change.change.ChangeVisualAction
|
|
||||||
import com.maddyhome.idea.vim.action.change.delete.DeleteVisualAction
|
|
||||||
import com.maddyhome.idea.vim.action.copy.YankVisualAction
|
|
||||||
import com.maddyhome.idea.vim.api.injector
|
|
||||||
import com.maddyhome.idea.vim.command.MappingMode.OP_PENDING
|
|
||||||
import com.maddyhome.idea.vim.command.OperatorArguments
|
|
||||||
import com.maddyhome.idea.vim.command.VimStateMachine
|
|
||||||
import com.maddyhome.idea.vim.group.visual.vimSetSelection
|
|
||||||
import com.maddyhome.idea.vim.helper.inVisualMode
|
|
||||||
import com.maddyhome.idea.vim.helper.vimSelectionStart
|
|
||||||
import com.maddyhome.idea.vim.helper.vimStateMachine
|
|
||||||
import com.maddyhome.idea.vim.newapi.vim
|
|
||||||
import org.acejump.boundaries.StandardBoundaries.AFTER_CARET
|
|
||||||
import org.acejump.boundaries.StandardBoundaries.BEFORE_CARET
|
|
||||||
import org.acejump.boundaries.StandardBoundaries.CARET_LINE
|
|
||||||
import org.acejump.boundaries.StandardBoundaries.VISIBLE_ON_SCREEN
|
import org.acejump.boundaries.StandardBoundaries.VISIBLE_ON_SCREEN
|
||||||
import org.acejump.modes.JumpMode
|
import org.acejump.modes.ActionMode
|
||||||
import org.acejump.search.Pattern
|
import org.acejump.session.Session
|
||||||
import org.acejump.search.Tag
|
|
||||||
import org.acejump.session.SessionManager
|
|
||||||
import org.acejump.session.SessionState
|
|
||||||
|
|
||||||
sealed class AceVimAction : DumbAwareAction() {
|
sealed class AceVimAction : AceKeyboardAction() {
|
||||||
protected abstract val mode: AceVimMode
|
protected abstract val boundary: Boundaries
|
||||||
|
|
||||||
final override fun actionPerformed(e: AnActionEvent) {
|
final override fun invoke(session: Session) {
|
||||||
val editor = e.getData(CommonDataKeys.EDITOR) ?: return
|
session.defaultBoundary = boundary
|
||||||
val context = e.dataContext.vim
|
start(session)
|
||||||
|
|
||||||
val caret = editor.caretModel.currentCaret
|
|
||||||
val initialOffset = caret.offset
|
|
||||||
val selectionStart = if (editor.inVisualMode) caret.vimSelectionStart else null
|
|
||||||
|
|
||||||
val session = SessionManager.start(editor, mode.getJumpEditors(editor))
|
|
||||||
|
|
||||||
session.defaultBoundary = mode.boundaries
|
|
||||||
session.startJumpMode {
|
|
||||||
object : JumpMode() {
|
|
||||||
override fun accept(state: SessionState, acceptedTag: Tag): Boolean {
|
|
||||||
state.act(AceTagAction.JumpToSearchStart, acceptedTag, wasUpperCase, isFinal = true)
|
|
||||||
|
|
||||||
if (selectionStart != null) {
|
|
||||||
caret.vimSetSelection(selectionStart, caret.offset, moveCaretToSelectionEnd = true)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
val vim = editor.vim
|
|
||||||
val commandState = vim.vimStateMachine
|
|
||||||
if (commandState.isOperatorPending) {
|
|
||||||
val key = commandState.commandBuilder.keys.singleOrNull()?.keyChar
|
|
||||||
|
|
||||||
commandState.reset()
|
|
||||||
KeyHandler.getInstance().fullReset(vim)
|
|
||||||
|
|
||||||
VimPlugin.getVisualMotion().enterVisualMode(vim, VimStateMachine.SubMode.VISUAL_CHARACTER)
|
|
||||||
caret.vimSetSelection(caret.offset, initialOffset, moveCaretToSelectionEnd = true)
|
|
||||||
|
|
||||||
val action = when (key) {
|
|
||||||
'd' -> DeleteVisualAction()
|
|
||||||
'c' -> ChangeVisualAction()
|
|
||||||
'y' -> YankVisualAction()
|
|
||||||
else -> null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action != null) {
|
protected abstract fun start(session: Session)
|
||||||
ApplicationManager.getApplication().invokeLater {
|
|
||||||
WriteAction.run<Nothing> {
|
|
||||||
commandState.commandBuilder.pushCommandPart(action)
|
|
||||||
|
|
||||||
val cmd = commandState.commandBuilder.buildCommand()
|
class GoToDeclaration : AceVimAction() {
|
||||||
val operatorArguments = OperatorArguments(
|
override val boundary = VISIBLE_ON_SCREEN
|
||||||
commandState.mappingState.mappingMode == OP_PENDING,
|
override fun start(session: Session) {
|
||||||
cmd.rawCount, commandState.mode, commandState.subMode
|
session.startJumpMode { ActionMode(AceTagAction.GoToDeclaration, shiftMode = false) }
|
||||||
)
|
|
||||||
|
|
||||||
commandState.setExecutingCommand(cmd)
|
|
||||||
injector.actionExecutor.executeVimAction(vim, action, context, operatorArguments)
|
|
||||||
// TODO does not update status
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mode.finishSession(editor, session)
|
class GoToTypeDeclaration : AceVimAction() {
|
||||||
return true
|
override val boundary = VISIBLE_ON_SCREEN
|
||||||
}
|
override fun start(session: Session) {
|
||||||
|
session.startJumpMode { ActionMode(AceTagAction.GoToDeclaration, shiftMode = true) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mode.setupSession(editor, session)
|
class ShowIntentions : AceVimAction() {
|
||||||
|
override val boundary = VISIBLE_ON_SCREEN
|
||||||
|
override fun start(session: Session) {
|
||||||
|
session.startJumpMode { ActionMode(AceTagAction.ShowIntentions, shiftMode = false) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class JumpAllEditors : AceVimAction() {
|
class ShowUsages : AceVimAction() {
|
||||||
override val mode = AceVimMode.JumpAllEditors
|
override val boundary = VISIBLE_ON_SCREEN
|
||||||
|
override fun start(session: Session) {
|
||||||
|
session.startJumpMode { ActionMode(AceTagAction.ShowUsages, shiftMode = false) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class JumpForward : AceVimAction() {
|
class FindUsages : AceVimAction() {
|
||||||
override val mode = AceVimMode.Jump(AFTER_CARET.intersection(VISIBLE_ON_SCREEN))
|
override val boundary = VISIBLE_ON_SCREEN
|
||||||
|
override fun start(session: Session) {
|
||||||
|
session.startJumpMode { ActionMode(AceTagAction.ShowUsages, shiftMode = true) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class JumpBackward : AceVimAction() {
|
class Refactor : AceVimAction() {
|
||||||
override val mode = AceVimMode.Jump(BEFORE_CARET.intersection(VISIBLE_ON_SCREEN))
|
override val boundary = VISIBLE_ON_SCREEN
|
||||||
|
override fun start(session: Session) {
|
||||||
|
session.startJumpMode { ActionMode(AceTagAction.Refactor, shiftMode = false) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class JumpTillForward : AceVimAction() {
|
class Rename : AceVimAction() {
|
||||||
override val mode = AceVimMode.JumpTillForward(AFTER_CARET.intersection(VISIBLE_ON_SCREEN))
|
override val boundary = VISIBLE_ON_SCREEN
|
||||||
|
override fun start(session: Session) {
|
||||||
|
session.startJumpMode { ActionMode(AceTagAction.Refactor, shiftMode = true) }
|
||||||
}
|
}
|
||||||
|
|
||||||
class JumpTillBackward : AceVimAction() {
|
|
||||||
override val mode = AceVimMode.JumpTillBackward(BEFORE_CARET.intersection(VISIBLE_ON_SCREEN))
|
|
||||||
}
|
|
||||||
|
|
||||||
class JumpOnLineForward : AceVimAction() {
|
|
||||||
override val mode = AceVimMode.Jump(AFTER_CARET.intersection(CARET_LINE))
|
|
||||||
}
|
|
||||||
|
|
||||||
class JumpOnLineBackward : AceVimAction() {
|
|
||||||
override val mode = AceVimMode.Jump(BEFORE_CARET.intersection(CARET_LINE))
|
|
||||||
}
|
|
||||||
|
|
||||||
class JumpLineIndentsForward : AceVimAction() {
|
|
||||||
override val mode = AceVimMode.JumpToPattern(Pattern.LINE_INDENTS, AFTER_CARET.intersection(VISIBLE_ON_SCREEN))
|
|
||||||
}
|
|
||||||
|
|
||||||
class JumpLineIndentsBackward : AceVimAction() {
|
|
||||||
override val mode = AceVimMode.JumpToPattern(Pattern.LINE_INDENTS, BEFORE_CARET.intersection(VISIBLE_ON_SCREEN))
|
|
||||||
}
|
|
||||||
|
|
||||||
class JumpLWordForward : AceVimAction() {
|
|
||||||
override val mode = AceVimMode.JumpToPattern(Pattern.VIM_LWORD, AFTER_CARET.intersection(VISIBLE_ON_SCREEN))
|
|
||||||
}
|
|
||||||
|
|
||||||
class JumpUWordForward : AceVimAction() {
|
|
||||||
override val mode = AceVimMode.JumpToPattern(Pattern.VIM_UWORD, AFTER_CARET.intersection(VISIBLE_ON_SCREEN))
|
|
||||||
}
|
|
||||||
|
|
||||||
class JumpLWordBackward : AceVimAction() {
|
|
||||||
override val mode = AceVimMode.JumpToPattern(Pattern.VIM_LWORD, BEFORE_CARET.intersection(VISIBLE_ON_SCREEN))
|
|
||||||
}
|
|
||||||
|
|
||||||
class JumpUWordBackward : AceVimAction() {
|
|
||||||
override val mode = AceVimMode.JumpToPattern(Pattern.VIM_UWORD, BEFORE_CARET.intersection(VISIBLE_ON_SCREEN))
|
|
||||||
}
|
|
||||||
|
|
||||||
class JumpLWordEndForward : AceVimAction() {
|
|
||||||
override val mode = AceVimMode.JumpToPattern(Pattern.VIM_LWORD_END, AFTER_CARET.intersection(VISIBLE_ON_SCREEN))
|
|
||||||
}
|
|
||||||
|
|
||||||
class JumpUWordEndForward : AceVimAction() {
|
|
||||||
override val mode = AceVimMode.JumpToPattern(Pattern.VIM_UWORD_END, AFTER_CARET.intersection(VISIBLE_ON_SCREEN))
|
|
||||||
}
|
|
||||||
|
|
||||||
class JumpLWordEndBackward : AceVimAction() {
|
|
||||||
override val mode = AceVimMode.JumpToPattern(Pattern.VIM_LWORD_END, BEFORE_CARET.intersection(VISIBLE_ON_SCREEN))
|
|
||||||
}
|
|
||||||
|
|
||||||
class JumpUWordEndBackward : AceVimAction() {
|
|
||||||
override val mode = AceVimMode.JumpToPattern(Pattern.VIM_UWORD_END, BEFORE_CARET.intersection(VISIBLE_ON_SCREEN))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
src/main/kotlin/org/acejump/modes/ActionMode.kt
Normal file
12
src/main/kotlin/org/acejump/modes/ActionMode.kt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package org.acejump.modes
|
||||||
|
|
||||||
|
import org.acejump.action.AceTagAction
|
||||||
|
import org.acejump.search.Tag
|
||||||
|
import org.acejump.session.SessionState
|
||||||
|
|
||||||
|
class ActionMode(private val action: AceTagAction, private val shiftMode: Boolean) : JumpMode() {
|
||||||
|
override fun accept(state: SessionState, acceptedTag: Tag): Boolean {
|
||||||
|
state.act(action, acceptedTag, shiftMode, isFinal = true)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
59
src/main/kotlin/org/acejump/vim/AceVimExtension.kt
Normal file
59
src/main/kotlin/org/acejump/vim/AceVimExtension.kt
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package org.acejump.vim
|
||||||
|
|
||||||
|
import com.maddyhome.idea.vim.api.injector
|
||||||
|
import com.maddyhome.idea.vim.command.MappingMode
|
||||||
|
import com.maddyhome.idea.vim.extension.VimExtension
|
||||||
|
import com.maddyhome.idea.vim.extension.VimExtensionFacade
|
||||||
|
import com.maddyhome.idea.vim.key.MappingOwner
|
||||||
|
import org.acejump.boundaries.StandardBoundaries
|
||||||
|
import org.acejump.search.Pattern
|
||||||
|
|
||||||
|
class AceVimExtension : VimExtension {
|
||||||
|
private companion object {
|
||||||
|
const val NAME = "AceJump"
|
||||||
|
const val PLUG_PREFIX = "<Plug>(acejump)"
|
||||||
|
|
||||||
|
private val OWNER = MappingOwner.Plugin.get(NAME)
|
||||||
|
|
||||||
|
private fun register(keys: String, mode: AceVimMode) {
|
||||||
|
val keysPrefixed = injector.parser.parseKeys("${PLUG_PREFIX}$keys")
|
||||||
|
val keysCommand = injector.parser.parseKeys(command(keys))
|
||||||
|
|
||||||
|
VimExtensionFacade.putExtensionHandlerMapping(MappingMode.NVO, keysCommand, OWNER, AceVimHandler(mode), false)
|
||||||
|
VimExtensionFacade.putKeyMapping(MappingMode.NVO, keysPrefixed, OWNER, keysCommand, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun command(name: String): String {
|
||||||
|
return "<Plug>(acejump-$name)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getName(): String {
|
||||||
|
return NAME
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun init() {
|
||||||
|
register("<Space>", AceVimMode.JumpAllEditors)
|
||||||
|
register("s", AceVimMode.JumpAllEditors)
|
||||||
|
|
||||||
|
register("f", AceVimMode.Jump(StandardBoundaries.AFTER_CARET))
|
||||||
|
register("F", AceVimMode.Jump(StandardBoundaries.BEFORE_CARET))
|
||||||
|
register("t", AceVimMode.JumpTillForward(StandardBoundaries.AFTER_CARET))
|
||||||
|
register("T", AceVimMode.JumpTillBackward(StandardBoundaries.BEFORE_CARET))
|
||||||
|
|
||||||
|
register("w", AceVimMode.JumpToPattern(Pattern.VIM_LWORD, StandardBoundaries.AFTER_CARET))
|
||||||
|
register("W", AceVimMode.JumpToPattern(Pattern.VIM_UWORD, StandardBoundaries.AFTER_CARET))
|
||||||
|
register("b", AceVimMode.JumpToPattern(Pattern.VIM_LWORD, StandardBoundaries.BEFORE_CARET))
|
||||||
|
register("B", AceVimMode.JumpToPattern(Pattern.VIM_UWORD, StandardBoundaries.BEFORE_CARET))
|
||||||
|
register("e", AceVimMode.JumpToPattern(Pattern.VIM_LWORD_END, StandardBoundaries.AFTER_CARET))
|
||||||
|
register("E", AceVimMode.JumpToPattern(Pattern.VIM_LWORD_END, StandardBoundaries.AFTER_CARET))
|
||||||
|
register("ge", AceVimMode.JumpToPattern(Pattern.VIM_UWORD_END, StandardBoundaries.BEFORE_CARET))
|
||||||
|
register("gE", AceVimMode.JumpToPattern(Pattern.VIM_UWORD_END, StandardBoundaries.BEFORE_CARET))
|
||||||
|
|
||||||
|
register("j", AceVimMode.JumpToPattern(Pattern.LINE_INDENTS, StandardBoundaries.AFTER_CARET))
|
||||||
|
register("k", AceVimMode.JumpToPattern(Pattern.LINE_INDENTS, StandardBoundaries.BEFORE_CARET))
|
||||||
|
|
||||||
|
register("l", AceVimMode.Jump(StandardBoundaries.AFTER_CARET.intersection(StandardBoundaries.CARET_LINE)))
|
||||||
|
register("h", AceVimMode.Jump(StandardBoundaries.BEFORE_CARET.intersection(StandardBoundaries.CARET_LINE)))
|
||||||
|
}
|
||||||
|
}
|
92
src/main/kotlin/org/acejump/vim/AceVimHandler.kt
Normal file
92
src/main/kotlin/org/acejump/vim/AceVimHandler.kt
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
package org.acejump.vim
|
||||||
|
|
||||||
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
|
import com.intellij.openapi.application.WriteAction
|
||||||
|
import com.maddyhome.idea.vim.KeyHandler
|
||||||
|
import com.maddyhome.idea.vim.VimPlugin
|
||||||
|
import com.maddyhome.idea.vim.action.change.change.ChangeVisualAction
|
||||||
|
import com.maddyhome.idea.vim.action.change.delete.DeleteVisualAction
|
||||||
|
import com.maddyhome.idea.vim.action.copy.YankVisualAction
|
||||||
|
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.MappingMode
|
||||||
|
import com.maddyhome.idea.vim.command.OperatorArguments
|
||||||
|
import com.maddyhome.idea.vim.command.VimStateMachine
|
||||||
|
import com.maddyhome.idea.vim.extension.ExtensionHandler
|
||||||
|
import com.maddyhome.idea.vim.group.visual.vimSetSelection
|
||||||
|
import com.maddyhome.idea.vim.helper.inVisualMode
|
||||||
|
import com.maddyhome.idea.vim.helper.vimSelectionStart
|
||||||
|
import com.maddyhome.idea.vim.helper.vimStateMachine
|
||||||
|
import com.maddyhome.idea.vim.newapi.ij
|
||||||
|
import org.acejump.action.AceTagAction
|
||||||
|
import org.acejump.modes.JumpMode
|
||||||
|
import org.acejump.search.Tag
|
||||||
|
import org.acejump.session.SessionManager
|
||||||
|
import org.acejump.session.SessionState
|
||||||
|
|
||||||
|
class AceVimHandler(private val mode: AceVimMode) : ExtensionHandler {
|
||||||
|
override fun execute(editor: VimEditor, context: ExecutionContext) {
|
||||||
|
val ij = editor.ij
|
||||||
|
val caret = ij.caretModel.currentCaret
|
||||||
|
val initialOffset = caret.offset
|
||||||
|
val selectionStart = if (ij.inVisualMode) caret.vimSelectionStart else null
|
||||||
|
|
||||||
|
val session = SessionManager.start(ij, mode.getJumpEditors(ij))
|
||||||
|
|
||||||
|
session.defaultBoundary = mode.boundaries
|
||||||
|
session.startJumpMode {
|
||||||
|
object : JumpMode() {
|
||||||
|
override fun accept(state: SessionState, acceptedTag: Tag): Boolean {
|
||||||
|
state.act(AceTagAction.JumpToSearchStart, acceptedTag, wasUpperCase, isFinal = true)
|
||||||
|
|
||||||
|
if (selectionStart != null) {
|
||||||
|
caret.vimSetSelection(selectionStart, caret.offset, moveCaretToSelectionEnd = true)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
val commandState = editor.vimStateMachine
|
||||||
|
if (commandState.isOperatorPending) {
|
||||||
|
val key = commandState.commandBuilder.keys.singleOrNull()?.keyChar
|
||||||
|
|
||||||
|
commandState.reset()
|
||||||
|
KeyHandler.getInstance().fullReset(editor)
|
||||||
|
|
||||||
|
VimPlugin.getVisualMotion().enterVisualMode(editor, VimStateMachine.SubMode.VISUAL_CHARACTER)
|
||||||
|
caret.vimSetSelection(caret.offset, initialOffset, moveCaretToSelectionEnd = true)
|
||||||
|
|
||||||
|
val action = when (key) {
|
||||||
|
'd' -> DeleteVisualAction()
|
||||||
|
'c' -> ChangeVisualAction()
|
||||||
|
'y' -> YankVisualAction()
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action != null) {
|
||||||
|
ApplicationManager.getApplication().invokeLater {
|
||||||
|
WriteAction.run<Nothing> {
|
||||||
|
commandState.commandBuilder.pushCommandPart(action)
|
||||||
|
|
||||||
|
val cmd = commandState.commandBuilder.buildCommand()
|
||||||
|
val operatorArguments = OperatorArguments(
|
||||||
|
commandState.mappingState.mappingMode == MappingMode.OP_PENDING,
|
||||||
|
cmd.rawCount, commandState.mode, commandState.subMode
|
||||||
|
)
|
||||||
|
|
||||||
|
commandState.setExecutingCommand(cmd)
|
||||||
|
injector.actionExecutor.executeVimAction(editor, action, context, operatorArguments)
|
||||||
|
// TODO does not update status
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mode.finishSession(ij, session)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mode.setupSession(ij, session)
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.acejump.action
|
package org.acejump.vim
|
||||||
|
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import org.acejump.boundaries.Boundaries
|
import org.acejump.boundaries.Boundaries
|
||||||
@ -8,7 +8,8 @@ import org.acejump.search.Pattern
|
|||||||
import org.acejump.session.Session
|
import org.acejump.session.Session
|
||||||
|
|
||||||
sealed class AceVimMode {
|
sealed class AceVimMode {
|
||||||
abstract val boundaries: Boundaries
|
open val boundaries: Boundaries
|
||||||
|
get() = StandardBoundaries.VISIBLE_ON_SCREEN
|
||||||
|
|
||||||
open fun getJumpEditors(mainEditor: Editor): List<Editor> {
|
open fun getJumpEditors(mainEditor: Editor): List<Editor> {
|
||||||
return listOf(mainEditor)
|
return listOf(mainEditor)
|
||||||
@ -20,7 +21,6 @@ sealed class AceVimMode {
|
|||||||
class Jump(override val boundaries: Boundaries) : AceVimMode()
|
class Jump(override val boundaries: Boundaries) : AceVimMode()
|
||||||
|
|
||||||
object JumpAllEditors : AceVimMode() {
|
object JumpAllEditors : AceVimMode() {
|
||||||
override val boundaries = StandardBoundaries.VISIBLE_ON_SCREEN
|
|
||||||
override fun getJumpEditors(mainEditor: Editor): List<Editor> {
|
override fun getJumpEditors(mainEditor: Editor): List<Editor> {
|
||||||
val project = mainEditor.project ?: return super.getJumpEditors(mainEditor)
|
val project = mainEditor.project ?: return super.getJumpEditors(mainEditor)
|
||||||
|
|
5
src/main/resources/META-INF/acejump-ideavim.xml
Normal file
5
src/main/resources/META-INF/acejump-ideavim.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<idea-plugin>
|
||||||
|
<extensions defaultExtensionNs="IdeaVIM">
|
||||||
|
<vimExtension implementation="org.acejump.vim.AceVimExtension" name="acejump" />
|
||||||
|
</extensions>
|
||||||
|
</idea-plugin>
|
@ -9,11 +9,12 @@
|
|||||||
</description>
|
</description>
|
||||||
|
|
||||||
<depends>com.intellij.modules.platform</depends>
|
<depends>com.intellij.modules.platform</depends>
|
||||||
<depends>IdeaVIM</depends>
|
|
||||||
|
|
||||||
<category>Navigation</category>
|
<category>Navigation</category>
|
||||||
<vendor url="https://github.com/acejump/AceJump">AceJump</vendor>
|
<vendor url="https://github.com/acejump/AceJump">AceJump</vendor>
|
||||||
|
|
||||||
|
<depends optional="true" config-file="acejump-ideavim.xml">IdeaVIM</depends>
|
||||||
|
|
||||||
<extensions defaultExtensionNs="com.intellij">
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
<applicationService serviceImplementation="org.acejump.config.AceConfig"/>
|
<applicationService serviceImplementation="org.acejump.config.AceConfig"/>
|
||||||
<applicationConfigurable groupId="tools" displayName="AceJump"
|
<applicationConfigurable groupId="tools" displayName="AceJump"
|
||||||
@ -29,22 +30,33 @@
|
|||||||
</extensions>
|
</extensions>
|
||||||
|
|
||||||
<actions>
|
<actions>
|
||||||
<action id="AceVimAction_JumpAllEditors" class="org.acejump.action.AceVimAction$JumpAllEditors" text="AceJump Vim - Jump All Editors" />
|
<action id="AceAction"
|
||||||
<action id="AceVimAction_JumpForward" class="org.acejump.action.AceVimAction$JumpForward" text="AceJump Vim - Jump Forward" />
|
class="org.acejump.action.AceKeyboardAction$ActivateAceJump"
|
||||||
<action id="AceVimAction_JumpBackward" class="org.acejump.action.AceVimAction$JumpBackward" text="AceJump Vim - Jump Backward" />
|
text="Activate AceJump">
|
||||||
<action id="AceVimAction_JumpTillForward" class="org.acejump.action.AceVimAction$JumpTillForward" text="AceJump Vim - Jump Till Forward" />
|
<keyboard-shortcut keymap="Mac OS X" first-keystroke="ctrl SEMICOLON"/>
|
||||||
<action id="AceVimAction_JumpTillBackward" class="org.acejump.action.AceVimAction$JumpTillBackward" text="AceJump Vim - Jump Till Backward" />
|
<keyboard-shortcut keymap="Mac OS X 10.5+" first-keystroke="ctrl SEMICOLON"/>
|
||||||
<action id="AceVimAction_JumpOnLineForward" class="org.acejump.action.AceVimAction$JumpOnLineForward" text="AceJump Vim - Jump On Line Forward" />
|
<keyboard-shortcut keymap="$default" first-keystroke="ctrl SEMICOLON"/>
|
||||||
<action id="AceVimAction_JumpOnLineBackward" class="org.acejump.action.AceVimAction$JumpOnLineBackward" text="AceJump Vim - Jump On Line Backward" />
|
</action>
|
||||||
<action id="AceVimAction_JumpLineIndentsForward" class="org.acejump.action.AceVimAction$JumpLineIndentsForward" text="AceJump Vim - Jump Line Indents Forward" />
|
<action id="AceVimAction_GoToDeclaration"
|
||||||
<action id="AceVimAction_JumpLineIndentsBackward" class="org.acejump.action.AceVimAction$JumpLineIndentsBackward" text="AceJump Vim - Jump Line Indents Backward" />
|
class="org.acejump.action.AceVimAction$GoToDeclaration"
|
||||||
<action id="AceVimAction_JumpLWordForward" class="org.acejump.action.AceVimAction$JumpLWordForward" text="AceJump Vim - Jump LWord Forward" />
|
text="AceJump Vim - GoToDeclaration"/>
|
||||||
<action id="AceVimAction_JumpUWordForward" class="org.acejump.action.AceVimAction$JumpUWordForward" text="AceJump Vim - Jump UWord Forward" />
|
<action id="AceVimAction_GoToTypeDeclaration"
|
||||||
<action id="AceVimAction_JumpLWordBackward" class="org.acejump.action.AceVimAction$JumpLWordBackward" text="AceJump Vim - Jump LWord Backward" />
|
class="org.acejump.action.AceVimAction$GoToTypeDeclaration"
|
||||||
<action id="AceVimAction_JumpUWordBackward" class="org.acejump.action.AceVimAction$JumpUWordBackward" text="AceJump Vim - Jump UWord Backward" />
|
text="AceJump Vim - GoToTypeDeclaration"/>
|
||||||
<action id="AceVimAction_JumpLWordEndForward" class="org.acejump.action.AceVimAction$JumpLWordEndForward" text="AceJump Vim - Jump LWord End Forward" />
|
<action id="AceVimAction_ShowIntentions"
|
||||||
<action id="AceVimAction_JumpUWordEndForward" class="org.acejump.action.AceVimAction$JumpUWordEndForward" text="AceJump Vim - Jump UWord End Forward" />
|
class="org.acejump.action.AceVimAction$ShowIntentions"
|
||||||
<action id="AceVimAction_JumpLWordEndBackward" class="org.acejump.action.AceVimAction$JumpLWordEndBackward" text="AceJump Vim - Jump LWord End Backward" />
|
text="AceJump Vim - ShowIntentions"/>
|
||||||
<action id="AceVimAction_JumpUWordEndBackward" class="org.acejump.action.AceVimAction$JumpUWordEndBackward" text="AceJump Vim - Jump UWord End Backward" />
|
<action id="AceVimAction_ShowUsages"
|
||||||
|
class="org.acejump.action.AceVimAction$ShowUsages"
|
||||||
|
text="AceJump Vim - ShowUsages"/>
|
||||||
|
<action id="AceVimAction_FindUsages"
|
||||||
|
class="org.acejump.action.AceVimAction$FindUsages"
|
||||||
|
text="AceJump Vim - FindUsages"/>
|
||||||
|
<action id="AceVimAction_Refactor"
|
||||||
|
class="org.acejump.action.AceVimAction$Refactor"
|
||||||
|
text="AceJump Vim - Refactor"/>
|
||||||
|
<action id="AceVimAction_Rename"
|
||||||
|
class="org.acejump.action.AceVimAction$Rename"
|
||||||
|
text="AceJump Vim - Rename"/>
|
||||||
</actions>
|
</actions>
|
||||||
</idea-plugin>
|
</idea-plugin>
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
import org.acejump.action.AceKeyboardAction
|
||||||
import org.acejump.action.AceVimAction
|
|
||||||
import org.acejump.test.util.BaseTest
|
import org.acejump.test.util.BaseTest
|
||||||
|
import org.junit.Ignore
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
import kotlin.system.measureTimeMillis
|
import kotlin.system.measureTimeMillis
|
||||||
|
|
||||||
|
@Ignore
|
||||||
class LatencyTest : BaseTest() {
|
class LatencyTest : BaseTest() {
|
||||||
|
|
||||||
private fun `test tag latency`(editorText: String) {
|
private fun `test tag latency`(editorText: String) {
|
||||||
@ -14,7 +15,7 @@ class LatencyTest : BaseTest() {
|
|||||||
|
|
||||||
for (query in chars) {
|
for (query in chars) {
|
||||||
makeEditor(editorText)
|
makeEditor(editorText)
|
||||||
myFixture.testAction(AceVimAction.JumpAllEditors())
|
myFixture.testAction(AceKeyboardAction.ActivateAceJump)
|
||||||
time += measureTimeMillis { typeAndWaitForResults("$query") }
|
time += measureTimeMillis { typeAndWaitForResults("$query") }
|
||||||
// TODO assert(Tagger.markers.isNotEmpty()) { "Should be tagged: $query" }
|
// TODO assert(Tagger.markers.isNotEmpty()) { "Should be tagged: $query" }
|
||||||
resetEditor()
|
resetEditor()
|
||||||
|
@ -7,7 +7,7 @@ import com.intellij.openapi.fileTypes.PlainTextFileType
|
|||||||
import com.intellij.psi.PsiFile
|
import com.intellij.psi.PsiFile
|
||||||
import com.intellij.testFramework.fixtures.BasePlatformTestCase
|
import com.intellij.testFramework.fixtures.BasePlatformTestCase
|
||||||
import com.intellij.util.ui.UIUtil
|
import com.intellij.util.ui.UIUtil
|
||||||
import org.acejump.action.AceVimAction
|
import org.acejump.action.AceKeyboardAction
|
||||||
import org.acejump.session.SessionManager
|
import org.acejump.session.SessionManager
|
||||||
|
|
||||||
abstract class BaseTest : BasePlatformTestCase() {
|
abstract class BaseTest : BasePlatformTestCase() {
|
||||||
@ -58,7 +58,7 @@ abstract class BaseTest : BasePlatformTestCase() {
|
|||||||
private fun String.executeQuery(query: String) {
|
private fun String.executeQuery(query: String) {
|
||||||
myFixture.run {
|
myFixture.run {
|
||||||
makeEditor(this@executeQuery)
|
makeEditor(this@executeQuery)
|
||||||
testAction(AceVimAction.JumpAllEditors())
|
testAction(AceKeyboardAction.ActivateAceJump)
|
||||||
typeAndWaitForResults(query)
|
typeAndWaitForResults(query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user