Skip to content

Commit 431de23

Browse files
Fix the step-into target on multi line expression. Fix #519 (#520)
* Fix the step-into target on multi line expression. Fix #519 --------- Co-authored-by: Jinbo Wang <[email protected]>
1 parent b578b50 commit 431de23

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/StepRequestHandler.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ private void handleDebugEvent(DebugEvent debugEvent, IDebugSession debugSession,
268268
} else if (currentStackDepth == threadState.stackDepth) {
269269
// If the ending step location is same as the original location where the step into operation is originated,
270270
// do another step of the same kind.
271-
if (isSameLocation(currentStepLocation, threadState.stepLocation)) {
271+
if (isSameLocation(currentStepLocation, threadState.stepLocation,
272+
threadState.targetStepIn)) {
272273
context.getStepResultManager().removeMethodResult(threadId);
273274
threadState.pendingStepRequest = DebugUtility.createStepIntoRequest(thread,
274275
context.getStepFilters().allowClasses,
@@ -438,15 +439,19 @@ private boolean shouldDoExtraStepInto(int originalStackDepth, Location originalL
438439
return true;
439440
}
440441

441-
private boolean isSameLocation(Location original, Location current) {
442+
private boolean isSameLocation(Location current, Location original, MethodInvocation targetStepIn) {
442443
if (original == null || current == null) {
443444
return false;
444445
}
445446

446447
Method originalMethod = original.method();
447448
Method currentMethod = current.method();
449+
// if the lines doesn't match, check if the current line is still behind the
450+
// target if a target exist. This handles where the target is part of a
451+
// expression which is wrapped.
448452
return originalMethod.equals(currentMethod)
449-
&& original.lineNumber() == current.lineNumber();
453+
&& (original.lineNumber() == current.lineNumber()
454+
|| (targetStepIn != null && targetStepIn.lineEnd >= current.lineNumber()));
450455
}
451456

452457
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public boolean visit(ClassInstanceCreation node) {
217217

218218
private boolean shouldVisitNode(ASTNode node) {
219219
int start = unit.getLineNumber(node.getStartPosition());
220-
int end = unit.getLineNumber(node.getStartPosition() + node.getLength());
220+
int end = unit.getLineNumber(node.getStartPosition() + node.getLength() - 1);
221221

222222
if (line >= start && line <= end) {
223223
return true;

0 commit comments

Comments
 (0)