Skip to content

Commit

Permalink
update the fix according to suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
gayanper committed Dec 12, 2023
1 parent d8845eb commit 9337cea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class BreakpointLocationLocator

public BreakpointLocationLocator(CompilationUnit compilationUnit, int lineNumber,
boolean bindingsResolved,
boolean bestMatch) {
super(compilationUnit, lineNumber, bindingsResolved, bestMatch);
boolean bestMatch, int offset, int end) {
super(compilationUnit, lineNumber, bindingsResolved, bestMatch, offset, end);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
import com.microsoft.java.debug.core.Configuration;
import com.microsoft.java.debug.core.DebugException;
import com.microsoft.java.debug.core.DebugSettings;
import com.microsoft.java.debug.core.JavaBreakpointLocation;
import com.microsoft.java.debug.core.DebugSettings.Switch;
import com.microsoft.java.debug.core.JavaBreakpointLocation;
import com.microsoft.java.debug.core.adapter.AdapterUtils;
import com.microsoft.java.debug.core.adapter.Constants;
import com.microsoft.java.debug.core.adapter.IDebugAdapterContext;
Expand Down Expand Up @@ -210,8 +210,11 @@ public JavaBreakpointLocation[] getBreakpointLocations(String sourceUri, SourceB
// mark it as "unverified".
// In future, we could consider supporting to update the breakpoint to a valid
// location.

// passing the offset to the constructor, it can recognize the multiline lambda
// expression well
BreakpointLocationLocator locator = new BreakpointLocationLocator(astUnit,
sourceLine, true, true);
sourceLine, true, true, astUnit.getPosition(sourceLine, 0), 0);
astUnit.accept(locator);
// When the final valid line location is same as the original line, that
// represents it's a valid breakpoint.
Expand Down Expand Up @@ -248,7 +251,7 @@ private BreakpointLocation[] getInlineBreakpointLocations(final CompilationUnit
public boolean visit(LambdaExpression node) {
int lambdaStart = node.getStartPosition();
int startLine = astUnit.getLineNumber(lambdaStart);
if (findNearestRelatedLineToLambda(node) == sourceLine) {
if (startLine == sourceLine) {
int startColumn = astUnit.getColumnNumber(lambdaStart);
int lambdaEnd = lambdaStart + node.getLength();
int endLine = astUnit.getLineNumber(lambdaEnd);
Expand All @@ -258,21 +261,6 @@ public boolean visit(LambdaExpression node) {
}
return super.visit(node);
}

private int findNearestRelatedLineToLambda(LambdaExpression lambda) {
ASTNode node = lambda;
while (node != null) {
int line = astUnit.getLineNumber(node.getStartPosition());
if(line == sourceLine) {
return line;
} else if (line < sourceLine) {
// the lambda doesn't belong to current line at all
break;
}
node = node.getParent();
}
return -1;
}
});

return locations.toArray(BreakpointLocation[]::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<unit id="org.eclipse.jdt.source.feature.group" version="0.0.0"/>
<unit id="org.eclipse.sdk.feature.group" version="0.0.0"/>
<unit id="org.eclipse.xtext.sdk.feature.group" version="0.0.0"/>
<repository location="https://download.eclipse.org/releases/2023-12/202311171000/"/>
<repository location="https://download.eclipse.org/releases/2023-12/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.jboss.tools.maven.apt.core" version="0.0.0"/>
Expand Down

0 comments on commit 9337cea

Please sign in to comment.