Bug 32267 - Target location is not set for default target
Summary: Target location is not set for default target
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.6.2
Hardware: PC Linux
: P1 trivial (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2004-11-17 10:43 UTC by Yves Martin
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yves Martin 2004-11-17 10:43:33 UTC
When creating my own task, I tried to get Target.getLocation information but it
is never set. May you please include the following patch to set Target location
when parsing the build file with ProjectHelper2. Thank you in advance. 

 *** ProjectHelper2.java.org     2004-07-16 09:57:32.000000000 +0200
--- ProjectHelper2.java 2004-11-17 10:20:42.139829000 +0100
***************
*** 121,126 ****
--- 121,133 ----
                  newCurrent.setProject(project);
                  newCurrent.setName("");
                  context.setCurrentTarget(newCurrent);
+                 if (context.getLocator() != null) {
+                     Location location =
+                         new Location(context.getLocator().getSystemId(),
+                                      context.getLocator().getLineNumber(),
+                                      context.getLocator().getColumnNumber());
+                     newCurrent.setLocation(location);
+                 }
                  parse(project, source, new RootHandler(context, mainHandler));
                  newCurrent.execute();
              } finally {
***************
*** 758,763 ****
--- 765,777 ----
              Target target = new Target();
              target.setProject(project);
              context.addTarget(target);
+             if (context.getLocator() != null) {
+                 Location location =
+                     new Location(context.getLocator().getSystemId(),
+                                  context.getLocator().getLineNumber(),
+                                  context.getLocator().getColumnNumber());
+                 target.setLocation(location);
+             }
   
              for (int i = 0; i < attrs.getLength(); i++) {
                  String attrUri = attrs.getURI(i);
Comment 1 Peter Reilly 2004-11-17 11:16:18 UTC
The second part of the patch (target location) is already in
CVS.

The first part (default target for imported files) will not work as 
the context locator is not yet set correctly (id is null and line
number is -1).

- One also needs to do default target for main file (in this case
the context locator is null).

Changing the title to reflect the sub bug.
Comment 2 Peter Reilly 2004-11-18 10:51:01 UTC
Ok, I have committed a change to set the location for the default target.
Now, why do you need the location of the target?. You should have the
location of the task that is creating your task.