-
Notifications
You must be signed in to change notification settings - Fork 801
Maintenance: Test infrastructure - Refactor configureByJavaText helper #1374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Maintenance: Test infrastructure - Refactor configureByJavaText helper #1374
Conversation
Consolidated duplicate configureByJavaText method and improved documentation to enhance test infrastructure maintainability. Changes: - Moved configureByJavaText to VimTestCase base class alongside configureByXmlText - Removed duplicate implementations from VimJavaTestCase and VimPropertyTestBase - Added comprehensive KDoc to VimJavaTestCase explaining its purpose - Added JavaFileType import to VimTestCase This eliminates code duplication while maintaining consistency with the existing pattern of providing file-type-specific helper methods in the base test class. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
|
||
| 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) |
There was a problem hiding this comment.
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.
| * 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. |
There was a problem hiding this comment.
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
VimTestCasedirectly - That it now inherits
configureByJavaTextfrom 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.
|
|
||
| VimPlugin.getSearch().resetState() | ||
| VimPlugin.getChange().reset() | ||
| } |
There was a problem hiding this comment.
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 usesconfigureByJavaText)YankDeletePropertyTest.ktIncrementDecrementCheck.ktMapPropertyTest.kt
PR Review: Test Infrastructure RefactoringOverall Assessment: ✅ APPROVEDThis is an excellent refactoring that improves code quality and maintainability without changing any functional behavior. Strengths1. Eliminates Code Duplication ✅
2. Consistency with Existing Patterns ✅
3. Excellent Documentation ✅
4. Clean Dependency Management ✅
5. Zero Breaking Changes ✅
Code Quality
Test Coverage
Security & Performance
RecommendationsThis PR is ready to merge as-is. No changes required. Suggestion for future work (not blocking): Consider similar refactoring opportunities for other file type helpers if they exist elsewhere in the test infrastructure. Great work on identifying and fixing this duplication! This type of maintenance improves long-term codebase health. |
Summary
configureByJavaTexthelper method toVimTestCasebase classVimJavaTestCaseandVimPropertyTestBaseVimJavaTestCaseArea Inspected
During routine codebase maintenance, I inspected:
tests/java-tests/src/test/kotlin/org/jetbrains/plugins/ideavim/VimJavaTestCase.ktIssues Found
configureByJavaTextmethod was duplicated in bothVimJavaTestCaseandVimPropertyTestBase, violating the DRY principleVimTestCasealready providesconfigureByXmlTextdirectly in the base class, but Java support required subclasses to define their own helperVimJavaTestCaselacked KDoc explaining its purposeChanges Made
configureByJavaTexttoVimTestCase.kt(line 305) alongside the existingconfigureByXmlText, maintaining consistency with the established patternVimJavaTestCase(now inherits from parent)VimPropertyTestBase(now inherits from parent)JavaFileTypeimport fromVimPropertyTestBaseVimJavaTestCaseexplaining:VimTestCasedirectlyWhy These Changes Improve the Code
configureByJavaTexthelperconfigureByXmlTextis in the base class)Test Plan
configureByJavaTextcontinue to work via inheritanceVimJavaTestCaseare unaffected🤖 Generated with Claude Code