use of org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider in project applause by applause.
the class ApplauseDslSemanticSequencer method sequence_RESTMethodCall.
/**
* Constraint:
* (datasource=[DataSourceCall|ID] restMethod=[DataSourceAccessMethod|ID])
*/
protected void sequence_RESTMethodCall(EObject context, RESTMethodCall semanticObject) {
if (errorAcceptor != null) {
if (transientValues.isValueTransient(semanticObject, ApplauseDslPackage.Literals.REST_METHOD_CALL__DATASOURCE) == ValueTransient.YES)
errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ApplauseDslPackage.Literals.REST_METHOD_CALL__DATASOURCE));
if (transientValues.isValueTransient(semanticObject, ApplauseDslPackage.Literals.REST_METHOD_CALL__REST_METHOD) == ValueTransient.YES)
errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ApplauseDslPackage.Literals.REST_METHOD_CALL__REST_METHOD));
}
INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
feeder.accept(grammarAccess.getRESTMethodCallAccess().getDatasourceDataSourceCallIDTerminalRuleCall_0_0_1(), semanticObject.getDatasource());
feeder.accept(grammarAccess.getRESTMethodCallAccess().getRestMethodDataSourceAccessMethodIDTerminalRuleCall_2_0_1(), semanticObject.getRestMethod());
feeder.finish();
}
use of org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider in project applause by applause.
the class ApplauseDslSemanticSequencer method sequence_DataType.
/**
* Constraint:
* name=KeywordedID
*/
protected void sequence_DataType(EObject context, DataType semanticObject) {
if (errorAcceptor != null) {
if (transientValues.isValueTransient(semanticObject, ApplauseDslPackage.Literals.NAMED_ELEMENT__NAME) == ValueTransient.YES)
errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, ApplauseDslPackage.Literals.NAMED_ELEMENT__NAME));
}
INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
feeder.accept(grammarAccess.getDataTypeAccess().getNameKeywordedIDParserRuleCall_1_0(), semanticObject.getName());
feeder.finish();
}
use of org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider in project xtext-core by eclipse.
the class BacktrackingSemanticSequencer method createSequence.
@Override
public void createSequence(ISerializationContext context, EObject obj) {
INodesForEObjectProvider nodes = nodeProvider.getNodesForSemanticObject(obj, null);
SerializationContextMap<IConstraint> constraints = constraintProvider.getConstraints(grammar.getGrammar());
IConstraint constraint = constraints.get(context);
if (constraint == null)
throw new IllegalStateException("Invalid context: " + context);
Nfa<ISemState> nfa = constraint.getNfa();
final SerializableObject object = new SerializableObject(context, obj, nodes);
TraceItem co = new TraceItem(object);
List<TraceItem> trace = new NfaUtil().backtrack(nfa, co, new NfaUtil.BacktrackHandler<ISemState, TraceItem>() {
@Override
public TraceItem handle(ISemState state, TraceItem previous) {
if (!previous.canEnter(state))
return null;
if (state.getFeature() != null) {
return previous.cloneAndConsume(state);
} else
return previous.clone(state);
}
@Override
public boolean isSolution(TraceItem result) {
return result.isConsumed();
}
@Override
public Iterable<ISemState> sortFollowers(TraceItem result, Iterable<ISemState> followers) {
AbstractElement next = result.getNextGrammarElement();
List<ISemState> r = Lists.newArrayList(followers);
Collections.sort(r, createFollowerSorter(object, next));
return r;
}
});
SequenceFeeder feeder = feederProvider.create(context, obj, nodes, masterSequencer, sequenceAcceptor, errorAcceptor);
if (trace != null) {
for (TraceItem ti : trace) if (ti.getState() != null && ti.getState().getFeature() != null)
accept(ti, feeder);
} else if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createBacktrackingFailedDiagnostic(object, context, constraint));
feeder.finish();
}
use of org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider in project xtext-core by eclipse.
the class ContextFinder method findAssignedElements.
protected Set<AbstractElement> findAssignedElements(EObject obj, EStructuralFeature feature, Multimap<AbstractElement, ISerializationContext> assignments) {
if (feature.isMany()) {
Set<AbstractElement> r = Sets.newLinkedHashSet();
INodesForEObjectProvider nodes = nodesProvider.getNodesForSemanticObject(obj, null);
switch(transientValues.isListTransient(obj, feature)) {
case SOME:
List<?> values1 = (List<?>) obj.eGet(feature);
int j = 0;
for (int i = 0; i < values1.size(); i++) if (!transientValues.isValueInListTransient(obj, i, feature)) {
Object value = values1.get(i);
INode node = nodes.getNodeForMultiValue(feature, i, j, value);
r.addAll(assignmentFinder.findAssignmentsByValue(obj, assignments, value, node));
j++;
}
return r;
case NO:
List<?> values2 = (List<?>) obj.eGet(feature);
for (int i = 0; i < values2.size(); i++) {
Object value = values2.get(i);
INode node = nodes.getNodeForMultiValue(feature, i, i, value);
r.addAll(assignmentFinder.findAssignmentsByValue(obj, assignments, value, node));
}
return r;
default:
return Collections.emptySet();
}
} else {
if (transientValues.isValueTransient(obj, feature) == ValueTransient.YES)
return Collections.emptySet();
Object value = obj.eGet(feature);
INode node = nodesProvider.getNodesForSemanticObject(obj, null).getNodeForSingelValue(feature, value);
return assignmentFinder.findAssignmentsByValue(obj, assignments, value, node);
}
}
use of org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider in project mechanoid by robotoworks.
the class NetModelSemanticSequencer method sequence_LongType.
/**
* Constraint:
* id='long'
*/
protected void sequence_LongType(EObject context, LongType semanticObject) {
if (errorAcceptor != null) {
if (transientValues.isValueTransient(semanticObject, NetModelPackage.Literals.INTRINSIC_TYPE__ID) == ValueTransient.YES)
errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, NetModelPackage.Literals.INTRINSIC_TYPE__ID));
}
INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
feeder.accept(grammarAccess.getLongTypeAccess().getIdLongKeyword_0(), semanticObject.getId());
feeder.finish();
}
Aggregations