Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ajdt-dev] AJDT and ITDs

Although what you are trying to do sounds very reasonable, this is not
yet supported in AJDT.  The main reason why it doesn't work is that
the crosscutting model exposed to AJDT does not contain target
elements for crosscutting relationships when the target is binary (and
I don't know if it will contain the source elements either in your
situation).

In the short term, there is a work around, however.  If you can
perform the weaving of A & B in a separate project and have the source
project consume the woven jars, rather than try to weave them itself,
you should be working at least partially.  It may not be as clean as
you would like, but you should get proper content assist and
reconciling.

In the longer term, we are considering an  enhancement is something
that Andy has alluded to before.  This enhancement is to use
matching-without-weaving-capability in AspectJ.  This will allow AJDT
to find matches to pointcuts even if they sit somewhat outside the
model.  So, for example, you can show weaving matches between projects
when performing Load time weaving.  This can also likely be extended
to include matches between binary package roots.

hope this helps,
--a

On Wed, Jul 22, 2009 at 3:38 PM, Simone Gianni<simoneg@xxxxxxxxxx> wrote:
> Hi Andrew,
> thanks for the fast and in-depth answer. I arrived to
> ITDAwareNameEnvironment and was following my way back to "the core" of it.
> You gave me the right pointers.
>
> I have basically this problem, and I was trying to understand internals of
> AJDT to see if this is achievable at all, and if I could eventually
> contribute somehow.
>
> Suppose I have a User class, packaged in A.jar. Then I have an aspect ITD
> getIQ() on user, packaged in B.jar.
>
> Now, from a different project, that "depends" on A.jar and B.jar, I want to
> call User.getIQ().
>
> If I place A.jar on the inpath and B.jar on the aspectpath, AspectJ itself
> gives no error at all, and in fact there is no error in the package view.
> But if I open the .java or .aj file making the call, I can see
> reconciliation errors, and no ITD content assist for user.getIQ(). (should I
> raise a bug for this? I have it ready :D )
>
> I'm using this construct (aspect libraries adding new functionalities to
> classes in different libraries using ITDs) all the way around, and then they
> are composed together on a third package that need to use the original
> classes with the additional functionalities. It works in AspectJ, but it is
> a pain while writing it in Eclipse, due to reconciliation errors and lack of
> content assist.
>
> I was hoping that bug 271269
> <https://bugs.eclipse.org/bugs/show_bug.cgi?id=271269> was somehow going to
> resolve this issue, but it seems that it adds "source->binary" ITDs, while
> "binary->binary" ITDs are not handled, while they work in AspectJ.
>
>
> I noticed that in ITDAwareNameEnvironment, in the find(String,String)
> method, if the found type is a binary then no ITD interpolation is
> performed, and it does not exist an ITDAwareBinaryType* class.
>
> Exploring the AJProjectModelFacade however I can see many places where it
> tries to access AJ data from resources in jar files or class files.
>
> Is it a hard work to get that working? Theoretically if AJDT is able to
> extract ITDs from binary aspects, and to apply ITDs to binary classes (for
> bug 271269), the hardest pieces should be there.
>
>
> Simone
>
> Andrew Eisenberg wrote:
>>
>> Sure.  AJDT uses the crosscutting model from AspectJ as the base.  The
>> entry point into the AspectJ model is the AJProjectModelFacade class
>> (and AJProjectModelFactory to create them).  This class allows you to
>> convert from IJavaElement handles to IProgramElement handles, as well
>> as ask interesting questions about what elements crosscut other
>> elements.
>>
>> This information is used to seed content assist, gutter markers, the
>> crosscutting view, etc.  Gutter markers and crosscutting view are easy
>> since that is basically just taking a projection of the underlying
>> model and transforming it to the correct format.
>>
>> ITD Aware content assist is a bit more complex because we need to
>> trick JDT into thinking that ITDs really exist in the target type.
>> ITDInserter and ITDAwareSourceTypeElementInfo are two classes that
>> handle this mocking up of ITDs.
>>
>> There is a code sample on AJProjectModelFacade available on this wiki
>> page:
>>
>> http://wiki.eclipse.org/Developer%27s_guide_to_building_tools_on_top_of_AJDT_and_AspectJ
>>
>> I'm happy to go into more detail if you have any questions.
>>
>> On Wed, Jul 22, 2009 at 1:14 PM, Simone Gianni<simoneg@xxxxxxxxxx> wrote:
>>
>>>
>>> Hi all,
>>> this is the first time I have a serious look at AJDT internals, so please
>>> forgive me if I ask stupid questions :)
>>>
>>> I'm trying to figure out how AJDT fetches information from the underlying
>>> AJ, especially regarding ITDs. Does AJDT "re-reads" the .class files
>>> generated by AJ build? Or does it parses pointcuts and check them using
>>> the
>>> matcher? Or what else? :D
>>>
>>> I'm talking about informations to display ITD content assist as well as
>>> cross reference view, even if I think these use different methods.
>>>
>>> If you can point me to relevant part of code I'll then try to figure it
>>> out
>>> on my own.
>>>
>>> Simone
>>>
>>> --
>>> Simone Gianni            CEO Semeru s.r.l.           Apache Committer
>>> http://www.simonegianni.it/
>>>
>>> _______________________________________________
>>> ajdt-dev mailing list
>>> ajdt-dev@xxxxxxxxxxx
>>> https://dev.eclipse.org/mailman/listinfo/ajdt-dev
>>>
>>>
>>
>> _______________________________________________
>> ajdt-dev mailing list
>> ajdt-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/ajdt-dev
>>
>
>
> --
> Simone Gianni            CEO Semeru s.r.l.           Apache Committer
> http://www.simonegianni.it/
>
>


Back to the top