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

EqualsVisitor Does Not Consider Comments #978

Closed
msteinbeck opened this issue Nov 16, 2016 · 5 comments · Fixed by #993
Closed

EqualsVisitor Does Not Consider Comments #978

msteinbeck opened this issue Nov 16, 2016 · 5 comments · Fixed by #993

Comments

@msteinbeck
Copy link
Contributor

msteinbeck commented Nov 16, 2016

I found that the EqualsVisitor doesn't validate comment tokens. That is, two elements are equal even though their comments are different. A simple c0.getContent().equals(c1.getCotent()) should be sufficient.

@danglotb
Copy link
Member

danglotb commented Nov 16, 2016

Hi @ReTuXx , this is actually done in purpose: see here.
Maybe, the EqualsVisitor could take the comment in account.

@msteinbeck
Copy link
Contributor Author

Maybe, the EqualsVisitor could be take the comment in account.

I think it makes perfectly sense to take a comment into account because a comment is a token which may or may not be equal to another comment token.

@monperrus
Copy link
Collaborator

I'm fine with removing the @IgnoreByEquals to consider all properties incl comments in equality.
This is less surprising, easier to maintain, and removes a hidden bug between equals and hashCode wrt comments.
@ReTuXx do you want to give this a try?

@msteinbeck
Copy link
Contributor Author

@monperrus: I will create a PR later this day.

@msteinbeck
Copy link
Contributor Author

Do I have to copy the file EqualsVisitor.java from target/generated/spoon/support/visitor/equals/EqualsVisitor.java to src/main/java/spoon/support/visitor/equals/EqualsVisitor.java manually? The test case CtGenerationTest.testGenerateEqualsVisitor fails because the generated and commit files differ.

monperrus added a commit to monperrus/spoon that referenced this issue Nov 19, 2016
monperrus added a commit to monperrus/spoon that referenced this issue Nov 19, 2016
monperrus added a commit to monperrus/spoon that referenced this issue Nov 19, 2016
monperrus added a commit to monperrus/spoon that referenced this issue Nov 19, 2016
monperrus added a commit to monperrus/spoon that referenced this issue Nov 19, 2016
monperrus added a commit to monperrus/spoon that referenced this issue Nov 19, 2016
monperrus added a commit to monperrus/spoon that referenced this issue Nov 21, 2016
monperrus added a commit to monperrus/spoon that referenced this issue Nov 21, 2016
tdurieux pushed a commit that referenced this issue Nov 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants