Home » Language IDEs » AspectJ » How to find fully qualified type name from simple type name?
How to find fully qualified type name from simple type name? [message #67522] |
Tue, 31 October 2006 18:40 |
Eclipse User |
|
|
|
Originally posted by: m.bartsch.rdg.ac.uk
Hi all,
How can I find the fully qualified type name of an aspect from a simple
type name in my plug-in? If I have an IType object (e.g. theJavaType)
that represents a class, then
theJavaType.resolveType( "someClass" );
works fine and returns the fully qual. name of "someClass" which is
visible in theJavaType. If I have an IType that represent an aspect
(e.g. theAspectType), then it does not work and null is returned for
another aspect "someAspect" that is visible in theAspectType:
IType theAspectType = ... // Get IType for aspect E
String[][] tp = theAspectType.resolveType( "someAspect" );
// returns null;
The aspect in question could look like:
public aspect E
{
declare precedence : someAspect, someOtherAspect;
}
It should be noted that IType is org.eclipse.jdt.core.IType and not
org.aspectj.org.eclipse.jdt.core.IType and I assume that I should be
using the latter, but I do not know how to retrieve it. Is there maybe
an easier way to resolve a type name than using IType.resolveType?
Thanks a lot,
Marc.
|
|
|
Re: How to find fully qualified type name from simple type name? [message #67566 is a reply to message #67522] |
Wed, 01 November 2006 11:17 |
Matt Chapman Messages: 429 Registered: July 2009 |
Senior Member |
|
|
Warning: this is more complicated than it should be! To keep things
short I'll explain the way things currently are (as of AJDT 1.4 and
Eclipse 3.2) but not the reasons why.
Firstly, for a single .aj file in eclipse there are two compilation
units: one created by JDT and one created by AJDT (which is an
AJCompilationUnit). How are you getting the IType for your aspect? It
needs to come from the AJDT compilation unit. You can use methods in
AJCompilationUnitManager to do obtain it directly, or use the method
mapToAJCompilationUnit() to obtain one from the other.
Secondly aspects (usually) have a different working copy owner, so you
could try the two arg version of resolveType, using
AJCompilationUnitManager.defaultAJWorkingCopyOwner() as the working copy
owner. Alternatively you could try to resolve the type in the context of
the project. Here's an example from the implementation of the New Aspect
wizard (NewAspectWizardPage.java):
IType stype = type.getJavaProject().findType(supertype,
AJCompilationUnitManager.defaultAJWorkingCopyOwner());
Hope that helps,
Matt.
Marc Bartsch wrote:
> Hi all,
>
> How can I find the fully qualified type name of an aspect from a simple
> type name in my plug-in? If I have an IType object (e.g. theJavaType)
> that represents a class, then
>
> theJavaType.resolveType( "someClass" );
>
> works fine and returns the fully qual. name of "someClass" which is
> visible in theJavaType. If I have an IType that represent an aspect
> (e.g. theAspectType), then it does not work and null is returned for
> another aspect "someAspect" that is visible in theAspectType:
>
> IType theAspectType = ... // Get IType for aspect E
>
> String[][] tp = theAspectType.resolveType( "someAspect" );
> // returns null;
>
> The aspect in question could look like:
>
> public aspect E
> {
> declare precedence : someAspect, someOtherAspect;
> }
>
> It should be noted that IType is org.eclipse.jdt.core.IType and not
> org.aspectj.org.eclipse.jdt.core.IType and I assume that I should be
> using the latter, but I do not know how to retrieve it. Is there maybe
> an easier way to resolve a type name than using IType.resolveType?
>
> Thanks a lot,
>
> Marc.
|
|
|
Re: How to find fully qualified type name from simple type name? [message #67583 is a reply to message #67566] |
Wed, 01 November 2006 14:23 |
Eclipse User |
|
|
|
Originally posted by: m.bartsch.rdg.ac.uk
Hi Matt,
Thanks for your help! Retrieving the ITypes from AJCompilationUnit and
using the two arg version does the trick.
Best wishes,
Marc.
Matt Chapman schrieb:
> Warning: this is more complicated than it should be! To keep things
> short I'll explain the way things currently are (as of AJDT 1.4 and
> Eclipse 3.2) but not the reasons why.
>
> Firstly, for a single .aj file in eclipse there are two compilation
> units: one created by JDT and one created by AJDT (which is an
> AJCompilationUnit). How are you getting the IType for your aspect? It
> needs to come from the AJDT compilation unit. You can use methods in
> AJCompilationUnitManager to do obtain it directly, or use the method
> mapToAJCompilationUnit() to obtain one from the other.
>
> Secondly aspects (usually) have a different working copy owner, so you
> could try the two arg version of resolveType, using
> AJCompilationUnitManager.defaultAJWorkingCopyOwner() as the working copy
> owner. Alternatively you could try to resolve the type in the context of
> the project. Here's an example from the implementation of the New Aspect
> wizard (NewAspectWizardPage.java):
>
> IType stype =
> type.getJavaProject().findType(supertype,
> AJCompilationUnitManager.defaultAJWorkingCopyOwner());
>
> Hope that helps,
>
> Matt.
>
> Marc Bartsch wrote:
>> Hi all,
>>
>> How can I find the fully qualified type name of an aspect from a simple
>> type name in my plug-in? If I have an IType object (e.g. theJavaType)
>> that represents a class, then
>>
>> theJavaType.resolveType( "someClass" );
>>
>> works fine and returns the fully qual. name of "someClass" which is
>> visible in theJavaType. If I have an IType that represent an aspect
>> (e.g. theAspectType), then it does not work and null is returned for
>> another aspect "someAspect" that is visible in theAspectType:
>>
>> IType theAspectType = ... // Get IType for aspect E
>>
>> String[][] tp = theAspectType.resolveType( "someAspect" );
>> // returns null;
>>
>> The aspect in question could look like:
>>
>> public aspect E
>> {
>> declare precedence : someAspect, someOtherAspect;
>> }
>>
>> It should be noted that IType is org.eclipse.jdt.core.IType and not
>> org.aspectj.org.eclipse.jdt.core.IType and I assume that I should be
>> using the latter, but I do not know how to retrieve it. Is there maybe
>> an easier way to resolve a type name than using IType.resolveType?
>>
>> Thanks a lot,
>>
>> Marc.
|
|
|
Re: How to find fully qualified type name from simple type name? [message #595207 is a reply to message #67522] |
Wed, 01 November 2006 11:17 |
Matt Chapman Messages: 429 Registered: July 2009 |
Senior Member |
|
|
Warning: this is more complicated than it should be! To keep things
short I'll explain the way things currently are (as of AJDT 1.4 and
Eclipse 3.2) but not the reasons why.
Firstly, for a single .aj file in eclipse there are two compilation
units: one created by JDT and one created by AJDT (which is an
AJCompilationUnit). How are you getting the IType for your aspect? It
needs to come from the AJDT compilation unit. You can use methods in
AJCompilationUnitManager to do obtain it directly, or use the method
mapToAJCompilationUnit() to obtain one from the other.
Secondly aspects (usually) have a different working copy owner, so you
could try the two arg version of resolveType, using
AJCompilationUnitManager.defaultAJWorkingCopyOwner() as the working copy
owner. Alternatively you could try to resolve the type in the context of
the project. Here's an example from the implementation of the New Aspect
wizard (NewAspectWizardPage.java):
IType stype = type.getJavaProject().findType(supertype,
AJCompilationUnitManager.defaultAJWorkingCopyOwner());
Hope that helps,
Matt.
Marc Bartsch wrote:
> Hi all,
>
> How can I find the fully qualified type name of an aspect from a simple
> type name in my plug-in? If I have an IType object (e.g. theJavaType)
> that represents a class, then
>
> theJavaType.resolveType( "someClass" );
>
> works fine and returns the fully qual. name of "someClass" which is
> visible in theJavaType. If I have an IType that represent an aspect
> (e.g. theAspectType), then it does not work and null is returned for
> another aspect "someAspect" that is visible in theAspectType:
>
> IType theAspectType = ... // Get IType for aspect E
>
> String[][] tp = theAspectType.resolveType( "someAspect" );
> // returns null;
>
> The aspect in question could look like:
>
> public aspect E
> {
> declare precedence : someAspect, someOtherAspect;
> }
>
> It should be noted that IType is org.eclipse.jdt.core.IType and not
> org.aspectj.org.eclipse.jdt.core.IType and I assume that I should be
> using the latter, but I do not know how to retrieve it. Is there maybe
> an easier way to resolve a type name than using IType.resolveType?
>
> Thanks a lot,
>
> Marc.
|
|
|
Re: How to find fully qualified type name from simple type name? [message #595223 is a reply to message #67566] |
Wed, 01 November 2006 14:23 |
Eclipse User |
|
|
|
Originally posted by: m.bartsch.rdg.ac.uk
Hi Matt,
Thanks for your help! Retrieving the ITypes from AJCompilationUnit and
using the two arg version does the trick.
Best wishes,
Marc.
Matt Chapman schrieb:
> Warning: this is more complicated than it should be! To keep things
> short I'll explain the way things currently are (as of AJDT 1.4 and
> Eclipse 3.2) but not the reasons why.
>
> Firstly, for a single .aj file in eclipse there are two compilation
> units: one created by JDT and one created by AJDT (which is an
> AJCompilationUnit). How are you getting the IType for your aspect? It
> needs to come from the AJDT compilation unit. You can use methods in
> AJCompilationUnitManager to do obtain it directly, or use the method
> mapToAJCompilationUnit() to obtain one from the other.
>
> Secondly aspects (usually) have a different working copy owner, so you
> could try the two arg version of resolveType, using
> AJCompilationUnitManager.defaultAJWorkingCopyOwner() as the working copy
> owner. Alternatively you could try to resolve the type in the context of
> the project. Here's an example from the implementation of the New Aspect
> wizard (NewAspectWizardPage.java):
>
> IType stype =
> type.getJavaProject().findType(supertype,
> AJCompilationUnitManager.defaultAJWorkingCopyOwner());
>
> Hope that helps,
>
> Matt.
>
> Marc Bartsch wrote:
>> Hi all,
>>
>> How can I find the fully qualified type name of an aspect from a simple
>> type name in my plug-in? If I have an IType object (e.g. theJavaType)
>> that represents a class, then
>>
>> theJavaType.resolveType( "someClass" );
>>
>> works fine and returns the fully qual. name of "someClass" which is
>> visible in theJavaType. If I have an IType that represent an aspect
>> (e.g. theAspectType), then it does not work and null is returned for
>> another aspect "someAspect" that is visible in theAspectType:
>>
>> IType theAspectType = ... // Get IType for aspect E
>>
>> String[][] tp = theAspectType.resolveType( "someAspect" );
>> // returns null;
>>
>> The aspect in question could look like:
>>
>> public aspect E
>> {
>> declare precedence : someAspect, someOtherAspect;
>> }
>>
>> It should be noted that IType is org.eclipse.jdt.core.IType and not
>> org.aspectj.org.eclipse.jdt.core.IType and I assume that I should be
>> using the latter, but I do not know how to retrieve it. Is there maybe
>> an easier way to resolve a type name than using IType.resolveType?
>>
>> Thanks a lot,
>>
>> Marc.
|
|
|
Goto Forum:
Current Time: Fri Dec 27 02:49:07 GMT 2024
Powered by FUDForum. Page generated in 0.03892 seconds
|