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

Setting a breakpoint inside a lamda that contains an object fails #518

Open
laeubi opened this issue Sep 27, 2024 · 4 comments · May be fixed by #523
Open

Setting a breakpoint inside a lamda that contains an object fails #518

laeubi opened this issue Sep 27, 2024 · 4 comments · May be fixed by #523
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@laeubi
Copy link
Contributor

laeubi commented Sep 27, 2024

Assume the following code

package example;

import java.util.Optional;
import java.util.function.Consumer;

import org.eclipse.core.databinding.observable.sideeffect.ISideEffectFactory;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.databinding.swt.WidgetSideEffects;
import org.eclipse.swt.widgets.Composite;

public class NoBreakPoint {

	private Context context = new Context();

	public NoBreakPoint(Composite parent) {
		ISideEffectFactory factory = WidgetSideEffects.createFactory(parent);
		factory.create(context::getSample, sample -> new Consumer<Optional<String>>() {

			Optional<String> lastSample = Optional.empty();

			@Override
			public void accept(Optional<String> currentSample) {

				lastSample.ifPresent(System.out::println);
				currentSample.ifPresent(System.out::println);
				lastSample = currentSample;
			}
		});
	}

	private static final class Context {
		public Optional<String> getSample() {
			return Optional.of("An example"); //$NON-NLS-1$
		}
	}

	public void dummy1() {
		new Action() {

			@Override
			public void run() {
				super.run();
			}
		};
	}

}
  • Now try to set a breakpoint in line 24 (lastSample.ifPresent(System.out::println);), it seems noting happens, but the Breakpoint view shows a breakpoint without a line number (in my real world code I get sett a breakpoint far away from the line i double clicked).
  • Now double click on that one in the breakpoint view --> nothing happens.
  • Now do the same on line 42 (super.run();)
  • Everything works

Here is a video:

Peek.2024-09-27.09-35.mp4
Eclipse SDK

Version: 2024-12 (4.34)
Build id: I20240921-1800
@jukzi jukzi added bug Something isn't working good first issue Good for newcomers labels Sep 27, 2024
@nettozahler
Copy link

Question: what is the best way to set up a proper example project having org.eclipse.core.*, org.eclipse.jface.*and org.eclipse.swt.* as dependencies so the above code compiles? Add some Eclipse projects to the classpath?

Anyhow - I did some mocking to make it compile and could reproduce it. I get the following error in the log:

org.eclipse.jface.text.BadLocationException: -1
	at org.eclipse.jface.text.TreeLineTracker.getLineInformation(TreeLineTracker.java:1153)
	at org.eclipse.jface.text.AbstractLineTracker.getLineInformation(AbstractLineTracker.java:228)
	at org.eclipse.jface.text.AbstractDocument.getLineInformation(AbstractDocument.java:873)
	at org.eclipse.core.internal.filebuffers.SynchronizableDocument.getLineInformation(SynchronizableDocument.java:290)
	at org.eclipse.jdt.internal.debug.ui.actions.ToggleBreakpointAdapter.doLineBreakpointToggle(ToggleBreakpointAdapter.java:529)
	at org.eclipse.jdt.internal.debug.ui.actions.ToggleBreakpointAdapter$1.run(ToggleBreakpointAdapter.java:213)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

@laeubi
Copy link
Contributor Author

laeubi commented Sep 30, 2024

I extracted it from a real use-case, but usually a recent Eclipse as target platform should be enough, probably only the structure needs to be preserved, for example Action --> Runnable, Composite -> Object and so on...

@noopur2507 noopur2507 transferred this issue from eclipse-jdt/eclipse.jdt.ui Sep 30, 2024
@jukzi
Copy link
Contributor

jukzi commented Sep 30, 2024

@nettozahler do you plan to work on this?

@nettozahler
Copy link

Well, I will do some debugging on this issue with reduced priority for me and see how far I can get. Maybe my Eclipse knowledge in jdt.debug is insufficient to find a solution in limited time. So I would not complain if anybody else is faster in finding a bufix :-)

nettozahler pushed a commit to nettozahler/eclipse.jdt.debug that referenced this issue Oct 1, 2024
nettozahler added a commit to nettozahler/eclipse.jdt.debug that referenced this issue Oct 1, 2024
nettozahler added a commit to nettozahler/eclipse.jdt.debug that referenced this issue Oct 1, 2024
nettozahler added a commit to nettozahler/eclipse.jdt.debug that referenced this issue Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants