package jetbrains.mps.baseLanguage.editor; /*Generated by MPS */ import jetbrains.mps.editor.runtime.cells.KeyMapImpl; import jetbrains.mps.openapi.editor.cells.KeyMapAction; import jetbrains.mps.editor.runtime.cells.KeyMapActionImpl; import jetbrains.mps.openapi.editor.EditorContext; import jetbrains.mps.openapi.editor.cells.EditorCell; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import java.util.List; import jetbrains.mps.internal.collections.runtime.ListSequence; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.smodel.action.SNodeFactoryOperations; import jetbrains.mps.internal.collections.runtime.Sequence; import jetbrains.mps.baseLanguage.behavior.ClassConcept__BehaviorDescriptor; public class EnumConstants extends KeyMapImpl { public EnumConstants() { this.setApplicableToEveryModel(false); KeyMapAction action; action = new EnumConstants.EnumConstants_Action0(); this.putAction("any", "non-space char", action); } public static class EnumConstants_Action0 extends KeyMapActionImpl { public EnumConstants_Action0() { this.setShownInPopupMenu(false); } public boolean isMenuAlwaysShown() { return false; } public boolean canExecute(final EditorContext editorContext) { EditorCell contextCell = editorContext.getContextCell(); if ((contextCell == null)) { return false; } SNode contextNode = contextCell.getSNode(); if (contextNode == null) { return false; } if (!(SNodeOperations.isInstanceOf(contextNode, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc367070a5L, "jetbrains.mps.baseLanguage.structure.EnumClass")))) { return false; } return this.canExecute_internal(editorContext, contextNode, this.getSelectedNodes(editorContext)); } public void execute(final EditorContext editorContext) { EditorCell contextCell = editorContext.getContextCell(); this.execute_internal(editorContext, contextCell.getSNode(), this.getSelectedNodes(editorContext)); } private boolean canExecute_internal(final EditorContext editorContext, final SNode node, final List<SNode> selectedNodes) { return ListSequence.fromList(SLinkOperations.getChildren(node, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc367070a5L, 0xfc367503acL, "enumConstant"))).isEmpty(); } private void execute_internal(final EditorContext editorContext, final SNode node, final List<SNode> selectedNodes) { SNode constant = SNodeFactoryOperations.createNewNode(SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc367388b3L, "jetbrains.mps.baseLanguage.structure.EnumConstantDeclaration")), null); SNode constructor = Sequence.fromIterable(ClassConcept__BehaviorDescriptor.constructors_id4_LVZ3pCvsd.invoke(node)).first(); if ((constructor == null)) { constructor = Sequence.fromIterable(ClassConcept__BehaviorDescriptor.constructors_id4_LVZ3pCvsd.invoke(SNodeOperations.getNode("6354ebe7-c22a-4a0f-ac54-50b52ab9b065/java:java.lang(JDK/)", "~Object"))).first(); } SLinkOperations.setTarget(constant, MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11857355952L, 0xf8c78301adL, "baseMethodDeclaration"), constructor); ListSequence.fromList(SLinkOperations.getChildren(node, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfc367070a5L, 0xfc367503acL, "enumConstant"))).addElement(constant); } public String getKeyStroke() { return "any non-space char"; } } }