use of org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient in project xtext-core by eclipse.
the class PartialSerializer method trySerializeSingleValue.
protected List<SerializationStrategy> trySerializeSingleValue(EObject owner, FeatureChange change, IEObjectRegion ownerRegion, IConstraint constraint) {
List<SerializationStrategy> result = Lists.newArrayList();
EStructuralFeature feature = change.getFeature();
IFeatureInfo featureInfo = constraint.getFeatures()[owner.eClass().getFeatureID(feature)];
List<IConstraintElement> assignments = featureInfo.getAssignments();
if (assignments.size() != 1) {
return null;
}
boolean optional = assignments.get(0).isOptional();
IAstRegion featureRegion = findRegion(ownerRegion, change);
ValueTransient valueTransient = transientValues.isValueTransient(owner, feature);
switch(valueTransient) {
case YES:
if (featureRegion != null) {
if (optional) {
result.add(new DeleteRegionStrategy(featureRegion));
} else {
return null;
}
}
break;
case PREFERABLY:
if (featureRegion != null) {
if (optional) {
result.add(new DeleteRegionStrategy(featureRegion));
} else {
SerializationStrategy update = updateSingleValue(owner, feature, featureRegion);
if (update != null) {
result.add(update);
} else {
return null;
}
}
}
break;
case NO:
if (featureRegion == null) {
return null;
}
SerializationStrategy update = updateSingleValue(owner, feature, featureRegion);
if (update != null) {
result.add(update);
} else {
return null;
}
break;
}
return result;
}
use of org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient in project xtext-core by eclipse.
the class ContextFinder method isValidValueQuantity.
protected boolean isValidValueQuantity(IConstraint constraint, EObject semanicObj) {
if (constraint == null)
return false;
for (int featureID = 0; featureID < semanicObj.eClass().getFeatureCount(); featureID++) {
IFeatureInfo featureInfo = constraint.getFeatures()[featureID];
EStructuralFeature feature = semanicObj.eClass().getEStructuralFeature(featureID);
if (feature.isMany()) {
int count = transientValueUtil.countNonTransientListValues(semanicObj, feature);
if (count > featureInfo.getUpperBound())
return false;
if (count < featureInfo.getLowerBound())
return false;
} else {
ValueTransient valueTransient = transientValues.isValueTransient(semanicObj, feature);
switch(valueTransient) {
case NO:
if (featureInfo == null)
return false;
if (featureInfo.getUpperBound() <= 0)
return false;
break;
case YES:
if (featureInfo == null)
break;
if (featureInfo.getLowerBound() > 0)
return false;
break;
case PREFERABLY:
break;
}
}
}
return true;
}
Aggregations