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

Remove unnecessary continue/return hint should handle rule cases and switch expressions. #7968

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

lahodaj
Copy link
Contributor

@lahodaj lahodaj commented Nov 15, 2024

The RemoveUnnecessary hint crashes on code like:

switch (...) {
   case 0 -> { return ; }
}

with exceptions like:

Caused by: java.lang.AssertionError
	at org.netbeans.modules.java.hints.control.RemoveUnnecessary.unnecessaryReturnContinue(RemoveUnnecessary.java:175)
	at org.netbeans.modules.java.hints.control.RemoveUnnecessary.unnecessaryReturn(RemoveUnnecessary.java:99)

This patch adds handling for rule cases and switch expressions.

@lahodaj lahodaj added the Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) label Nov 15, 2024
@lahodaj lahodaj added this to the NB25 milestone Nov 15, 2024
@lahodaj lahodaj requested a review from mbien November 15, 2024 11:41
Copy link
Member

@mbien mbien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks for updating this hint.

edit: while testing I found another issue in a different switch hint #7973

@mbien mbien added the hints label Nov 18, 2024
@lahodaj lahodaj merged commit 7aea558 into apache:master Nov 19, 2024
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hints Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants