Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package org.jetbrains.plugins.ideavim
import com.intellij.application.options.CodeStyle
import com.intellij.ide.ClipboardSynchronizer
import com.intellij.ide.bookmark.BookmarksManager
import com.intellij.ide.highlighter.JavaFileType
import com.intellij.ide.highlighter.XmlFileType
import com.intellij.lang.Language
import com.intellij.openapi.actionSystem.ActionManager
Expand Down Expand Up @@ -301,6 +302,7 @@ abstract class VimTestCase(private val defaultEditorText: String? = null) {

protected fun configureByText(content: String) = configureByText(PlainTextFileType.INSTANCE, content)
protected fun configureByXmlText(content: String) = configureByText(XmlFileType.INSTANCE, content)
protected fun configureByJavaText(content: String) = configureByText(JavaFileType.INSTANCE, content)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good placement and consistency: This helper method is now properly aligned with the existing configureByXmlText method, following the established pattern in the codebase. The refactoring successfully eliminates duplication.

Minor note: The method returns Editor (inherited from the base configureByText method), which is consistent with the original implementations and maintains backward compatibility.


protected fun configureAndGuard(content: String) {
val ranges = extractBrackets(content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@

package org.jetbrains.plugins.ideavim

import com.intellij.ide.highlighter.JavaFileType

abstract class VimJavaTestCase : VimTestCase() {
protected fun configureByJavaText(content: String) = configureByText(JavaFileType.INSTANCE, content)
}
/**
* Base test case for tests that require Java file type support.
*
* This class extends [VimTestCase] and is specifically designed for tests that need to work with
* Java source files, where language-specific features like auto-indentation, code folding, or
* syntax-aware operations are required.
*
* Tests can use the inherited [configureByJavaText] method from [VimTestCase] to set up Java files.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent documentation: The KDoc is comprehensive and clearly explains:

  • The purpose of the class
  • When to use it vs. using VimTestCase directly
  • That it now inherits configureByJavaText from the parent

Suggestion: Consider adding a @since tag if the project follows that convention for documentation, though I don't see this pattern used elsewhere in the codebase, so it's likely not necessary.

* This class serves as a semantic marker and provides a convenient base for Java-specific test setup
* if needed in the future.
*
* @see VimTestCase
*/
abstract class VimJavaTestCase : VimTestCase()
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

package org.jetbrains.plugins.ideavim.propertybased

import com.intellij.ide.highlighter.JavaFileType
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.editor.Editor
import com.maddyhome.idea.vim.KeyHandler
Expand Down Expand Up @@ -40,6 +39,4 @@ abstract class VimPropertyTestBase : VimTestCase() {
VimPlugin.getSearch().resetState()
VimPlugin.getChange().reset()
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean refactoring: The removal of the duplicate configureByJavaText method and its import is correct. The method is now inherited from VimTestCase, maintaining full backward compatibility.

All 4 subclasses of VimPropertyTestBase will continue to work without modification:

  • RandomActionsPropertyTest.kt (which uses configureByJavaText)
  • YankDeletePropertyTest.kt
  • IncrementDecrementCheck.kt
  • MapPropertyTest.kt


protected fun configureByJavaText(content: String) = configureByText(JavaFileType.INSTANCE, content)
}
Loading