7272import com .microsoft .java .debug .core .Configuration ;
7373import com .microsoft .java .debug .core .DebugException ;
7474import com .microsoft .java .debug .core .DebugSettings ;
75- import com .microsoft .java .debug .core .JavaBreakpointLocation ;
7675import com .microsoft .java .debug .core .DebugSettings .Switch ;
76+ import com .microsoft .java .debug .core .JavaBreakpointLocation ;
7777import com .microsoft .java .debug .core .adapter .AdapterUtils ;
7878import com .microsoft .java .debug .core .adapter .Constants ;
7979import com .microsoft .java .debug .core .adapter .IDebugAdapterContext ;
@@ -248,7 +248,7 @@ private BreakpointLocation[] getInlineBreakpointLocations(final CompilationUnit
248248 public boolean visit (LambdaExpression node ) {
249249 int lambdaStart = node .getStartPosition ();
250250 int startLine = astUnit .getLineNumber (lambdaStart );
251- if (startLine == sourceLine ) {
251+ if (findNearestRelatedLineToLambda ( node ) == sourceLine ) {
252252 int startColumn = astUnit .getColumnNumber (lambdaStart );
253253 int lambdaEnd = lambdaStart + node .getLength ();
254254 int endLine = astUnit .getLineNumber (lambdaEnd );
@@ -258,6 +258,21 @@ public boolean visit(LambdaExpression node) {
258258 }
259259 return super .visit (node );
260260 }
261+
262+ private int findNearestRelatedLineToLambda (LambdaExpression lambda ) {
263+ ASTNode node = lambda ;
264+ while (node != null ) {
265+ int line = astUnit .getLineNumber (node .getStartPosition ());
266+ if (line == sourceLine ) {
267+ return line ;
268+ } else if (line < sourceLine ) {
269+ // the lambda doesn't belong to current line at all
270+ break ;
271+ }
272+ node = node .getParent ();
273+ }
274+ return -1 ;
275+ }
261276 });
262277
263278 return locations .toArray (BreakpointLocation []::new );
0 commit comments