1
0
mirror of https://github.com/chylex/IntelliJ-Keyboard-Master.git synced 2025-04-22 17:15:43 +02:00

Add actions to go to next/previous highlighted error in other mode

This commit is contained in:
chylex 2023-10-17 02:39:56 +02:00
parent a3aee8cd84
commit 6f7cb51300
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548
4 changed files with 55 additions and 0 deletions
src/main
kotlin/com/chylex/intellij/keyboardmaster/feature/action/gotoError
resources/META-INF

View File

@ -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
}
}
}

View File

@ -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)
}
}

View File

@ -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)
}
}

View File

@ -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>