| Summary: | Setting default values for features in the grammar | ||
|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Sébastien Gandon <sgandon> |
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P5 | CC: | bojidar.dimitrov, foremans, moritz.eysholdt, robert, sven.efftinge |
| Version: | 0.7.0 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Sébastien Gandon
*** Bug 316862 has been marked as a duplicate of this bug. *** I'd say default values for EAttributes are not something Xtext's grammar should handle. Ecore provides many features of which only some can be inferred from the grammar. This is intentional, since otherwise the grammar would become more complex than Ecore itself. To set default values, you can a) Import the Ecore model (instead of generating it) in the grammar. Thereby, you can edit the Ecore file directly. b) Use MWE's EcoreGenerator. It allows to use the generation gap pattern... so you can override the Java Methodes generated by EMF. With this approach even dynamic defaults become possible. :) (aka if feature a is not set, use feature b's value as default). c) Use the processor that allows to modify the Ecore model that is inferred from the grammar. proposing to close this one as "won't fix". The request is not to declare default values for EAttributes but to set values based on decisions the parser made during parsing. This is 2 years and old and probably long forgotten about by now. Any update on this? Is there a way to specify the what the default value should be for missing attributes within a rule? Here is the essence of what I'm trying to do: Main: A | B; A: 'value' type=EnumType name=Name '=' value=INT; B returns A(property=EnumType.special): 'special' name=Name '=' value=INT; EnumType: normal | extended | special | ... Thanks for the reminder. This requirement comes up rarely and can be solved by post-processing the parsed model, which is why I close this bug. Sorry for having it laying around for such a long time. |