Maintenance: VimScript Variables - Convert to objects and improve documentation#1573
Open
claude[bot] wants to merge 3 commits intomasterfrom
Open
Maintenance: VimScript Variables - Convert to objects and improve documentation#1573claude[bot] wants to merge 3 commits intomasterfrom
claude[bot] wants to merge 3 commits intomasterfrom
Conversation
Changed HighLightVariable from a class to an object singleton since it has no mutable state. This prevents unnecessary instantiation and aligns with Kotlin best practices and the pattern used by other Variable implementations like KeyVariable and ValueVariable. Added KDoc documentation explaining what v:hlsearch represents, its behavior, and reference to Vim help. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed RegisterVariable from a class to an object singleton for consistency with other Variable implementations and to prevent unnecessary instantiation. Enhanced KDoc to explicitly mention v:register and added reference to Vim help documentation. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed from instantiating HighLightVariable() and RegisterVariable() to using direct object references HighLightVariable and RegisterVariable, matching the pattern used for KeyVariable and ValueVariable. This eliminates unnecessary object creation since these Variables are now singletons. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HighLightVariableandRegisterVariablefrom classes to object singletonsVimVariableServiceBaseto use direct object references instead of instantiationArea Inspected
vim-engine/src/main/kotlin/com/maddyhome/idea/vim/vimscript/model/variables/HighLightVariable.ktand related Variable implementationsIssues Found
HighLightVariableandRegisterVariablewere classes but had no mutable state, yet were being instantiated on every useHighLightVariablelacked KDoc comments explaining its purposeVimVariableServiceBasecreated new instances withHighLightVariable()andRegisterVariable()on every evaluationChanges Made
1. Convert HighLightVariable to object and add documentation
classtointernal objectsince it has no statev:hlsearchrepresents, its behavior, and reference to:help v:hlsearchKeyVariableandValueVariable2. Convert RegisterVariable to object and improve documentation
classtointernal objectfor consistencyv:registerand added reference to:help v:register3. Update VimVariableServiceBase to use object references
HighLightVariable().evaluate(...)toHighLightVariable.evaluate(...)RegisterVariable().evaluate(...)toRegisterVariable.evaluate(...)KeyVariableandValueVariableWhy These Changes Improve the Code
Testing
Existing tests in
HighLightVariableTestandRegisterVariableTestshould continue to pass unchanged. The functionality remains identical - only the implementation pattern changed.🤖 Generated with Claude Code