[xtend] instanceof [message #516766] |
Wed, 24 February 2010 21:00  |
Eclipse User |
|
|
|
Hi,
suppose I have a meta model where there are classes
B and C that extend a class A and another model with
a class D.
B has an attribute of type b and C has an attribute of type c.
Also, D has an attribute of type d.
I want to write an extension like this:
create D this AToD(A aa):
// If A is a B, set D.d to B.b,
// if A is a C, set D.d to C.c
;
At first I thought I could just write several extensions
with the same name for every class:
create D this AToD(B bb) and create D this AToD(C cc)
However, I get this exception:
org.eclipse.core.commands.common.NotDefinedException: Cannot get the
parent identifier from an undefined context.
org.eclipse.ui.edit.text.actionSet.presentation
Then I thought I could write an Extension like this:
create D this AToD(A aa):
// If A is a B, return BToD
// if A is a C, return CToD
;
and also two extensions like this:
create D this BToD(B bb):
this.setd(bb.b)
;
create D this CToD(C cc):
this.setd(cc.c)
;
Is there something like an 'instanceof' operator in xtend
so I can use the latter approach? Or maybe the first is the
right one and i'm just doing something wrong?
Regards,
Matthias
|
|
|
|
Re: [xtend] instanceof [message #517066 is a reply to message #516771] |
Thu, 25 February 2010 20:11   |
Eclipse User |
|
|
|
Hi Sven,
thank you for your reply. You are right, the exception seems to have
nothing to do with the extension. It's because it doesn't occur anymore.
If I find a way to reproduce it, I will file a bugzilla.
Regards,
Matthias
Sven Efftinge wrote:
> Matthias Schmeling schrieb:
>> I want to write an extension like this:
>>
>> create D this AToD(A aa):
>> // If A is a B, set D.d to B.b,
>> // if A is a C, set D.d to C.c
>> ;
>>
>> At first I thought I could just write several extensions
>> with the same name for every class:
>>
>> create D this AToD(B bb) and create D this AToD(C cc)
>
> Yes, that should work.
>
>> However, I get this exception:
>> org.eclipse.core.commands.common.NotDefinedException: Cannot get the
>> parent identifier from an undefined context.
>> org.eclipse.ui.edit.text.actionSet.presentation
>
> It shouldn't have something to do with the extension.
> Could you please file a bugzilla containing the stack trace and the
> example?
>
>>
>> Is there something like an 'instanceof' operator in xtend
>> so I can use the latter approach?
>
> Yes, it's: TypeName.isInstance(object)
>
> Sven
>
|
|
|
|
|
Re: [xtend] instanceof [message #518135 is a reply to message #516766] |
Wed, 03 March 2010 03:44  |
Eclipse User |
|
|
|
No, I had troubles with the basics on metamodeling, but its solved now (I think).
But still, thanks for answering, that answer helps me for something else.
Regards
maxime
|
|
|
Powered by
FUDForum. Page generated in 0.04146 seconds