Skip to content

Commit 191b7a5

Browse files
committed
update the fix according to suggestion
1 parent d8845eb commit 191b7a5

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/BreakpointLocationLocator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public class BreakpointLocationLocator
2222

2323
public BreakpointLocationLocator(CompilationUnit compilationUnit, int lineNumber,
2424
boolean bindingsResolved,
25-
boolean bestMatch) {
26-
super(compilationUnit, lineNumber, bindingsResolved, bestMatch);
25+
boolean bestMatch, int offset, int end) {
26+
super(compilationUnit, lineNumber, bindingsResolved, bestMatch, offset, end);
2727
}
2828

2929
@Override

com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/JdtSourceLookUpProvider.java

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
import com.microsoft.java.debug.core.Configuration;
7373
import com.microsoft.java.debug.core.DebugException;
7474
import com.microsoft.java.debug.core.DebugSettings;
75-
import com.microsoft.java.debug.core.JavaBreakpointLocation;
7675
import com.microsoft.java.debug.core.DebugSettings.Switch;
76+
import com.microsoft.java.debug.core.JavaBreakpointLocation;
7777
import com.microsoft.java.debug.core.adapter.AdapterUtils;
7878
import com.microsoft.java.debug.core.adapter.Constants;
7979
import 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);

com.microsoft.java.debug.target/com.microsoft.java.debug.tp.target

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<unit id="org.eclipse.jdt.source.feature.group" version="0.0.0"/>
1818
<unit id="org.eclipse.sdk.feature.group" version="0.0.0"/>
1919
<unit id="org.eclipse.xtext.sdk.feature.group" version="0.0.0"/>
20-
<repository location="https://download.eclipse.org/releases/2023-12/202311171000/"/>
20+
<repository location="https://download.eclipse.org/releases/2023-12/"/>
2121
</location>
2222
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
2323
<unit id="org.jboss.tools.maven.apt.core" version="0.0.0"/>

0 commit comments

Comments
 (0)