Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » AJCompilationUnit question.
AJCompilationUnit question. [message #60863] Thu, 12 January 2006 07:54 Go to next message
Eclipse UserFriend
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 09:18 Go to previous message
Matt Chapman is currently offline Matt ChapmanFriend
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 09:18 Go to previous message
Matt Chapman is currently offline Matt ChapmanFriend
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: Thu Nov 27 20:05:38 GMT 2014

Powered by FUDForum. Page generated in 0.01558 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software