1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-02-28 11:45:59 +01:00

Fix qodana inspections

This commit is contained in:
Alex Plate 2023-02-28 10:10:24 +02:00
parent ec05ca11ba
commit ec4684c336
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
5 changed files with 13 additions and 15 deletions
src
main/java/com/maddyhome/idea/vim
test/java/org/jetbrains/plugins/ideavim

View File

@ -170,10 +170,11 @@ public class FileGroup extends VimFileBase {
final FileEditorManagerEx fileEditorManager = FileEditorManagerEx.getInstanceEx(project);
final EditorWindow window = fileEditorManager.getCurrentWindow();
VirtualFile[] editors = fileEditorManager.getOpenFiles();
if (number >= 0 && number < editors.length) {
fileEditorManager.closeFile(editors[number], window);
}
if (!ApplicationManager.getApplication().isUnitTestMode()) {
if (window != null) {
if (number >= 0 && number < editors.length) {
fileEditorManager.closeFile(editors[number], window);
}
} if (!ApplicationManager.getApplication().isUnitTestMode()) {
// This thing doesn't have an implementation in test mode
EditorsSplitters.focusDefaultComponentInSplittersIfPresent(project);
}

View File

@ -77,7 +77,7 @@ class JumpsListener : RecentPlacesListener {
val jumpService = injector.jumpService as VimJumpServiceImpl
if (!isChanged) {
if (changePlace.timeStamp < jumpService.lastJumpTimeStamp) return // this listener is notified asynchronously and
if (changePlace.timeStamp < jumpService.lastJumpTimeStamp) return // this listener is notified asynchronously, and
// we do not want jumps that were processed before
val jump = buildJump(changePlace) ?: return
jumpService.addJump(jump, true)
@ -89,7 +89,7 @@ class JumpsListener : RecentPlacesListener {
val jumpService = injector.jumpService
if (!isChanged) {
if (changePlace.timeStamp < jumpService.lastJumpTimeStamp) return // this listener is notified asynchronously and
if (changePlace.timeStamp < jumpService.lastJumpTimeStamp) return // this listener is notified asynchronously, and
// we do not want jumps that were processed before
val jump = buildJump(changePlace) ?: return
jumpService.removeJump(jump)

View File

@ -55,7 +55,7 @@ private val Editor.disabledInDialog: Boolean
*/
fun Editor.isPrimaryEditor(): Boolean {
val project = project ?: return false
val fileEditorManager = FileEditorManagerEx.getInstanceEx(project) ?: return false
val fileEditorManager = FileEditorManagerEx.getInstanceEx(project)
return fileEditorManager.allEditors.any { fileEditor -> this == EditorUtil.getEditorEx(fileEditor) }
}
@ -78,12 +78,6 @@ private inline fun findParentByCondition(c: Component?, condition: (Component?)
return null
}
fun Editor.endsWithNewLine(): Boolean {
val textLength = this.document.textLength
if (textLength == 0) return false
return this.document.charsSequence[textLength - 1] == '\n'
}
/**
* Get caret line in vim notation (1-based)
*/

View File

@ -8,6 +8,7 @@
package com.maddyhome.idea.vim.vimscript.services
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.extensions.ExtensionPointName
import com.maddyhome.idea.vim.api.VimscriptFunctionService
@ -163,7 +164,7 @@ class FunctionStorage : VimscriptFunctionService {
}
override fun registerHandlers() {
extensionPoint.extensions().forEach(FunctionBeanClass::register)
extensionPoint.getExtensionList(ApplicationManager.getApplication()).forEach(FunctionBeanClass::register)
}
override fun addHandler(handlerHolder: Any) {

View File

@ -68,7 +68,9 @@ class RegisterActionsTest : VimTestCase() {
val after = "I f${c}ound it in a legendary land"
var motionRightAction: ActionBeanClass? = null
doTest("l", before, after, VimStateMachine.Mode.COMMAND, VimStateMachine.SubMode.NONE) {
motionRightAction = VIM_ACTIONS_EP.extensions().filter { it.actionId == "VimPreviousTabAction" }.findFirst().get()
motionRightAction =
VIM_ACTIONS_EP.getExtensionList(null)
.filter { it.actionId == "VimPreviousTabAction" }.first()
assertNotNull(getCommandNode())