Skip to content

Commit

Permalink
Fix the step-into target on multi line expression. Fix #519
Browse files Browse the repository at this point in the history
  • Loading branch information
gayanper committed Dec 13, 2023
1 parent 9bdd997 commit 9b60b13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ private void handleDebugEvent(DebugEvent debugEvent, IDebugSession debugSession,
} else if (currentStackDepth == threadState.stackDepth) {
// If the ending step location is same as the original location where the step into operation is originated,
// do another step of the same kind.
if (isSameLocation(currentStepLocation, threadState.stepLocation)) {
if (isSameLocation(currentStepLocation, threadState.stepLocation,
threadState.targetStepIn)) {
context.getStepResultManager().removeMethodResult(threadId);
threadState.pendingStepRequest = DebugUtility.createStepIntoRequest(thread,
context.getStepFilters().allowClasses,
Expand Down Expand Up @@ -438,15 +439,19 @@ private boolean shouldDoExtraStepInto(int originalStackDepth, Location originalL
return true;
}

private boolean isSameLocation(Location original, Location current) {
private boolean isSameLocation(Location original, Location current, MethodInvocation targetStepIn) {
if (original == null || current == null) {
return false;
}

Method originalMethod = original.method();
Method currentMethod = current.method();
// if the lines doesn't match, check if the current line is still behind the
// target if a target exist. This handles where the target is part of a
// expression which is wrapped.
return originalMethod.equals(currentMethod)
&& original.lineNumber() == current.lineNumber();
&& (original.lineNumber() == current.lineNumber()
|| (targetStepIn != null && targetStepIn.lineStart > current.lineNumber()));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public boolean visit(MethodDeclaration node) {

@Override
public boolean visit(TypeDeclaration node) {
return shouldVisitNode(node);
return unit.getRoot() == node.getRoot() || shouldVisitNode(node);
}

@Override
Expand Down

0 comments on commit 9b60b13

Please sign in to comment.