11/*******************************************************************************
2- * Copyright (c) 2005, 2015 IBM Corporation and others.
2+ * Copyright (c) 2005, 2025 IBM Corporation and others.
33 *
44 * This program and the accompanying materials
55 * are made available under the terms of the Eclipse Public License 2.0
@@ -225,7 +225,7 @@ public Location getBreakpointLocation() {
225225 if (considerTargetBreakpoints ()) {
226226 Target targetExecuting = getTargetExecuting ();
227227 if (targetExecuting != null ) {
228- return getLocation (targetExecuting );
228+ return targetExecuting . getLocation ();
229229 }
230230 }
231231 return null ;
@@ -320,77 +320,15 @@ public void targetStarted(BuildEvent event) {
320320 setConsiderTargetBreakpoints (true );
321321 }
322322
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-
385323 private void appendToStack (StringBuffer stackRepresentation , String targetName , String taskName , Location location ) {
386324 stackRepresentation .append (targetName );
387325 stackRepresentation .append (DebugMessageIds .MESSAGE_DELIMITER );
388326 stackRepresentation .append (taskName );
389327 stackRepresentation .append (DebugMessageIds .MESSAGE_DELIMITER );
390328
391- stackRepresentation .append (getFileName (location ));
329+ stackRepresentation .append (location . getFileName ());
392330 stackRepresentation .append (DebugMessageIds .MESSAGE_DELIMITER );
393- stackRepresentation .append (getLineNumber (location ));
331+ stackRepresentation .append (location . getLineNumber ());
394332 stackRepresentation .append (DebugMessageIds .MESSAGE_DELIMITER );
395333 }
396334
@@ -412,7 +350,7 @@ public void marshalStack(StringBuffer stackRepresentation) {
412350 }
413351
414352 if (!isAfterTaskEvent ()) {
415- appendToStack (stackRepresentation , targetExecuting .getName (), IAntCoreConstants .EMPTY_STRING , getLocation (targetExecuting ));
353+ appendToStack (stackRepresentation , targetExecuting .getName (), IAntCoreConstants .EMPTY_STRING , targetExecuting . getLocation ());
416354 }
417355 for (int i = tasks .size () - 1 ; i >= 0 ; i --) {
418356 Task task = tasks .get (i );
@@ -450,7 +388,7 @@ private void marshalTargetDependancyStack(StringBuffer stackRepresentation, Targ
450388 for (int i = startIndex ; i <= dependancyStackDepth ; i ++) {
451389 stackTarget = buildSequence .get (i );
452390 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 ());
454392 }
455393 }
456394 }
0 commit comments