← 返回首页
Improve inline breakpoint discovery when expression is multiline. Fix #521 by gayanper · Pull Request #522 · microsoft/java-debug · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Improve inline breakpoint discovery when expression is multiline. Fix #521#522

Merged
testforstephen merged 3 commits into
microsoft:mainfrom
gayanper:multi-line-breakpoint-discovery
Dec 13, 2023
Merged

Improve inline breakpoint discovery when expression is multiline. Fix #521#522
testforstephen merged 3 commits into
microsoft:mainfrom
gayanper:multi-line-breakpoint-discovery

Conversation

gayanper commented Dec 2, 2023
edited by testforstephen
Loading

Copy link
Copy Markdown
Contributor

When checking for lambda expression visible in same line, instead of matching the lambda line to current source line, this fix checks if the lambda is related to the current source line as part of a expression by traversing the parents unit we find the source line.

// the lambda doesn't belong to current line at all
break;
}
node = node.getParent();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Recursively checking the parent is not efficient, any way to return earlier?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Well do you see that we could run forever where theline < sourceLine will be never reached ? Otherwise i think in most cases we will end from the first iteration where line == sourceLine right ? Only in a multiline scenario we will traverse to see if the lambda we found belongs to the same line we add a breakpoint. And I also assume this logic will be executed only for breakpoints that are installed on the source line isn't it ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

I think we could follow Eclipse’s behavior for breakpoint support on the multiline expression, which allows setting a normal line breakpoint on it directly. This is simpler than the current approach.

I found that we only need a small change on the constructor of BreakpointLocationLocator. We can use the constructor public ValidBreakpointLocationLocator(CompilationUnit compilationUnit, int lineNumber, boolean bindingsResolved, boolean bestMatch, int offset, int end) to initialize the breakpoint validator. This can recognize the multiline lambda on the selected line.

BreakpointLocationLocator locator = new BreakpointLocationLocator(astUnit,
sourceLine, true, true);

// passing the offset to the constructor, it can recognize the multline lambda expression well BreakpointLocationLocator locator = new BreakpointLocationLocator(astUnit, sourceLine, true, true, astUnit.getPosition(sourceLine, 0), 0);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

Updated the fix

gayanper force-pushed the multi-line-breakpoint-discovery branch 2 times, most recently from c4dfc7d to f50b519 Compare December 5, 2023 22:05
gayanper force-pushed the multi-line-breakpoint-discovery branch from f50b519 to d8845eb Compare December 5, 2023 22:08
gayanper force-pushed the multi-line-breakpoint-discovery branch from 191b7a5 to 9337cea Compare December 12, 2023 21:14

testforstephen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

LGTM, thanks for contribution.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Critical] Cannot debug multiline nested method expression's lambda statements Breakpoint with inline lambdas work only with last one

2 participants

Footer

© 2026 GitHub, Inc.