use of org.eclipse.xtext.serializer.analysis.SerializationContext in project xtext-core by eclipse.
the class SerializerFragment2 method genMethodCreateSequenceCaseBody.
private StringConcatenationClient genMethodCreateSequenceCaseBody(final Map<IGrammarConstraintProvider.IConstraint, IGrammarConstraintProvider.IConstraint> superConstraints, final EClass type) {
StringConcatenationClient _xblockexpression = null;
{
final Function1<Map.Entry<IGrammarConstraintProvider.IConstraint, List<ISerializationContext>>, String> _function = (Map.Entry<IGrammarConstraintProvider.IConstraint, List<ISerializationContext>> it) -> {
return it.getKey().getName();
};
final List<Map.Entry<IGrammarConstraintProvider.IConstraint, List<ISerializationContext>>> contexts = IterableExtensions.<Map.Entry<IGrammarConstraintProvider.IConstraint, List<ISerializationContext>>, String>sortBy(this._semanticSequencerExtensions.getGrammarConstraints(this.getGrammar(), type).entrySet(), _function);
final LinkedHashMultimap<EObject, IGrammarConstraintProvider.IConstraint> context2constraint = LinkedHashMultimap.<EObject, IGrammarConstraintProvider.IConstraint>create();
for (final Map.Entry<IGrammarConstraintProvider.IConstraint, List<ISerializationContext>> e : contexts) {
List<ISerializationContext> _value = e.getValue();
for (final ISerializationContext ctx : _value) {
context2constraint.put(((SerializationContext) ctx).getActionOrRule(), e.getKey());
}
}
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
{
int _size = contexts.size();
boolean _greaterThan = (_size > 1);
if (_greaterThan) {
{
Iterable<Pair<Integer, Map.Entry<IGrammarConstraintProvider.IConstraint, List<ISerializationContext>>>> _indexed = IterableExtensions.<Map.Entry<IGrammarConstraintProvider.IConstraint, List<ISerializationContext>>>indexed(contexts);
for (final Pair<Integer, Map.Entry<IGrammarConstraintProvider.IConstraint, List<ISerializationContext>>> ctx : _indexed) {
{
Integer _key = ctx.getKey();
boolean _greaterThan_1 = ((_key).intValue() > 0);
if (_greaterThan_1) {
_builder.append("else ");
}
}
_builder.append("if (");
StringConcatenationClient _genCondition = SerializerFragment2.this.genCondition(ctx.getValue().getValue(), ctx.getValue().getKey(), context2constraint);
_builder.append(_genCondition);
_builder.append(") {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
StringConcatenationClient _genMethodCreateSequenceCall = SerializerFragment2.this.genMethodCreateSequenceCall(superConstraints, type, ctx.getValue().getKey());
_builder.append(_genMethodCreateSequenceCall, "\t");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
}
}
_builder.append("else break;");
_builder.newLine();
} else {
int _size_1 = contexts.size();
boolean _equals = (_size_1 == 1);
if (_equals) {
StringConcatenationClient _genMethodCreateSequenceCall_1 = SerializerFragment2.this.genMethodCreateSequenceCall(superConstraints, type, IterableExtensions.<Map.Entry<IGrammarConstraintProvider.IConstraint, List<ISerializationContext>>>head(contexts).getKey());
_builder.append(_genMethodCreateSequenceCall_1);
_builder.newLineIfNotEmpty();
} else {
_builder.append("// error, no contexts. ");
_builder.newLine();
}
}
}
}
};
_xblockexpression = _client;
}
return _xblockexpression;
}
Aggregations