package jetbrains.mps.kotlin.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.SLinkOperations;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations;
import org.jetbrains.mps.openapi.language.SContainmentLink;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import org.jetbrains.mps.openapi.language.SProperty;

public class FunctionParameter_TextGen extends TextGenDescriptorBase {
  @Override
  public void generateText(final TextGenContext ctx) {
    final TextGenSupport tgs = new TextGenSupport(ctx);
    KotlinTextGen.annotations(ctx.getPrimaryInput(), false, ctx);

    if ((SLinkOperations.getTarget(ctx.getPrimaryInput(), LINKS.modifier$xSnt) != null)) {
      tgs.appendNode(SLinkOperations.getTarget(ctx.getPrimaryInput(), LINKS.modifier$xSnt));
      tgs.append(" ");
    }

    if (SPropertyOperations.getBoolean(ctx.getPrimaryInput(), PROPS.isVararg$GaYv)) {
      tgs.append("vararg ");
    }

    KotlinTextGen.identifier(ctx.getPrimaryInput(), ctx);
    tgs.append(":");
    tgs.appendNode(SLinkOperations.getTarget(ctx.getPrimaryInput(), LINKS.type$1aXr));

    if ((SLinkOperations.getTarget(ctx.getPrimaryInput(), LINKS.defaultValue$1bcs) != null)) {
      tgs.append("=");
      tgs.appendNode(SLinkOperations.getTarget(ctx.getPrimaryInput(), LINKS.defaultValue$1bcs));
    }
  }

  private static final class LINKS {
    /*package*/ static final SContainmentLink modifier$xSnt = MetaAdapterFactory.getContainmentLink(0x6b3888c1980244d8L, 0x8baff8e6c33ed689L, 0x28bef6d7551af405L, 0x28bef6d7551af6c8L, "modifier");
    /*package*/ static final SContainmentLink type$1aXr = MetaAdapterFactory.getContainmentLink(0x6b3888c1980244d8L, 0x8baff8e6c33ed689L, 0x63c34deca4888fe2L, 0x63c34deca4888fe3L, "type");
    /*package*/ static final SContainmentLink defaultValue$1bcs = MetaAdapterFactory.getContainmentLink(0x6b3888c1980244d8L, 0x8baff8e6c33ed689L, 0x63c34deca4888fe2L, 0x63c34deca4888fe4L, "defaultValue");
  }

  private static final class PROPS {
    /*package*/ static final SProperty isVararg$GaYv = MetaAdapterFactory.getProperty(0x6b3888c1980244d8L, 0x8baff8e6c33ed689L, 0x63c34deca4888fe2L, 0x2a5d340976790b94L, "isVararg");
  }
}
