package jetbrains.mps.lang.behavior.editor;
/*Generated by MPS */
import jetbrains.mps.nodeEditor.menus.substitute.SubstituteMenuBase;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import jetbrains.mps.lang.editor.menus.MenuPart;
import jetbrains.mps.openapi.editor.menus.substitute.SubstituteMenuItem;
import jetbrains.mps.openapi.editor.menus.substitute.SubstituteMenuContext;
import java.util.ArrayList;
import jetbrains.mps.lang.editor.menus.GroupMenuPart;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import org.jetbrains.mps.openapi.language.SAbstractConcept;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import java.util.Arrays;
import jetbrains.mps.lang.editor.menus.substitute.ConstraintsFilteringSubstituteMenuPartDecorator;
import jetbrains.mps.lang.editor.menus.ParameterizedMenuPart;
import org.jetbrains.mps.openapi.model.SNode;
import org.jetbrains.annotations.Nullable;
import jetbrains.mps.lang.structure.behavior.AbstractConceptDeclaration__BehaviorDescriptor;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations;
import jetbrains.mps.lang.editor.menus.substitute.SingleItemSubstituteMenuPart;
import jetbrains.mps.lang.editor.menus.substitute.DefaultSubstituteMenuItem;
import jetbrains.mps.smodel.action.SNodeFactoryOperations;
import jetbrains.mps.smodel.presentation.NodePresentationUtil;
import jetbrains.mps.smodel.runtime.IconResource;
import jetbrains.mps.smodel.runtime.IconResourceUtil;
public class ConceptMethodsWithoutThis_Contribution extends SubstituteMenuBase {
public ConceptMethodsWithoutThis_Contribution() {
super(true);
}
@NotNull
@Override
protected List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> getParts(final SubstituteMenuContext _context) {
List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> result = new ArrayList<MenuPart<SubstituteMenuItem, SubstituteMenuContext>>();
result.add(new ConceptMethodsWithoutThis_Contribution.SMP_Group_lcxjkp_a());
return result;
}
public class SMP_Group_lcxjkp_a extends GroupMenuPart<SubstituteMenuItem, SubstituteMenuContext> {
@Override
protected boolean isApplicable(SubstituteMenuContext _context) {
return false && SNodeOperations.getNodeAncestorWhereConceptInList(_context.getParentNode(), new SAbstractConcept[]{MetaAdapterFactory.getConcept(0xaf65afd8f0dd4942L, 0x87d963a55f2a9db1L, 0x11d4348057eL, "jetbrains.mps.lang.behavior.structure.ConceptMethodDeclaration"), MetaAdapterFactory.getConcept(0xaf65afd8f0dd4942L, 0x87d963a55f2a9db1L, 0x11d43471eedL, "jetbrains.mps.lang.behavior.structure.ConceptConstructorDeclaration")}, true, false) != null;
}
@Override
protected List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> getParts() {
return Arrays.<MenuPart<SubstituteMenuItem, SubstituteMenuContext>>asList(new ConstraintsFilteringSubstituteMenuPartDecorator(new ConceptMethodsWithoutThis_Contribution.SMP_Group_lcxjkp_a.SMP_Param_lcxjkp_a0(), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x116b46a08c4L, "jetbrains.mps.baseLanguage.structure.DotExpression")));
}
private class SMP_Param_lcxjkp_a0 extends ParameterizedMenuPart<SNode, SubstituteMenuItem, SubstituteMenuContext> {
@NotNull
@Override
protected List<SubstituteMenuItem> createItems(SNode parameter, SubstituteMenuContext context) {
return new ConceptMethodsWithoutThis_Contribution.SMP_Group_lcxjkp_a.SMP_Param_lcxjkp_a0.SMP_Action_lcxjkp_a0a(parameter).createItems(context);
}
@Nullable
@Override
protected Iterable<? extends SNode> getParameters(SubstituteMenuContext _context) {
SNode behavior = SNodeOperations.getNodeAncestor(_context.getParentNode(), MetaAdapterFactory.getConcept(0xaf65afd8f0dd4942L, 0x87d963a55f2a9db1L, 0x11d43447b1aL, "jetbrains.mps.lang.behavior.structure.ConceptBehavior"), true, false);
return AbstractConceptDeclaration__BehaviorDescriptor.getAvailableConceptMethods_idhEwILGo.invoke(SLinkOperations.getTarget(behavior, MetaAdapterFactory.getReferenceLink(0xaf65afd8f0dd4942L, 0x87d963a55f2a9db1L, 0x11d43447b1aL, 0x11d43447b1fL, "concept")), _context.getParentNode());
}
private class SMP_Action_lcxjkp_a0a extends SingleItemSubstituteMenuPart {
private final SNode myParameterObject;
public SMP_Action_lcxjkp_a0a(SNode parameterObject) {
myParameterObject = parameterObject;
}
@Nullable
@Override
protected SubstituteMenuItem createItem(SubstituteMenuContext _context) {
return new ConceptMethodsWithoutThis_Contribution.SMP_Group_lcxjkp_a.SMP_Param_lcxjkp_a0.SMP_Action_lcxjkp_a0a.Item(_context);
}
private class Item extends DefaultSubstituteMenuItem {
private final SubstituteMenuContext _context;
public Item(SubstituteMenuContext context) {
super(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x116b46a08c4L, "jetbrains.mps.baseLanguage.structure.DotExpression"), context.getParentNode(), context.getCurrentTargetNode(), context.getEditorContext());
_context = context;
}
@Nullable
@Override
public SNode createNode(@NotNull String pattern) {
SNode expr = SNodeFactoryOperations.createNewNode(SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x116b46a08c4L, "jetbrains.mps.baseLanguage.structure.DotExpression")), null);
SNodeFactoryOperations.setNewChild(expr, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x116b46a08c4L, 0x116b46a4416L, "operand"), SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xaf65afd8f0dd4942L, 0x87d963a55f2a9db1L, 0x11d434b5be1L, "jetbrains.mps.lang.behavior.structure.ThisNodeExpression")));
SNode call = SNodeFactoryOperations.createNewNode(SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0x7866978ea0f04cc7L, 0x81bc4d213d9375e1L, 0x1129a43046bL, "jetbrains.mps.lang.smodel.structure.Node_ConceptMethodCall")), null);
SLinkOperations.setTarget(call, MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11857355952L, 0xf8c78301adL, "baseMethodDeclaration"), myParameterObject);
SLinkOperations.setTarget(expr, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x116b46a08c4L, 0x116b46b36c4L, "operation"), call);
return expr;
}
@Nullable
@Override
public String getMatchingText(@NotNull String pattern) {
if (myParameterObject instanceof SNode) {
return NodePresentationUtil.visibleMatchingText((SNode) myParameterObject, null);
}
return "" + myParameterObject;
}
@Nullable
@Override
public String getDescriptionText(@NotNull String pattern) {
if (myParameterObject instanceof SNode) {
return NodePresentationUtil.descriptionText((SNode) myParameterObject);
}
return "" + myParameterObject;
}
@Nullable
@Override
public IconResource getIcon(@NotNull String pattern) {
if (myParameterObject instanceof SNode) {
return IconResourceUtil.getIconResourceForNode(((SNode) myParameterObject));
}
return null;
}
}
}
}
}
}