Skip to content

Commit 9337cea

Browse files
committed
update the fix according to suggestion
1 parent d8845eb commit 9337cea

3 files changed

Lines changed: 9 additions & 21 deletions

File tree

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: 6 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.
@@ -248,7 +251,7 @@ private BreakpointLocation[] getInlineBreakpointLocations(final CompilationUnit
248251
public boolean visit(LambdaExpression node) {
249252
int lambdaStart = node.getStartPosition();
250253
int startLine = astUnit.getLineNumber(lambdaStart);
251-
if (findNearestRelatedLineToLambda(node) == sourceLine) {
254+
if (startLine == sourceLine) {
252255
int startColumn = astUnit.getColumnNumber(lambdaStart);
253256
int lambdaEnd = lambdaStart + node.getLength();
254257
int endLine = astUnit.getLineNumber(lambdaEnd);
@@ -258,21 +261,6 @@ public boolean visit(LambdaExpression node) {
258261
}
259262
return super.visit(node);
260263
}
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-
}
276264
});
277265

278266
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)