Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Re: Duplicate case error in generated model
Re: Duplicate case error in generated model [message #461502] Sun, 02 August 2009 11:40 Go to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3104
Registered: July 2009
Senior Member
Hi everybody,

the following Ecore model will lead to compile time errors.

eClass A {
attr X: int;
}
eClass B {
attr X: int;
}
eClass C extends A, B {
}

You'll end up with duplicate field names in the package. Is there a way
to avoid this?

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


Am 01.08.2009 11:22 Uhr, schrieb Sebastian Zarnekow:
> Hi KD,
>
> I guess, you are stumbling across a bug in EMF. It seems that the naming
> convention that is used by genmodel cannot handle this case. That's why
> I've added the EMF newsgroup to this thread.
> Maybe someone can confirm this to be a bug or give us a hint on how to
> avoid this compile time error.
>
> Regards,
> Sebastian

Am 01.08.2009 7:58 Uhr, schrieb KD:
>> The following grammar generates duplicate case errors in generated java
>> code.
>>
>> grammar org.xtext.example.MyDsl with org.eclipse.xtext.common.Terminals
>>
>> generate myDsl "http://www.xtext.org/example/MyDsl"
>>
>> Type:
>> 'B' (list+=B)* |
>> 'C' (list+=C)*
>> ;
>>
>> B:
>> A |
>> 'width' Width=INT
>> ;
>>
>> A:
>> 'name' name=STRING
>> ;
>>
>> C:
>> A |
>> 'width' Width=INT
>> ;
>>
>> Is it expected? The grammar itself is generated, so modifying the
>> grammar by hand is not possible. What other alternatives do I have?
>>
>> TIA.
>>
>> -- KD
>>
Re: Duplicate case error in generated model [message #462222 is a reply to message #461502] Sun, 02 August 2009 13:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
Sebastian,

It's not a valid model. You might define a base EClass Foo with an
EOperation getX() and have all three inherit from that...

Sebastian Zarnekow wrote:
> Hi everybody,
>
> the following Ecore model will lead to compile time errors.
>
> eClass A {
> attr X: int;
> }
> eClass B {
> attr X: int;
> }
> eClass C extends A, B {
> }
>
> You'll end up with duplicate field names in the package. Is there a
> way to avoid this?
>
> Regards,
> Sebastian
Re: Duplicate case error in generated model [message #463661 is a reply to message #462222] Sun, 02 August 2009 17:28 Go to previous messageGo to next message
Dakshinamurthy Karra is currently offline Dakshinamurthy KarraFriend
Messages: 45
Registered: July 2009
Member
Hello Ed,

Ed Merks wrote:

> It's not a valid model. You might define a base EClass Foo with an
> EOperation getX() and have all three inherit from that...

Is it not a valid EMF model or there is inherit flaw in modeling like this?

-- KD
Re: Duplicate case error in generated model [message #463809 is a reply to message #463661] Sun, 02 August 2009 17:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
KD,

If you validate the model, you'll get an error message indicating that
you can't have two features with the same name among all the features
you define local or inherit.


KD wrote:
> Hello Ed,
>
> Ed Merks wrote:
>
>> It's not a valid model. You might define a base EClass Foo with an
>> EOperation getX() and have all three inherit from that...
>
> Is it not a valid EMF model or there is inherit flaw in modeling like
> this?
>
> -- KD
>
Re: Duplicate case error in generated model [message #463811 is a reply to message #463809] Sun, 02 August 2009 17:53 Go to previous message
Dakshinamurthy Karra is currently offline Dakshinamurthy KarraFriend
Messages: 45
Registered: July 2009
Member
Ed,

Thanks for the reply. Unfortunately, the grammar is programmatically
generated and finding these cases is complicated. I took an easy way out
and generating unique feature names. That solved the problem.

-- KD
Previous Topic:[CDO] No suitable mapping found from EMF type CUSTOM to DB type DBType
Next Topic:org.xml.sax.SAXParseException: Content is not allowed in prolog / Custom ResourceImpl / case sensiti
Goto Forum:
  


Current Time: Sat Dec 14 16:29:09 GMT 2019

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

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

Back to the top