-
Notifications
You must be signed in to change notification settings - Fork 27
[#501] Add equals and hashCode implementations to PSI class wrappers
#500
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: development
Are you sure you want to change the base?
[#501] Add equals and hashCode implementations to PSI class wrappers
#500
Conversation
Implemented `equals` and `hashCode` methods in `JavaPsiClassWrapper` and `KotlinPsiClassWrapper` to ensure proper comparison and hashing based on the qualified name.
🚨 PR Title Needs FormattingPlease specify the modified module and, preferrably, include a GitHub or YouTrack issue that this PR closes in the title. By
|
equals and hashCode implementations to PSI class wrappersequals and hashCode implementations to PSI class wrappers
equals and hashCode implementations to PSI class wrappersequals and hashCode implementations to PSI class wrappers
equals and hashCode implementations to PSI class wrappersequals and hashCode implementations to PSI class wrappers
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.
Pull Request Overview
This PR implements proper equals and hashCode methods in PSI class wrappers to fix duplicate entries in sets when collecting interesting classes for prompt generation. The fix ensures that classes are compared and hashed based on their qualified names rather than object identity.
- Added
equalsandhashCodeimplementations to both Java and Kotlin PSI class wrappers - Both implementations use
qualifiedNameas the basis for equality and hashing - Includes validation that
qualifiedNameis not empty to ensure meaningful comparisons
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| KotlinPsiClassWrapper.kt | Added equals and hashCode methods using qualified name comparison |
| JavaPsiClassWrapper.kt | Added equals and hashCode methods using qualified name comparison |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
kotlin/src/main/kotlin/org/jetbrains/research/testspark/kotlin/KotlinPsiClassWrapper.kt
Outdated
Show resolved
Hide resolved
java/src/main/kotlin/org/jetbrains/research/testspark/java/JavaPsiClassWrapper.kt
Outdated
Show resolved
Hide resolved
…aPsiClassWrapper.kt Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…/KotlinPsiClassWrapper.kt Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Description of changes made
Implemented
equalsandhashCodemethods inJavaPsiClassWrapperandKotlinPsiClassWrapperto ensure proper comparison and hashing based on the qualified name.Why is merge request needed
When the
PromptManagergetsinterestingPsiClasses(here) usingpsiHelper.getInterestingPsiClassesWithQualifiedNames,PsiMethodWrapper.getInterestingPsiClassesWithQualifiedNamesis called.The
JavaPsiMethodWrapperandKotlinPsiMethodWrappercreate a new instance of the corresponding PsiClassWrapper for each interesting PSI class.If the same class is added to the
MutableSet, two items will be present because they will be two distinct instances of thePsiClassWrapper.Other notes
Fixes #501
I can't think of any particular case where two distinct classes can have the same qualified name.
Potential improvements
Based on data of a TGA-Pipeline run with the current version of TestSpark, duplicate class signatures has been removed from the prompt, resulting in a potentially significant improvement in performance.
What is missing?
Please mention if anything is missing for this merge request, e.g you have decided to move something to the next merge request