Skip to content
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

Add two methods in class VisitorMap for debug purposes #4391

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Laughh
Copy link

@Laughh Laughh commented Apr 27, 2024

The method keySet() and entrySet() are still based on hash code and the built-in equal() method, and there is no way to get all keys and entries, so I added two address-sensetive methods to get them which are more convenient for debugging.

@jlerbsc
Copy link
Collaborator

jlerbsc commented Apr 27, 2024

Thank you for this suggestion, but I'm not sure that it's essential as the VisitorMap class accepts as parameters an implementation of a visitor for calculating the hashcode and another for implementing equals.

@Laughh
Copy link
Author

Laughh commented Apr 27, 2024

Thank you for this suggestion, but I'm not sure that it's essential as the VisitorMap class accepts as parameters an implementation of a visitor for calculating the hashcode and another for implementing equals.

As mentioned above, the two methods are used for debugging purpose. And the reason I wrote about them was precisely because I was having trouble debugging VisitorMap. And maybe there are two keys in VisitorMap, but when we print it, only one key showed.

@Laughh
Copy link
Author

Laughh commented Apr 27, 2024

Is it useful for debugging purpose?

@jlerbsc
Copy link
Collaborator

jlerbsc commented Apr 27, 2024

No, I don't think so.

@Laughh
Copy link
Author

Laughh commented Apr 27, 2024

Without the functions,is there any way to obtain all keys by using keySet() if two of them have same hash code and equals?Like what I describe in issue #4390

@jlerbsc
Copy link
Collaborator

jlerbsc commented Apr 28, 2024

There is no way of obtaining this result with the VisitorMap class, as it relies internally on the operation of the HashCodeVisitor class. But you can certainly either use the VisitorSet class or implement your own Visitor class to suit your specific needs or extend the CompilationUnit class and redefine the hashcode and equals methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants