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

Quick assist "Join if statement with inner if" drops comments #1853

Closed
srikanth-sankaran opened this issue Dec 14, 2024 · 1 comment · Fixed by #1858
Closed

Quick assist "Join if statement with inner if" drops comments #1853

srikanth-sankaran opened this issue Dec 14, 2024 · 1 comment · Fixed by #1858
Assignees
Labels
bug Something isn't working

Comments

@srikanth-sankaran
Copy link

This block of code:

        if ((this.bits & ASTNode.SwitchRuleBlock) != 0) { // switch rule blocks shouldn't fall through ...
		if (flowInfo != FlowInfo.DEAD_END) {
			if (flowContext.associatedNode instanceof SwitchExpression) { // ... demand that for expression switch
				currentScope.problemReporter().switchExpressionBlockCompletesNormally(this);
			} else { // ... enforce that for statement switch, by an automagic break
				flowContext.recordBreakFrom(flowInfo);
				return FlowInfo.DEAD_END;
			}
		}
	}

becomes this:

        if ((this.bits & ASTNode.SwitchRuleBlock) != 0 && flowInfo != FlowInfo.DEAD_END) {
		if (flowContext.associatedNode instanceof SwitchExpression) { // ... demand that for expression switch
			currentScope.problemReporter().switchExpressionBlockCompletesNormally(this);
		} else { // ... enforce that for statement switch, by an automagic break
			flowContext.recordBreakFrom(flowInfo);
			return FlowInfo.DEAD_END;
		}
	}

See that the original comment // switch rule blocks shouldn't fall through ... has vanished

@jjohnstn jjohnstn self-assigned this Dec 14, 2024
@jjohnstn jjohnstn added the bug Something isn't working label Dec 14, 2024
jjohnstn added a commit to jjohnstn/eclipse.jdt.ui-1 that referenced this issue Dec 17, 2024
- modify EmbeddedIfCleanUp to check for line comments on the
  top and embedded if statement and preserve them in the merged
  if statement
- add new method to ASTNodes to get trailing line comment for
  a node plus an offset
- modify the embedded cleanup test in CleanUpTest to add new
  line comment scenarios
- fixes eclipse-jdt#1853
@srikanth-sankaran
Copy link
Author

Thanks so much @jjohnstn - No good deed shall go unpunished 😆 - so I gift you #1859 and #1856

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants