Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » AJCompilationUnit question.
AJCompilationUnit question. [message #60863] Thu, 12 January 2006 02:54 Go to next message
Eclipse User
Originally posted by: zifu.yang.gmail.com

I called getAJCompilationUnit(IFile file) in AJCompilationUnitManager to
get a compilation unit.
Then called ajcompilationUnit.getBuffer().getContents() to get the contents
of this unit. However, in this contents, the keyword "aspect" was changed
to "class" silently. Is this a bug?
Re: AJCompilationUnit question. [message #60886 is a reply to message #60863] Thu, 12 January 2006 04:18 Go to previous message
Matt Chapman is currently offline Matt Chapman
Messages: 429
Registered: July 2009
Senior Member
On Thu, 12 Jan 2006 01:54:50 -0600, Zifu Yang wrote:
> I called getAJCompilationUnit(IFile file) in AJCompilationUnitManager to
> get a compilation unit.
> Then called ajcompilationUnit.getBuffer().getContents() to get the contents
> of this unit. However, in this contents, the keyword "aspect" was changed
> to "class" silently. Is this a bug?

No, it's working as designed, for the current implementation. The
AJCompilationUnit is "pretending" to have Java syntax, so that JDT does
not get (too) confused by its existence.

However, once you know it's an AJCompilationUnit, there is a call you can
make to obtain the real contents, but you must return it to compatible
mode afterwards. Here's an example:

AJCompilationUnit cu =
AJCompilationUnitManager.INSTANCE.getAJCompilationUnit(file) ;
cu.requestOriginalContentMode();
String contents = cu.getBuffer().getContents();
cu.discardOriginalContentMode();

Hope that helps,

Matt.
(btw the developer's mailing list is also a good place for questions like
this: http://dev.eclipse.org/mailman/listinfo/ajdt-dev)
Re: AJCompilationUnit question. [message #591800 is a reply to message #60863] Thu, 12 January 2006 04:18 Go to previous message
Matt Chapman is currently offline Matt Chapman
Messages: 429
Registered: July 2009
Senior Member
On Thu, 12 Jan 2006 01:54:50 -0600, Zifu Yang wrote:
> I called getAJCompilationUnit(IFile file) in AJCompilationUnitManager to
> get a compilation unit.
> Then called ajcompilationUnit.getBuffer().getContents() to get the contents
> of this unit. However, in this contents, the keyword "aspect" was changed
> to "class" silently. Is this a bug?

No, it's working as designed, for the current implementation. The
AJCompilationUnit is "pretending" to have Java syntax, so that JDT does
not get (too) confused by its existence.

However, once you know it's an AJCompilationUnit, there is a call you can
make to obtain the real contents, but you must return it to compatible
mode afterwards. Here's an example:

AJCompilationUnit cu =
AJCompilationUnitManager.INSTANCE.getAJCompilationUnit(file) ;
cu.requestOriginalContentMode();
String contents = cu.getBuffer().getContents();
cu.discardOriginalContentMode();

Hope that helps,

Matt.
(btw the developer's mailing list is also a good place for questions like
this: http://dev.eclipse.org/mailman/listinfo/ajdt-dev)
Previous Topic:AJCompilationUnit question.
Next Topic:AspectJ/Java Editor does not work
Goto Forum:
  


Current Time: Fri Jul 25 03:02:30 EDT 2014

Powered by FUDForum. Page generated in 0.02452 seconds