package jetbrains.mps.baseLanguage.textGen;
/*Generated by MPS */
import jetbrains.mps.text.rt.TextGenDescriptorBase;
import jetbrains.mps.text.rt.TextGenContext;
import jetbrains.mps.text.impl.TextGenSupport;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations;
import jetbrains.mps.internal.collections.runtime.Sequence;
import jetbrains.mps.internal.collections.runtime.ListSequence;
public class EnumConstantDeclaration_TextGen extends TextGenDescriptorBase {
@Override
public void generateText(final TextGenContext ctx) {
final TextGenSupport tgs = new TextGenSupport(ctx);
tgs.newLine();
if (isEmptyString(SPropertyOperations.getString(ctx.getPrimaryInput(), MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name")))) {
tgs.reportError("enum constant without name");
tgs.indent();
tgs.append("???");
} else {
tgs.indent();
tgs.append(SPropertyOperations.getString(ctx.getPrimaryInput(), MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name")));
}
tgs.append("(");
{
Iterable<SNode> collection = SLinkOperations.getChildren(ctx.getPrimaryInput(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11857355952L, 0xf8c78301aeL, "actualArgument"));
final SNode lastItem = Sequence.fromIterable(collection).last();
for (SNode item : collection) {
tgs.appendNode(item);
if (item != lastItem) {
tgs.append(", ");
}
}
}
tgs.append(")");
if (ListSequence.fromList(SLinkOperations.getChildren(ctx.getPrimaryInput(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc367388b3L, 0x6d60019ab157734L, "method"))).isNotEmpty()) {
tgs.append(" {");
tgs.newLine();
ctx.getBuffer().area().increaseIndent();
for (SNode imd : SLinkOperations.getChildren(ctx.getPrimaryInput(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc367388b3L, 0x6d60019ab157734L, "method"))) {
tgs.appendNode(imd);
}
ctx.getBuffer().area().decreaseIndent();
tgs.newLine();
tgs.indent();
tgs.append("}");
}
}
private static boolean isEmptyString(String str) {
return str == null || str.length() == 0;
}
}