Bug 330041 - AJCodeElement should initialize source location upon construction
Summary: AJCodeElement should initialize source location upon construction
Status: RESOLVED FIXED
Alias: None
Product: AJDT
Classification: Tools
Component: Core (show other bugs)
Version: 2.1.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 2.1.2   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-11 15:42 EST by Raffi Khatchadourian CLA
Modified: 2010-11-23 16:31 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Raffi Khatchadourian CLA 2010-11-11 15:42:14 EST
Build Identifier: 20100917-0705

Objects of class org.eclipse.ajdt.core.javaelements.AJCodeElement only seem to set their source location when the org.eclipse.ajdt.core.javaelements.AJCodeElement.getNameRange() method is called. However, this fields should be set when the object is constructed.

Reproducible: Always
Comment 1 Andrew Eisenberg CLA 2010-11-18 14:57:55 EST
Is there any particular reason why you need this?  Unless there is a compelling reason, it's better that source locations are computed lazily.
Comment 2 Raffi Khatchadourian CLA 2010-11-18 15:07:18 EST
Computing them lazily would be fine but I don't think that the API is intuitive. There should be a separate void function that computes the locations and the get function should just retrieve them. That way, if there are other methods than access those fields, they will be populated.
Comment 3 Andrew Eisenberg CLA 2010-11-18 16:25:49 EST
Would it be sufficient if I made initializeLocations() public?

Can you be a little bit more specific on how you are using this and what problem you are facing?
Comment 4 Raffi Khatchadourian CLA 2010-11-19 11:55:38 EST
Hi Andrew,

Yes, I think that making initializeLocations() public would suffice. I am using this to make "virtual" join point shadows, i.e., join points that are not advised by any advice. Thus, I create instances of these classes manually. However, when a user double clicks on them, Eclipse just brings them to the top of the file they are located in instead of going to the exact location in the source code. I think this happens because the getNameRange() method is not being called somewhere in Eclipse (since it is specific to this type) and the source location is being retrieved some other way. In this case, the source location fields are empty. Thanks, and let me know if you have any other questions.

Raffi

(In reply to comment #3)
> Would it be sufficient if I made initializeLocations() public?
> 
> Can you be a little bit more specific on how you are using this and what
> problem you are facing?
Comment 5 Andrew Eisenberg CLA 2010-11-23 16:25:28 EST
Made that method public.  This will be out in the next dev build of AJDT (tomorrow most likely).  Feel free to reopen if this does not successfully solve your problem.