Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347304 - Specifying super types with only alternative break EAttribute inheritance
Summary: Specifying super types with only alternative break EAttribute inheritance
Status: CLOSED WONTFIX
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-26 08:39 EDT by Florian Philipp CLA
Modified: 2017-09-19 17:23 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Philipp CLA 2011-05-26 08:39:22 EDT
Build Identifier: M20100909-0800

Consider the following grammar:
SuperType: TypeA | TypeB;

TypeA: SubTypeA1 | SubTypeA2;
SubTypeA1: name='A1';
SubTypeA2: name='A2';

TypeB: SubTypeB;
SubTypeB: name='B';

In this case, neither TypeB nor SuperType will contain a name attribute in the generated source code. Adding a second alternative to TypeB or removing TypeB and adding SubTypeB directly to the alternatives of SuperType resolves this issue and adds name to SuperType.

Reproducible: Always
Comment 1 Sebastian Zarnekow CLA 2011-05-26 09:23:25 EDT
This works as specified. The attributes will be pulled up if there is more than one subtype and all subtypes have the attribute in common. That condition does not hold for TypeB which has not a 'name' attribute.

Consider the following simplified example:

Type: SubType | {Type} 'keyword';
SubType: someAttribute=ID;

If we reduce the constraints that mark attributes as 'to-be-pulled-up', all attributes would end up in the most abstract super type. That's usually not what you'ld expect.

In general I'd recommend to switch to imported metamodels as soon as your grammar is settled or the meta model inference does not do what you want. 

Please reopen if I missed a point.
Comment 2 Karsten Thoms CLA 2017-09-19 17:12:06 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 3 Karsten Thoms CLA 2017-09-19 17:23:34 EDT
Closing all bugs that were set to RESOLVED before Neon.0