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

Bugfix for #518 (Setting a breakpoint inside lambda with object). #523

Merged

Conversation

nettozahler
Copy link
Contributor

What it does

Fixes #518

How to test

Try to set a breakpoint inside a lambda expression with its body beginning with an anonymous class declaration.
See #518 as example. The new breakpoint should appear as usual and jumping to it from inside the "breakpoint view" must work.

Author checklist

@nettozahler nettozahler marked this pull request as draft October 1, 2024 13:43
@nettozahler
Copy link
Contributor Author

Maybe it would be good to extend the existing tests for this case.

@nettozahler
Copy link
Contributor Author

Review should consider this:
Lambda body can be a block or an (arbitrary) expression. So maybe the cases which are handled in the code are insufficient and should be replaced by handling the general org.eclipse.jdt.core.dom.Expression (see my similar comment in changed Java file).

@nettozahler nettozahler marked this pull request as ready for review October 2, 2024 12:34
@jukzi
Copy link
Contributor

jukzi commented Nov 7, 2024

please add a junit test. see /org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/breakpoints for related ones

@nettozahler
Copy link
Contributor Author

Hi, @jukzi, I would try to craft a PR with a JUnit test but first I need a hint to make my Eclipse SDK working again. My initial setup with OOMPH was fine and I used it for several months. Now I have updated the SDK with the "Perform setup tasks" feature. After this I now have zillions of compile errors in my SDK because all/many of the external dependencies like JSoup are missing. How can I restore/recreate all these dependencies to get rid of the compile errors? Thanks in advance.

@jukzi
Copy link
Contributor

jukzi commented Nov 14, 2024

When i have such problems it helps to 1. pull all repositories, 2. use the "edit" button of the eclipse-sdk target platform to update it. 3. reload the active target platform. 4. rebuild all projects. Don't know why such is not done automatically @merks

@merks
Copy link
Contributor

merks commented Nov 14, 2024

Help -> Perform Setup Tasks... should generally update everything after pulling all the git repositories. The *.target file should be resolved automatically by those steps, but for unknown reasons (in PDE) that doesn't always work. :-(

@nettozahler
Copy link
Contributor Author

Thanks for the quick response with valuable hints from experienced Eclipse developers. But they have produced some big question marks on my face. As you can see I need some more detailed info. Let's go through the steps.

  1. Pull all repos: "Perform Setup Tasks" does this and I can also do it manually. CHECK
  2. use the "edit" button of the eclipse-sdk target platform to update it: Where is this button located? Inside Eclipse? Never seen this before.
  3. reload the active target platform: How to do this?
  4. rebuild all projects: Have done this zillions of times before. CHECK

@jukzi
Copy link
Contributor

jukzi commented Nov 14, 2024

windows/preference:
image

@nettozahler
Copy link
Contributor Author

Thanks. This procedure helped me out and resolved my compile errors. :)

@nettozahler
Copy link
Contributor Author

Now I added a JUnit test.

@jukzi jukzi force-pushed the 518-breakpoint-inside-lambda-with-object branch from a309be9 to ccedd54 Compare November 27, 2024 06:40
@@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright (c) 2024 IBM Corporation and others.
Copy link
Contributor

Choose a reason for hiding this comment

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

typically use your employer here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is an employer but for Eclipse I work in my free time as private person.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then you can use your private name here

@@ -1066,10 +1066,16 @@ public boolean visit(LambdaExpression node) {

}
}

// Lambda body can be a block (which is handled above) or an (arbitrary) expression. So maybe the
// following cases are insufficient and should be replaced by handling the general
Copy link
Contributor

Choose a reason for hiding this comment

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

sounds odd to know what todo and not doing it ;-) could you instead of a comment suggest such an appropriate fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I am not 100% sure if the extended version of the fix would be OK. Maybe the gurus for Java grammar and AST can give a short advice here. @stephan-herrmann ? But what is clear according to my tests is that the fix "as is" solves the described bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, just handling the two specified alternatives Block and Expression sounds like the most consistent approach.

Seeing other visit methods freely invoking .accept(this) on general expressions, I see no reason why this should cause problems here, but I haven't studied class ValidBreakpointLocationLocator in more detail.

} else if (body instanceof LambdaExpression) {
body.accept(this);
} else if (body instanceof MethodInvocation) {
body.accept(this);
} else if (body instanceof ClassInstanceCreation) {
Copy link
Contributor

Choose a reason for hiding this comment

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

since the handling is the same may be use OR in the condition or even a general "instanceof Expression"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course I can implement a OR in the condition and adapt the PR accordingly.

@jukzi
Copy link
Contributor

jukzi commented Dec 10, 2024

@nettozahler ping can you get this PR done, please?

@nettozahler
Copy link
Contributor Author

OK, let's try to get it done... I will add some comments.

@nettozahler nettozahler force-pushed the 518-breakpoint-inside-lambda-with-object branch from ccedd54 to 7cebcbd Compare December 12, 2024 12:02
@nettozahler
Copy link
Contributor Author

Now let's try it with the revised PR.

@jukzi jukzi force-pushed the 518-breakpoint-inside-lambda-with-object branch from 7cebcbd to 5420f12 Compare December 16, 2024 14:13
@jukzi jukzi merged commit b08e5b1 into eclipse-jdt:master Dec 16, 2024
11 checks passed
@laeubi
Copy link
Contributor

laeubi commented Dec 16, 2024

@nettozahler many thanks for fixing this bug, such work is much more important in my opinion than all darkmode, icon, whatever style changes even though you sadly won't get that much attention for your change :-)

I can easily work with an "oldish" UI if it works and help me accomplish my tasks!

@jukzi
Copy link
Contributor

jukzi commented Dec 16, 2024

@nettozahler thanks for contributing

@jukzi jukzi added the bug Something isn't working label Dec 16, 2024
@nettozahler
Copy link
Contributor Author

As an Eclipse user for many years (since the days of VisualAge - if anybody remembers this) it feels right to "give something back". And the competition with other IDEs is hard so I think we need all contributions: the ones for a more fancy UI as well as those for even better functionality.

I would also like to say my thanks for your outstanding support especially in the performance and memory consumption areas.

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 this pull request may close these issues.

Setting a breakpoint inside a lamda that contains an object fails
5 participants