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

this.caseExpression attribute in CtCase is no longer needed #4019

Closed
algomaster99 opened this issue Jun 30, 2021 · 2 comments · Fixed by #4023
Closed

this.caseExpression attribute in CtCase is no longer needed #4019

algomaster99 opened this issue Jun 30, 2021 · 2 comments · Fixed by #4023
Labels

Comments

@algomaster99
Copy link
Contributor

Reference: #4015 (comment)

Before Java 12, only one case expression was allowed per case, so spoon maintained an attribute this.caseExpression which would store the expression corresponding to the case. Java 12 introduced a feature to add multiple expressions to a single case, so this.caseExpressions was introduced, which would contain a list of CtExpressions. The second attribute, this.caseExpressions, made this.caseExpression obsolete.

I propose that we remove the attribute and modify its getters and setters to, instead, return the list's first element and clear the list and insert a single element, respectively. This would reduce redundancy. Another benefit is that some visitors like CtScanner do not even access this.caseExpression. So if someone would have set the case expression using this.setCaseExpression, they won't even see it in their pretty-printed string.

@slarse slarse added the refactor label Jul 1, 2021
@slarse
Copy link
Collaborator

slarse commented Jul 1, 2021

I agree, seems like a good refactoring.

@algomaster99
Copy link
Contributor Author

I am working on it. I shall submit a PR soon.

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

Successfully merging a pull request may close this issue.

2 participants