1
1
/*******************************************************************************
2
- * Copyright (c) 2005, 2015 IBM Corporation and others.
2
+ * Copyright (c) 2005, 2025 IBM Corporation and others.
3
3
*
4
4
* This program and the accompanying materials
5
5
* are made available under the terms of the Eclipse Public License 2.0
@@ -225,7 +225,7 @@ public Location getBreakpointLocation() {
225
225
if (considerTargetBreakpoints ()) {
226
226
Target targetExecuting = getTargetExecuting ();
227
227
if (targetExecuting != null ) {
228
- return getLocation (targetExecuting );
228
+ return targetExecuting . getLocation ();
229
229
}
230
230
}
231
231
return null ;
@@ -320,77 +320,15 @@ public void targetStarted(BuildEvent event) {
320
320
setConsiderTargetBreakpoints (true );
321
321
}
322
322
323
- public int getLineNumber (Location location ) {
324
- try { // succeeds with Ant newer than 1.6
325
- return location .getLineNumber ();
326
- }
327
- catch (NoSuchMethodError e ) {
328
- // Ant before 1.6
329
- String locationString = location .toString ();
330
- if (locationString .length () == 0 ) {
331
- return 0 ;
332
- }
333
- // filename: lineNumber: ("c:\buildfile.xml: 12: ")
334
- int lastIndex = locationString .lastIndexOf (':' );
335
- int index = locationString .lastIndexOf (':' , lastIndex - 1 );
336
- if (index != -1 ) {
337
- try {
338
- return Integer .parseInt (locationString .substring (index + 1 , lastIndex ));
339
- }
340
- catch (NumberFormatException nfe ) {
341
- return 0 ;
342
- }
343
- }
344
- return 0 ;
345
- }
346
- }
347
-
348
- public static Location getLocation (Target target ) {
349
- try {// succeeds with Ant newer than 1.6.2
350
- return target .getLocation ();
351
- }
352
- catch (NoSuchMethodError e ) {
353
- return Location .UNKNOWN_LOCATION ;
354
- }
355
- }
356
-
357
- public String getFileName (Location location ) {
358
- try {// succeeds with Ant newer than 1.6
359
- return location .getFileName ();
360
- }
361
- catch (NoSuchMethodError e ) {
362
- // Ant before 1.6
363
- String locationString = location .toString ();
364
- if (locationString .length () == 0 ) {
365
- return null ;
366
- }
367
- // filename: lineNumber: ("c:\buildfile.xml: 12: ")
368
- int lastIndex = locationString .lastIndexOf (':' );
369
- int index = locationString .lastIndexOf (':' , lastIndex - 1 );
370
- if (index == -1 ) {
371
- index = lastIndex ; // only the filename is known
372
- }
373
- if (index != -1 ) {
374
- // bug 84403
375
- // if (locationString.startsWith("file:")) {
376
- // return FileUtils.newFileUtils().fromURI(locationString);
377
- // }
378
- // remove file:
379
- return locationString .substring (5 , index );
380
- }
381
- return null ;
382
- }
383
- }
384
-
385
323
private void appendToStack (StringBuffer stackRepresentation , String targetName , String taskName , Location location ) {
386
324
stackRepresentation .append (targetName );
387
325
stackRepresentation .append (DebugMessageIds .MESSAGE_DELIMITER );
388
326
stackRepresentation .append (taskName );
389
327
stackRepresentation .append (DebugMessageIds .MESSAGE_DELIMITER );
390
328
391
- stackRepresentation .append (getFileName (location ));
329
+ stackRepresentation .append (location . getFileName ());
392
330
stackRepresentation .append (DebugMessageIds .MESSAGE_DELIMITER );
393
- stackRepresentation .append (getLineNumber (location ));
331
+ stackRepresentation .append (location . getLineNumber ());
394
332
stackRepresentation .append (DebugMessageIds .MESSAGE_DELIMITER );
395
333
}
396
334
@@ -412,7 +350,7 @@ public void marshalStack(StringBuffer stackRepresentation) {
412
350
}
413
351
414
352
if (!isAfterTaskEvent ()) {
415
- appendToStack (stackRepresentation , targetExecuting .getName (), IAntCoreConstants .EMPTY_STRING , getLocation (targetExecuting ));
353
+ appendToStack (stackRepresentation , targetExecuting .getName (), IAntCoreConstants .EMPTY_STRING , targetExecuting . getLocation ());
416
354
}
417
355
for (int i = tasks .size () - 1 ; i >= 0 ; i --) {
418
356
Task task = tasks .get (i );
@@ -450,7 +388,7 @@ private void marshalTargetDependancyStack(StringBuffer stackRepresentation, Targ
450
388
for (int i = startIndex ; i <= dependancyStackDepth ; i ++) {
451
389
stackTarget = buildSequence .get (i );
452
390
if (stackTarget .dependsOn (targetExecuting .getName ())) {
453
- appendToStack (stackRepresentation , stackTarget .getName (), IAntCoreConstants .EMPTY_STRING , getLocation (stackTarget ));
391
+ appendToStack (stackRepresentation , stackTarget .getName (), IAntCoreConstants .EMPTY_STRING , stackTarget . getLocation ());
454
392
}
455
393
}
456
394
}
0 commit comments