package jetbrains.mps.baseLanguage.editor;

/*Generated by MPS */

import jetbrains.mps.editor.runtime.style.ParametersInformation;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.openapi.editor.EditorContext;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations;
import java.util.ArrayList;
import jetbrains.mps.editor.runtime.style.StyledTextPrinter;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.lang.core.behavior.BaseConcept__BehaviorDescriptor;
import org.jetbrains.mps.openapi.language.SReferenceLink;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import org.jetbrains.mps.openapi.language.SContainmentLink;
import org.jetbrains.mps.openapi.language.SConcept;

public class ClassifierType_ParameterDeclarationQuery implements ParametersInformation<SNode> {
  public ClassifierType_ParameterDeclarationQuery() {
  }
  public Iterable<SNode> getMethods(SNode node, EditorContext editorContext) {
    if (ListSequence.fromList(SLinkOperations.getChildren(SLinkOperations.getTarget(node, LINKS.classifier$cxMr), LINKS.typeVariableDeclaration$Lipp)).isNotEmpty()) {
      return ListSequence.fromListAndArray(new ArrayList<SNode>(), SLinkOperations.getTarget(node, LINKS.classifier$cxMr));
    } else {
      return ListSequence.fromList(new ArrayList<SNode>());
    }
  }
  public void getStyledMethodPresentation(SNode node, EditorContext editorContext, SNode parameterObject, StyledTextPrinter styledText) {
    if (ListSequence.fromList(SLinkOperations.getChildren(parameterObject, LINKS.typeVariableDeclaration$Lipp)).isNotEmpty()) {
      SNode argument = editorContext.getSelectedNode();
      while (argument != null && !(SNodeOperations.isInstanceOf(argument, CONCEPTS.Type$bu) && ListSequence.fromList(SLinkOperations.getChildren(node, LINKS.parameter$oqG$)).contains(SNodeOperations.cast(argument, CONCEPTS.Type$bu)))) {
        argument = SNodeOperations.getParent(argument);
      }
      for (SNode param : SLinkOperations.getChildren(parameterObject, LINKS.typeVariableDeclaration$Lipp)) {
        if (SNodeOperations.getIndexInParent(param) > 0) {
          styledText.append(", ");
        }
        if (SNodeOperations.getIndexInParent(param) == SNodeOperations.getIndexInParent(argument)) {
          styledText.setBold(true);
        }
        styledText.append(BaseConcept__BehaviorDescriptor.getPresentation_idhEwIMiw.invoke(param));
        styledText.setBold(false);
      }
    }
  }
  public boolean isMethodCurrent(SNode node, EditorContext editorContext, SNode parameterObject) {
    return false;
  }

  private static final class LINKS {
    /*package*/ static final SReferenceLink classifier$cxMr = MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, 0x101de490babL, "classifier");
    /*package*/ static final SContainmentLink typeVariableDeclaration$Lipp = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x102463b447aL, 0x102463bb98eL, "typeVariableDeclaration");
    /*package*/ static final SContainmentLink parameter$oqG$ = MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, 0x102419671abL, "parameter");
  }

  private static final class CONCEPTS {
    /*package*/ static final SConcept Type$bu = MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c37f506dL, "jetbrains.mps.baseLanguage.structure.Type");
  }
}
