package jetbrains.mps.lang.pattern.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 java.util.List;
import jetbrains.mps.smodel.action.SNodeFactoryOperations;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.IAttributeDescriptor;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import jetbrains.mps.nodeEditor.cells.EditorCell_Property;
import jetbrains.mps.nodeEditor.cells.PropertyAccessor;
import org.jetbrains.mps.openapi.language.SProperty;
import jetbrains.mps.smodel.legacy.ConceptMetaInfoConverter;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.AttributeOperations;
import org.jetbrains.mps.openapi.language.SReferenceLink;
public class _PatternExpression_KeyMap extends KeyMapImpl {
public _PatternExpression_KeyMap() {
this.setApplicableToEveryModel(false);
KeyMapAction action;
action = new _PatternExpression_KeyMap._PatternExpression_KeyMap_Action0();
this.putAction("any", "_", action);
action = new _PatternExpression_KeyMap._PatternExpression_KeyMap_Action1();
this.putAction("any", "@", action);
action = new _PatternExpression_KeyMap._PatternExpression_KeyMap_Action2();
this.putAction("any", "#", action);
action = new _PatternExpression_KeyMap._PatternExpression_KeyMap_Action3();
this.putAction("any", "$", action);
action = new _PatternExpression_KeyMap._PatternExpression_KeyMap_Action4();
this.putAction("any", "*", action);
action = new _PatternExpression_KeyMap._PatternExpression_KeyMap_Action5();
this.putAction("any", "%", action);
action = new _PatternExpression_KeyMap._PatternExpression_KeyMap_Action6();
this.putAction("any", "*", action);
action = new _PatternExpression_KeyMap._PatternExpression_KeyMap_Action7();
this.putAction("any", "^", action);
}
public static class _PatternExpression_KeyMap_Action0 extends KeyMapActionImpl {
public _PatternExpression_KeyMap_Action0() {
this.setShownInPopupMenu(false);
}
public String getDescriptionText() {
return "create wildcard";
}
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;
}
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 PatternAddingUtil.isPatternApplicable(editorContext);
}
private void execute_internal(final EditorContext editorContext, final SNode node, final List<SNode> selectedNodes) {
SNodeFactoryOperations.setNewAttribute(node, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0xd4615e3bd6714ba9L, 0xaf012b78369b0ba7L, 0x108a9cb478fL, "jetbrains.mps.lang.pattern.structure.Pattern")), SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xd4615e3bd6714ba9L, 0xaf012b78369b0ba7L, 0x108a9cb4797L, "jetbrains.mps.lang.pattern.structure.WildcardPattern")));
}
public String getKeyStroke() {
return " _";
}
}
public static class _PatternExpression_KeyMap_Action1 extends KeyMapActionImpl {
public _PatternExpression_KeyMap_Action1() {
this.setShownInPopupMenu(false);
}
public String getDescriptionText() {
return "create as-pattern";
}
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;
}
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 PatternAddingUtil.isPatternApplicable(editorContext);
}
private void execute_internal(final EditorContext editorContext, final SNode node, final List<SNode> selectedNodes) {
SNodeFactoryOperations.setNewAttribute(node, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0xd4615e3bd6714ba9L, 0xaf012b78369b0ba7L, 0x108a9cb478dL, "jetbrains.mps.lang.pattern.structure.AsPattern")), SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xd4615e3bd6714ba9L, 0xaf012b78369b0ba7L, 0x108a9cb478dL, "jetbrains.mps.lang.pattern.structure.AsPattern")));
}
public String getKeyStroke() {
return " @";
}
}
public static class _PatternExpression_KeyMap_Action2 extends KeyMapActionImpl {
public _PatternExpression_KeyMap_Action2() {
this.setShownInPopupMenu(false);
}
public String getDescriptionText() {
return "create variable pattern";
}
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;
}
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 PatternAddingUtil.isPatternApplicable(editorContext);
}
private void execute_internal(final EditorContext editorContext, final SNode node, final List<SNode> selectedNodes) {
PatternAddingUtil.addVariablePattern(editorContext);
}
public String getKeyStroke() {
return " #";
}
}
public static class _PatternExpression_KeyMap_Action3 extends KeyMapActionImpl {
public _PatternExpression_KeyMap_Action3() {
this.setShownInPopupMenu(false);
}
public String getDescriptionText() {
return "create property var pattern";
}
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;
}
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 (editorContext.getSelectedCell() instanceof EditorCell_Property) && PatternAddingUtil.isPatternApplicable(editorContext);
}
private void execute_internal(final EditorContext editorContext, final SNode node, final List<SNode> selectedNodes) {
EditorCell_Property cell = (EditorCell_Property) editorContext.getSelectedCell();
PropertyAccessor acc = (PropertyAccessor) cell.getModelAccessor();
String propertyName = (acc).getPropertyName();
SProperty p = ((ConceptMetaInfoConverter) cell.getSNode().getConcept()).convertProperty(propertyName);
SNodeFactoryOperations.setNewAttribute(node, new IAttributeDescriptor.PropertyAttribute(MetaAdapterFactory.getConcept(0xd4615e3bd6714ba9L, 0xaf012b78369b0ba7L, 0x108a9cb4795L, "jetbrains.mps.lang.pattern.structure.PropertyPatternVariableDeclaration"), p), SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xd4615e3bd6714ba9L, 0xaf012b78369b0ba7L, 0x108a9cb4795L, "jetbrains.mps.lang.pattern.structure.PropertyPatternVariableDeclaration")));
}
public String getKeyStroke() {
return " $";
}
}
public static class _PatternExpression_KeyMap_Action4 extends KeyMapActionImpl {
public _PatternExpression_KeyMap_Action4() {
this.setShownInPopupMenu(false);
}
public String getDescriptionText() {
return "create list pattern";
}
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;
}
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 PatternAddingUtil.isPatternApplicable(editorContext) && SNodeOperations.getParent(node) != null;
}
private void execute_internal(final EditorContext editorContext, final SNode node, final List<SNode> selectedNodes) {
List<SNode> siblings = SNodeOperations.getAllSiblings(node, false);
SNodeFactoryOperations.setNewAttribute(node, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0xd4615e3bd6714ba9L, 0xaf012b78369b0ba7L, 0x108a9cb478dL, "jetbrains.mps.lang.pattern.structure.AsPattern")), SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xd4615e3bd6714ba9L, 0xaf012b78369b0ba7L, 0x108aa36731aL, "jetbrains.mps.lang.pattern.structure.ListPattern")));
for (SNode sibling : siblings) {
SNodeOperations.deleteNode(sibling);
}
}
public String getKeyStroke() {
return " *";
}
}
public static class _PatternExpression_KeyMap_Action5 extends KeyMapActionImpl {
public _PatternExpression_KeyMap_Action5() {
this.setShownInPopupMenu(false);
}
public String getDescriptionText() {
return "antiquotation";
}
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;
}
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 true;
}
private void execute_internal(final EditorContext editorContext, final SNode node, final List<SNode> selectedNodes) {
SNode contextNode = editorContext.getSelectedCell().getSNode();
if (contextNode == null) {
return;
}
if (AttributeOperations.getAttribute(contextNode, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c104658L, "jetbrains.mps.lang.quotation.structure.Antiquotation"))) != null) {
AttributeOperations.setAttribute(contextNode, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c104658L, "jetbrains.mps.lang.quotation.structure.Antiquotation")), null);
} else
SNodeFactoryOperations.setNewAttribute(contextNode, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c104658L, "jetbrains.mps.lang.quotation.structure.Antiquotation")), SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c104658L, "jetbrains.mps.lang.quotation.structure.Antiquotation")));
}
public String getKeyStroke() {
return " %";
}
}
public static class _PatternExpression_KeyMap_Action6 extends KeyMapActionImpl {
public _PatternExpression_KeyMap_Action6() {
this.setShownInPopupMenu(false);
}
public String getDescriptionText() {
return "list antiquotation";
}
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;
}
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 true;
}
private void execute_internal(final EditorContext editorContext, final SNode node, final List<SNode> selectedNodes) {
SNode contextNode = editorContext.getSelectedCell().getSNode();
if (contextNode == null) {
return;
}
if (SNodeOperations.isInstanceOf(contextNode, MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c10465eL, "jetbrains.mps.lang.quotation.structure.ListAntiquotation"))) {
SNode attributedNode = SNodeOperations.getParent(contextNode);
assert attributedNode != null;
AttributeOperations.setAttribute(attributedNode, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c10465eL, "jetbrains.mps.lang.quotation.structure.ListAntiquotation")), null);
return;
}
if ((AttributeOperations.getAttribute(contextNode, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c10465eL, "jetbrains.mps.lang.quotation.structure.ListAntiquotation"))) != null)) {
AttributeOperations.setAttribute(contextNode, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c10465eL, "jetbrains.mps.lang.quotation.structure.ListAntiquotation")), null);
} else
SNodeFactoryOperations.setNewAttribute(contextNode, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c10465eL, "jetbrains.mps.lang.quotation.structure.ListAntiquotation")), SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c10465eL, "jetbrains.mps.lang.quotation.structure.ListAntiquotation")));
}
public String getKeyStroke() {
return " *";
}
}
public static class _PatternExpression_KeyMap_Action7 extends KeyMapActionImpl {
public _PatternExpression_KeyMap_Action7() {
this.setShownInPopupMenu(false);
}
public String getDescriptionText() {
return "reference antiquotation";
}
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;
}
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 true;
}
private void execute_internal(final EditorContext editorContext, final SNode node, final List<SNode> selectedNodes) {
EditorCell selectedCell = editorContext.getSelectedCell();
SNode contextNode = selectedCell.getSNode();
if (contextNode == null) {
return;
}
if (!(selectedCell.isReferenceCell())) {
return;
}
String role = selectedCell.getRole();
SReferenceLink ref = ((ConceptMetaInfoConverter) SNodeOperations.getConcept(contextNode)).convertAssociation(role);
if (SNodeOperations.isInstanceOf(contextNode, MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c10465dL, "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"))) {
SNode attributedNode = SNodeOperations.cast(SNodeOperations.getParent(contextNode), MetaAdapterFactory.getConcept(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x10802efe25aL, "jetbrains.mps.lang.core.structure.BaseConcept"));
assert attributedNode != null;
AttributeOperations.setAttribute(attributedNode, new IAttributeDescriptor.LinkAttribute(MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c10465dL, "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"), ref), null);
return;
}
if (AttributeOperations.getAttribute(contextNode, new IAttributeDescriptor.LinkAttribute(MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c10465dL, "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"), ref)) != null) {
AttributeOperations.setAttribute(contextNode, new IAttributeDescriptor.LinkAttribute(MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c10465dL, "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"), ref), null);
} else {
SNodeFactoryOperations.setNewAttribute(contextNode, new IAttributeDescriptor.LinkAttribute(MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c10465dL, "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation"), ref), SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0x3a13115c633c4c5cL, 0xbbcc75c4219e9555L, 0x1168c10465dL, "jetbrains.mps.lang.quotation.structure.ReferenceAntiquotation")));
}
}
public String getKeyStroke() {
return " ^";
}
}
}