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 ;
@@ -210,8 +210,11 @@ public JavaBreakpointLocation[] getBreakpointLocations(String sourceUri, SourceB
210210 // mark it as "unverified".
211211 // In future, we could consider supporting to update the breakpoint to a valid
212212 // location.
213+
214+ // passing the offset to the constructor, it can recognize the multiline lambda
215+ // expression well
213216 BreakpointLocationLocator locator = new BreakpointLocationLocator (astUnit ,
214- sourceLine , true , true );
217+ sourceLine , true , true , astUnit . getPosition ( sourceLine , 0 ), 0 );
215218 astUnit .accept (locator );
216219 // When the final valid line location is same as the original line, that
217220 // represents it's a valid breakpoint.
@@ -243,12 +246,13 @@ private BreakpointLocation[] getInlineBreakpointLocations(final CompilationUnit
243246 // The starting position of each line is the default breakpoint location for
244247 // that line.
245248 locations .add (new BreakpointLocation (sourceLine , 0 ));
249+
246250 astUnit .accept (new ASTVisitor () {
247251 @ Override
248252 public boolean visit (LambdaExpression node ) {
249253 int lambdaStart = node .getStartPosition ();
250254 int startLine = astUnit .getLineNumber (lambdaStart );
251- if (findNearestRelatedLineToLambda ( node ) == sourceLine ) {
255+ if (startLine == sourceLine ) {
252256 int startColumn = astUnit .getColumnNumber (lambdaStart );
253257 int lambdaEnd = lambdaStart + node .getLength ();
254258 int endLine = astUnit .getLineNumber (lambdaEnd );
@@ -258,21 +262,6 @@ public boolean visit(LambdaExpression node) {
258262 }
259263 return super .visit (node );
260264 }
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- }
276265 });
277266
278267 return locations .toArray (BreakpointLocation []::new );
0 commit comments