Community
Participate
Working Groups
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
Is there any particular reason why you need this? Unless there is a compelling reason, it's better that source locations are computed lazily.
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.
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?
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?
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.