Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the step-into target on multi line expression. Fix #519 #520

Merged
merged 4 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 current, Location original, 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.lineEnd >= current.lineNumber()));
}

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

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

if (line >= start && line <= end) {
return true;
Expand Down
Loading