AJCompilationUnit question. [message #60863] |
Thu, 12 January 2006 02:54  |
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  |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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)
|
|
|
Powered by
FUDForum. Page generated in 0.07385 seconds