Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Getting source code positions for advice

If doing a full compile you can specify the option -emacssym and it
will be created inside the World object and accessible through
world.getModel().  If binary weaving (loadtime weaving), probably not,
as the compiler creates a lot of the up front pieces of the structure
- I'm not sure how you are operating the weaver in order to access the
internals.

You could look at the AJDT wiki article that talks about using the
parser standalone:

http://wiki.eclipse.org/Developer%27s_guide_to_building_tools_on_top_of_AJDT_and_AspectJ

(obviously an ast for the file would give you accurate positions).

Or you could access the bytecode and look at the line number table for
the advice method, the last entry will give you an indication of where
the last bit of code is in the advice.

cheers
Andy

On 20 June 2011 11:42, Yoav A. <yoav_@xxxxxxxxxxx> wrote:
> is there some way to access this structure model from the weaver code?
>
>
> -----Original Message----- From: Andy Clement
> Sent: Monday, June 20, 2011 9:41 PM
> To: AspectJ developer discussions
> Subject: Re: [aspectj-dev] Getting source code positions for advice
>
> Hi,
>
> I doubt you are doing anything wrong.  We just never use the endline
> (from BcelAdvice) for anything (as I recall) and so don't really
> guarantee it is correct.  The structure model produced alongside the
> compile is more likely to have correct information in it, as that is
> used by AJDT.  Feel free to raise a bugzilla to sort out the
> BcelAdvice end line if you like.
>
> cheers
> Andy
>
> On 20 June 2011 11:25, Yoav A. <yoav_@xxxxxxxxxxx> wrote:
>>
>> I'm trying to extract source file information during the weaving process.
>> I
>> wrote the following code to fetch the beginning and end of an advice:
>>
>> public String getAdviceFormatString(BcelAdvice adv)
>> {
>>   ISourceLocation pos = adv.getSourceLocation(); int startLine =
>> pos.getLine();
>>   int endLine = pos.getEndLine(); // do the rest
>> }
>>
>>
>> I always get that startLine == endLine which correspond to the first line
>> of
>> the advice declaration. What am I doing wrong here?
>>
>>
>>
>> _______________________________________________
>> aspectj-dev mailing list
>> aspectj-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>>
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
>


Back to the top