Example #1
0
 @Override
 public Boolean caseAlternatives(Alternatives object) {
   boolean more = false;
   for (AbstractElement element : object.getElements()) {
     more = doSwitch(element) || more;
   }
   return more || isOptional(object);
 }
Example #2
0
 @Override
 public Boolean caseAlternatives(Alternatives object) {
   Multimap<String, AbstractElement> prevAssignedFeatures = assignedFeatures;
   Multimap<String, AbstractElement> mergedAssignedFeatures = LinkedHashMultimap.create();
   for (AbstractElement element : object.getElements()) {
     assignedFeatures = newMultimap(prevAssignedFeatures);
     doSwitch(element);
     mergedAssignedFeatures.putAll(assignedFeatures);
   }
   if (GrammarUtil.isOptionalCardinality(object)) {
     mergedAssignedFeatures.putAll(prevAssignedFeatures);
   }
   assignedFeatures = mergedAssignedFeatures;
   if (GrammarUtil.isMultipleCardinality(object)) {
     prevAssignedFeatures = assignedFeatures;
     for (AbstractElement element : object.getElements()) {
       assignedFeatures = newMultimap(prevAssignedFeatures);
       doSwitch(element);
       mergedAssignedFeatures.putAll(assignedFeatures);
     }
     assignedFeatures = mergedAssignedFeatures;
   }
   return Boolean.FALSE;
 }
 protected String _toXtext(final Alternatives alt) {
   EList<AbstractElement> _elements = alt.getElements();
   String _elvis = null;
   String _cardinality = alt.getCardinality();
   if (_cardinality != null) {
     _elvis = _cardinality;
   } else {
     _elvis = "";
   }
   String _plus = (")" + _elvis);
   final Function1<AbstractElement, CharSequence> _function =
       new Function1<AbstractElement, CharSequence>() {
         @Override
         public CharSequence apply(final AbstractElement it) {
           return PredicatedElementTest.this.toXtext(it);
         }
       };
   return IterableExtensions.<AbstractElement>join(_elements, "(", " | ", _plus, _function);
 }