Skip to content
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
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2015 IBM Corporation and others.
* Copyright (c) 2005, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -225,7 +225,7 @@ public Location getBreakpointLocation() {
if (considerTargetBreakpoints()) {
Target targetExecuting = getTargetExecuting();
if (targetExecuting != null) {
return getLocation(targetExecuting);
return targetExecuting.getLocation();
}
}
return null;
Expand Down Expand Up @@ -320,77 +320,15 @@ public void targetStarted(BuildEvent event) {
setConsiderTargetBreakpoints(true);
}

public int getLineNumber(Location location) {
try { // succeeds with Ant newer than 1.6
return location.getLineNumber();
}
catch (NoSuchMethodError e) {
// Ant before 1.6
String locationString = location.toString();
if (locationString.length() == 0) {
return 0;
}
// filename: lineNumber: ("c:\buildfile.xml: 12: ")
int lastIndex = locationString.lastIndexOf(':');
int index = locationString.lastIndexOf(':', lastIndex - 1);
if (index != -1) {
try {
return Integer.parseInt(locationString.substring(index + 1, lastIndex));
}
catch (NumberFormatException nfe) {
return 0;
}
}
return 0;
}
}

public static Location getLocation(Target target) {
try {// succeeds with Ant newer than 1.6.2
return target.getLocation();
}
catch (NoSuchMethodError e) {
return Location.UNKNOWN_LOCATION;
}
}

public String getFileName(Location location) {
try {// succeeds with Ant newer than 1.6
return location.getFileName();
}
catch (NoSuchMethodError e) {
// Ant before 1.6
String locationString = location.toString();
if (locationString.length() == 0) {
return null;
}
// filename: lineNumber: ("c:\buildfile.xml: 12: ")
int lastIndex = locationString.lastIndexOf(':');
int index = locationString.lastIndexOf(':', lastIndex - 1);
if (index == -1) {
index = lastIndex; // only the filename is known
}
if (index != -1) {
// bug 84403
// if (locationString.startsWith("file:")) {
// return FileUtils.newFileUtils().fromURI(locationString);
// }
// remove file:
return locationString.substring(5, index);
}
return null;
}
}

private void appendToStack(StringBuffer stackRepresentation, String targetName, String taskName, Location location) {
stackRepresentation.append(targetName);
stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
stackRepresentation.append(taskName);
stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);

stackRepresentation.append(getFileName(location));
stackRepresentation.append(location.getFileName());
stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
stackRepresentation.append(getLineNumber(location));
stackRepresentation.append(location.getLineNumber());
stackRepresentation.append(DebugMessageIds.MESSAGE_DELIMITER);
}

Expand All @@ -412,7 +350,7 @@ public void marshalStack(StringBuffer stackRepresentation) {
}

if (!isAfterTaskEvent()) {
appendToStack(stackRepresentation, targetExecuting.getName(), IAntCoreConstants.EMPTY_STRING, getLocation(targetExecuting));
appendToStack(stackRepresentation, targetExecuting.getName(), IAntCoreConstants.EMPTY_STRING, targetExecuting.getLocation());
}
for (int i = tasks.size() - 1; i >= 0; i--) {
Task task = tasks.get(i);
Expand Down Expand Up @@ -450,7 +388,7 @@ private void marshalTargetDependancyStack(StringBuffer stackRepresentation, Targ
for (int i = startIndex; i <= dependancyStackDepth; i++) {
stackTarget = buildSequence.get(i);
if (stackTarget.dependsOn(targetExecuting.getName())) {
appendToStack(stackRepresentation, stackTarget.getName(), IAntCoreConstants.EMPTY_STRING, getLocation(stackTarget));
appendToStack(stackRepresentation, stackTarget.getName(), IAntCoreConstants.EMPTY_STRING, stackTarget.getLocation());
}
}
}
Expand Down
Binary file modified ant/org.eclipse.ant.launching/lib/antdebug.jar
Binary file not shown.
Binary file modified ant/org.eclipse.ant.launching/lib/remote.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.eclipse.ant.internal.launching.AntLaunch;
import org.eclipse.ant.internal.launching.AntLaunching;
import org.eclipse.ant.internal.launching.AntLaunchingUtil;
import org.eclipse.ant.internal.launching.debug.AntDebugState;
import org.eclipse.ant.internal.launching.launchConfigurations.AntProcess;
import org.eclipse.ant.internal.launching.launchConfigurations.AntStreamMonitor;
import org.eclipse.ant.internal.launching.launchConfigurations.AntStreamsProxy;
Expand Down Expand Up @@ -287,7 +286,7 @@ public void targetStarted(BuildEvent event) {
msg.append(targetName);
msg.append(':');
String message = msg.toString();
Location location = AntDebugState.getLocation(target);
Location location = target.getLocation();
if (location != null && location != Location.UNKNOWN_LOCATION) {
IRegion region = new Region(0, targetName.length());
AntProcess antProcess = getAntProcess(fProcessId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2016 IBM Corporation and others.
* Copyright (c) 2004, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -219,8 +219,8 @@ private IBreakpoint breakpointAtLineNumber(Location location) {
if (fBreakpoints == null || location == null || location == Location.UNKNOWN_LOCATION) {
return null;
}
int lineNumber = fDebugState.getLineNumber(location);
File locationFile = new File(fDebugState.getFileName(location));
int lineNumber = location.getLineNumber();
File locationFile = new File(location.getFileName());
for (IBreakpoint bp : fBreakpoints) {
ILineBreakpoint breakpoint = (ILineBreakpoint) bp;
int breakpointLineNumber;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2016 IBM Corporation and others.
* Copyright (c) 2003, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -30,7 +30,6 @@
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Target;
import org.apache.tools.ant.util.StringUtils;
import org.eclipse.ant.internal.launching.debug.AntDebugState;
import org.eclipse.ant.internal.launching.remote.AntSecurityException;
import org.eclipse.ant.internal.launching.remote.IAntCoreConstants;
import org.eclipse.ant.internal.launching.remote.InternalAntRunner;
Expand Down Expand Up @@ -358,7 +357,7 @@ private void marshalTaskMessage(BuildEvent event) throws IOException {

private void marshalTargetMessage(BuildEvent event) {
Target target = event.getTarget();
Location location = AntDebugState.getLocation(target);
Location location = target.getLocation();

StringBuilder message = new StringBuilder();
message.append(MessageIds.TARGET);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2003, 2016 IBM Corporation and others.
* Copyright (c) 2003, 2025 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -302,8 +302,8 @@ private RemoteAntBreakpoint breakpointAtLineNumber(Location location) {
if (fBreakpoints == null || location == null || location == Location.UNKNOWN_LOCATION) {
return null;
}
String fileName = fDebugState.getFileName(location);
int lineNumber = fDebugState.getLineNumber(location);
String fileName = location.getFileName();
int lineNumber = location.getLineNumber();
for (RemoteAntBreakpoint breakpoint : fBreakpoints) {
if (breakpoint.isAt(fileName, lineNumber)) {
return breakpoint;
Expand Down
Loading