Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] AJDT and and referencing aspects with aspectOf()

Essentially, yes. The "early error indications" that you see in the editor and the actual problem markers (warning and error) that result from a build are two different (but related) things. As you edit text in the editor buffer, the JDT is constantly checking your source code against it's "Java Model" and says the equivalent of "if you were to save and build this right now, these are the errors I think you would get". The model that the JDT builds for doing these checks understands only Java constructs. It won't go into .aj files for example (so all aspects declared in .aj files are invisible to it), it doesn't understand ITDs (so it may think you are calling methods that don't exist), and it doesn't understand declare soft. Of course when you really do save the file, it's the AspectJ compiler not the Java compiler that kicks in, and everything is fine. When you open the file in the AspectJ/Java editor instead, it performs additional checking against the AspectJ view of the world to avoid giving false error indications.



On 12/04/06, Ken Pelletier <ken@xxxxxxxx> wrote:
Thanks, Adrian.

This has piqued my curiosity a bit more.

Is it expected that even simple references to an aspect class are not allowed by the JDT Java editor?  It wasn't the use of aspectOf() method per se that it was complaining about, but any reference to the aspect class.

Things like:

import MyAspect;

or:

foo = MyAspect.SOME_EVIL_PUBLIC_STATIC_FINAL;

Is it that, due to the type system differences, an aspect class is wholly unrecognizable to the JDT Java editor?

Cheers,

- Ken

On Apr 12, 2006, at 5:03 AM, Adrian Colyer wrote:

The JDT Java editor doesn't understanding the AspectJ type system, so where aspects extend the base Java model (such as the "aspectOf" method), the editor is unaware of them and highlights things like "aspectOf" as potential errors. At compile time of course, AspectJ compiles the file quite happily.

The solution is to go to the package explorer and select "open with... AspectJ/Java editor" for the file. This editor is an extension of the Java one and *does* understand the AJ type system.

On 12/04/06, Ken Pelletier <ken@xxxxxxxx> wrote:
Within an ADJT project, if I have a JUnit TestCase in which I want to
instantiate an aspect (from the same project) using aspectOf().

In doing this, the test case gets errors in the gutters on references
the aspect class:  "cannot be resolved as a type", and I am also
unable to import the aspect class in eclipse.

I can, however launch the test and it runs and passes.

Is there a configuration to get around this?

I find I can open the TestCase with the AspectJ editor and it then
works, but it strikes me that there must be something else I'm
missing.  It is just a java class after all.

Can somebody please enlighten me?

Thanks,

- Ken

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



--
-- Adrian
adrian.colyer@xxxxxxxxx
_______________________________________________


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users





--
-- Adrian
adrian.colyer@xxxxxxxxx

Back to the top