diff --git a/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/action/gotoError/GotoErrorInOtherModeHandler.kt b/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/action/gotoError/GotoErrorInOtherModeHandler.kt new file mode 100644 index 0000000..a1e530e --- /dev/null +++ b/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/action/gotoError/GotoErrorInOtherModeHandler.kt @@ -0,0 +1,21 @@ +package com.chylex.intellij.keyboardmaster.feature.action.gotoError + +import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings +import com.intellij.codeInsight.daemon.impl.GotoNextErrorHandler +import com.intellij.openapi.editor.Editor +import com.intellij.openapi.project.Project +import com.intellij.psi.PsiFile + +class GotoErrorInOtherModeHandler(forward: Boolean) : GotoNextErrorHandler(forward) { + override fun invoke(project: Project, editor: Editor, file: PsiFile) { + val settings = DaemonCodeAnalyzerSettings.getInstance() + val oldMode = settings.isNextErrorActionGoesToErrorsFirst + + settings.isNextErrorActionGoesToErrorsFirst = !oldMode + try { + super.invoke(project, editor, file) + } finally { + settings.isNextErrorActionGoesToErrorsFirst = oldMode + } + } +} diff --git a/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/action/gotoError/GotoNextErrorInOtherModeAction.kt b/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/action/gotoError/GotoNextErrorInOtherModeAction.kt new file mode 100644 index 0000000..0548516 --- /dev/null +++ b/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/action/gotoError/GotoNextErrorInOtherModeAction.kt @@ -0,0 +1,10 @@ +package com.chylex.intellij.keyboardmaster.feature.action.gotoError + +import com.intellij.codeInsight.CodeInsightActionHandler +import com.intellij.codeInsight.daemon.impl.actions.GotoNextErrorAction + +class GotoNextErrorInOtherModeAction : GotoNextErrorAction() { + override fun getHandler(): CodeInsightActionHandler { + return GotoErrorInOtherModeHandler(forward = true) + } +} diff --git a/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/action/gotoError/GotoPreviousErrorInOtherModeAction.kt b/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/action/gotoError/GotoPreviousErrorInOtherModeAction.kt new file mode 100644 index 0000000..ec540c2 --- /dev/null +++ b/src/main/kotlin/com/chylex/intellij/keyboardmaster/feature/action/gotoError/GotoPreviousErrorInOtherModeAction.kt @@ -0,0 +1,10 @@ +package com.chylex.intellij.keyboardmaster.feature.action.gotoError + +import com.intellij.codeInsight.CodeInsightActionHandler +import com.intellij.codeInsight.daemon.impl.actions.GotoPreviousErrorAction + +class GotoPreviousErrorInOtherModeAction : GotoPreviousErrorAction() { + override fun getHandler(): CodeInsightActionHandler { + return GotoErrorInOtherModeHandler(forward = false) + } +} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index e4efd87..8f4af26 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -22,4 +22,18 @@ <applicationConfigurable parentId="tools" instance="com.chylex.intellij.keyboardmaster.configuration.PluginConfigurable" id="com.chylex.keyboardmaster" displayName="Keyboard Master" /> <postStartupActivity implementation="com.chylex.intellij.keyboardmaster.PluginStartup" order="last" /> </extensions> + + <actions> + <!-- Go to Highlighted Error --> + <action id="KM.GotoNextErrorInOtherMode" + text="Next Highlighted Error in Other Mode" + class="com.chylex.intellij.keyboardmaster.feature.action.gotoError.GotoNextErrorInOtherModeAction"> + <add-to-group group-id="GoToErrorGroup" anchor="after" relative-to-action="GotoNextError" /> + </action> + <action id="KM.GotoPreviousErrorInOtherMode" + text="Previous Highlighted Error in Other Mode" + class="com.chylex.intellij.keyboardmaster.feature.action.gotoError.GotoPreviousErrorInOtherModeAction"> + <add-to-group group-id="GoToErrorGroup" anchor="after" relative-to-action="GotoPreviousError" /> + </action> + </actions> </idea-plugin>