eclipse - How to distinguish between 0 and unset in XText/EMF -


using xtext 2.6.2, have grammar references ecore, , model containing:

numberliteral :     int= long;  terminal long returns ecore::elong:     ('-')? (number)+;  terminal fragment number:     '0'..'9'; 

this generates class numberliteralimpl with:

  protected static final long int_edefault = 0l; 

and

  @override   public boolean eisset(int featureid)   {     switch (featureid)     {       case xcogpackage.number_literal__int:         return int_ != int_edefault;     }     return super.eisset(featureid);   } 

which means when set int attribute 0, counts unset.

which not @ useful; example, can't serialise expression 0 in it. if try, error of form:

org.eclipse.xtext.validation.iconcretesyntaxvalidator$invalidconcretesyntaxexception: these errors need fixed before model can serialized. systemmodel.{*snip*}.value->numberliteral: feature numberliteral.int must set. 

is there fix, or better way of doing this?

to prevent hitting same issue , finding unanswered question, solution went replace ecore::elong ecore::ebigdecimal. that's object, use null reference rather 0 'unset'.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -