Skip to content

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

Merged
lahodaj merged 1 commit intoapache:masterfrom
lahodaj:remove-unnecessary-for-rule-switches
Nov 19, 2024
Merged

Remove unnecessary continue/return hint should handle rule cases and switch expressions.#7968
lahodaj merged 1 commit intoapache:masterfrom
lahodaj:remove-unnecessary-for-rule-switches

Conversation

@lahodaj
Copy link
Copy Markdown
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
Copy Markdown
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

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