package jetbrains.mps.baseLanguage.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.util.Computable; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; 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.internal.collections.runtime.Sequence; import jetbrains.mps.baseLanguage.scopes.ClassifierScopes; import jetbrains.mps.internal.collections.runtime.IWhereFilter; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; 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.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.smodel.presentation.NodePresentationUtil; import jetbrains.mps.smodel.runtime.IconResource; import jetbrains.mps.smodel.runtime.IconResourceUtil; import jetbrains.mps.baseLanguage.behavior.Classifier__BehaviorDescriptor; import jetbrains.mps.lang.editor.menus.substitute.SimpleConceptSubstituteMenuPart; import jetbrains.mps.lang.editor.menus.ConceptMenusPart; import java.util.Collection; import jetbrains.mps.smodel.ConceptDescendantsCache; import org.jetbrains.mps.openapi.language.SAbstractConcept; import jetbrains.mps.lang.editor.menus.substitute.DefaultSubstituteMenuLookup; import jetbrains.mps.smodel.language.LanguageRegistry; public class ClassifierType_SubstituteMenu extends SubstituteMenuBase { @NotNull @Override protected List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> getParts(final SubstituteMenuContext _context) { List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> result = new ArrayList<MenuPart<SubstituteMenuItem, SubstituteMenuContext>>(); result.add(new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a()); return result; } public class SMP_Group_6wdawe_a extends GroupMenuPart<SubstituteMenuItem, SubstituteMenuContext> { private boolean condition; private boolean condition_1; private boolean condition_2; @Override protected void initialize(SubstituteMenuContext _context) { super.initialize(_context); condition = new Computable<Boolean>() { public Boolean compute() { return SNodeOperations.isInstanceOf(_context.getParentNode(), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, "jetbrains.mps.baseLanguage.structure.ClassConcept")) && eq_6wdawe_a0a0a0a0a0a1a3b(_context.getLink(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, 0x10f6353296dL, "superclass")); } }.compute(); condition_1 = new Computable<Boolean>() { public Boolean compute() { return SNodeOperations.isInstanceOf(_context.getParentNode(), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, "jetbrains.mps.baseLanguage.structure.ClassConcept")) && eq_6wdawe_a0a0a0a0a0a2a3b(_context.getLink(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, 0xff2ac0b419L, "implementedInterface")); } }.compute(); condition_2 = new Computable<Boolean>() { public Boolean compute() { return SNodeOperations.isInstanceOf(_context.getParentNode(), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101edd46144L, "jetbrains.mps.baseLanguage.structure.Interface")) && eq_6wdawe_a0a0a0a0a0a3a3b(_context.getLink(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101edd46144L, 0x101eddadad7L, "extendedInterface")); } }.compute(); } @Override protected List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> getParts() { return Arrays.<MenuPart<SubstituteMenuItem, SubstituteMenuContext>>asList(new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a.SMP_Group_6wdawe_a0(), new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a.SMP_Group_6wdawe_b0(), new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a.SMP_Group_6wdawe_c0(), new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a.SMP_Group_6wdawe_d0()); } public class SMP_Group_6wdawe_a0 extends GroupMenuPart<SubstituteMenuItem, SubstituteMenuContext> { @Override protected boolean isApplicable(SubstituteMenuContext _context) { return condition; } @Override protected List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> getParts() { return Arrays.<MenuPart<SubstituteMenuItem, SubstituteMenuContext>>asList(new ConstraintsFilteringSubstituteMenuPartDecorator(new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a.SMP_Group_6wdawe_a0.SMP_Param_6wdawe_a0a(), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType"))); } private class SMP_Param_6wdawe_a0a extends ParameterizedMenuPart<SNode, SubstituteMenuItem, SubstituteMenuContext> { @NotNull @Override protected List<SubstituteMenuItem> createItems(SNode parameter, SubstituteMenuContext context) { return new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a.SMP_Group_6wdawe_a0.SMP_Param_6wdawe_a0a.SMP_Action_6wdawe_a0a0(parameter).createItems(context); } @Nullable @Override protected Iterable<? extends SNode> getParameters(SubstituteMenuContext _context) { return (List<SNode>) Sequence.fromIterable(ClassifierScopes.getVisibleClassesScope(_context.getParentNode()).getAvailableElements(null)).where(new IWhereFilter<SNode>() { public boolean accept(SNode it) { return !(SPropertyOperations.getBoolean(SNodeOperations.cast(it, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, "jetbrains.mps.baseLanguage.structure.ClassConcept")), MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, 0x11c6af4b284L, "isFinal"))); } }).toListSequence(); } private class SMP_Action_6wdawe_a0a0 extends SingleItemSubstituteMenuPart { private final SNode myParameterObject; public SMP_Action_6wdawe_a0a0(SNode parameterObject) { myParameterObject = parameterObject; } @Nullable @Override protected SubstituteMenuItem createItem(SubstituteMenuContext _context) { return new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a.SMP_Group_6wdawe_a0.SMP_Param_6wdawe_a0a.SMP_Action_6wdawe_a0a0.Item(_context); } private class Item extends DefaultSubstituteMenuItem { private final SubstituteMenuContext _context; public Item(SubstituteMenuContext context) { super(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType"), context.getParentNode(), context.getCurrentTargetNode(), context.getEditorContext()); _context = context; } @Nullable @Override public SNode createNode(@NotNull String pattern) { SNode result = SNodeFactoryOperations.createNewNode(SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType")), null); SLinkOperations.setTarget(result, MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, 0x101de490babL, "classifier"), myParameterObject); return result; } @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; } @Nullable @Override public String getMatchingText(@NotNull String pattern) { return (String) Classifier__BehaviorDescriptor.getNestedNameInContext_id7q4lzBFjvF8.invoke(myParameterObject, _context.getCurrentTargetNode()); } } } } } public class SMP_Group_6wdawe_b0 extends GroupMenuPart<SubstituteMenuItem, SubstituteMenuContext> { @Override protected boolean isApplicable(SubstituteMenuContext _context) { return condition_1; } @Override protected List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> getParts() { return Arrays.<MenuPart<SubstituteMenuItem, SubstituteMenuContext>>asList(new ConstraintsFilteringSubstituteMenuPartDecorator(new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a.SMP_Group_6wdawe_b0.SMP_Param_6wdawe_a1a(), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType"))); } private class SMP_Param_6wdawe_a1a extends ParameterizedMenuPart<SNode, SubstituteMenuItem, SubstituteMenuContext> { @NotNull @Override protected List<SubstituteMenuItem> createItems(SNode parameter, SubstituteMenuContext context) { return new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a.SMP_Group_6wdawe_b0.SMP_Param_6wdawe_a1a.SMP_Action_6wdawe_a0b0(parameter).createItems(context); } @Nullable @Override protected Iterable<? extends SNode> getParameters(SubstituteMenuContext _context) { return (List<SNode>) Sequence.fromIterable(ClassifierScopes.getVisibleInterfacesScope(_context.getParentNode()).getAvailableElements(null)).toListSequence(); } private class SMP_Action_6wdawe_a0b0 extends SingleItemSubstituteMenuPart { private final SNode myParameterObject; public SMP_Action_6wdawe_a0b0(SNode parameterObject) { myParameterObject = parameterObject; } @Nullable @Override protected SubstituteMenuItem createItem(SubstituteMenuContext _context) { return new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a.SMP_Group_6wdawe_b0.SMP_Param_6wdawe_a1a.SMP_Action_6wdawe_a0b0.Item(_context); } private class Item extends DefaultSubstituteMenuItem { private final SubstituteMenuContext _context; public Item(SubstituteMenuContext context) { super(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType"), context.getParentNode(), context.getCurrentTargetNode(), context.getEditorContext()); _context = context; } @Nullable @Override public SNode createNode(@NotNull String pattern) { SNode result = SNodeFactoryOperations.createNewNode(SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType")), null); SLinkOperations.setTarget(result, MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, 0x101de490babL, "classifier"), myParameterObject); return result; } @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; } @Nullable @Override public String getMatchingText(@NotNull String pattern) { return (String) Classifier__BehaviorDescriptor.getNestedNameInContext_id7q4lzBFjvF8.invoke(myParameterObject, _context.getCurrentTargetNode()); } } } } } public class SMP_Group_6wdawe_c0 extends GroupMenuPart<SubstituteMenuItem, SubstituteMenuContext> { @Override protected boolean isApplicable(SubstituteMenuContext _context) { return condition_2; } @Override protected List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> getParts() { return Arrays.<MenuPart<SubstituteMenuItem, SubstituteMenuContext>>asList(new ConstraintsFilteringSubstituteMenuPartDecorator(new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a.SMP_Group_6wdawe_c0.SMP_Param_6wdawe_a2a(), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType"))); } private class SMP_Param_6wdawe_a2a extends ParameterizedMenuPart<SNode, SubstituteMenuItem, SubstituteMenuContext> { @NotNull @Override protected List<SubstituteMenuItem> createItems(SNode parameter, SubstituteMenuContext context) { return new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a.SMP_Group_6wdawe_c0.SMP_Param_6wdawe_a2a.SMP_Action_6wdawe_a0c0(parameter).createItems(context); } @Nullable @Override protected Iterable<? extends SNode> getParameters(SubstituteMenuContext _context) { return (List<SNode>) Sequence.fromIterable(ClassifierScopes.getVisibleInterfacesScope(_context.getParentNode()).getAvailableElements(null)).toListSequence(); } private class SMP_Action_6wdawe_a0c0 extends SingleItemSubstituteMenuPart { private final SNode myParameterObject; public SMP_Action_6wdawe_a0c0(SNode parameterObject) { myParameterObject = parameterObject; } @Nullable @Override protected SubstituteMenuItem createItem(SubstituteMenuContext _context) { return new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a.SMP_Group_6wdawe_c0.SMP_Param_6wdawe_a2a.SMP_Action_6wdawe_a0c0.Item(_context); } private class Item extends DefaultSubstituteMenuItem { private final SubstituteMenuContext _context; public Item(SubstituteMenuContext context) { super(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType"), context.getParentNode(), context.getCurrentTargetNode(), context.getEditorContext()); _context = context; } @Nullable @Override public SNode createNode(@NotNull String pattern) { SNode result = SNodeFactoryOperations.createNewNode(SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType")), null); SLinkOperations.setTarget(result, MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, 0x101de490babL, "classifier"), myParameterObject); return result; } @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; } @Nullable @Override public String getMatchingText(@NotNull String pattern) { return (String) Classifier__BehaviorDescriptor.getNestedNameInContext_id7q4lzBFjvF8.invoke(myParameterObject, _context.getCurrentTargetNode()); } } } } } public class SMP_Group_6wdawe_d0 extends GroupMenuPart<SubstituteMenuItem, SubstituteMenuContext> { @Override protected boolean isApplicable(SubstituteMenuContext _context) { return !((condition || condition_1 || condition_2)) && (_context.getLink() != null || !(SNodeOperations.isInstanceOf(_context.getParentNode(), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8cc56b200L, "jetbrains.mps.baseLanguage.structure.StatementList")))); } @Override protected List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> getParts() { return Arrays.<MenuPart<SubstituteMenuItem, SubstituteMenuContext>>asList(new ClassifierType_SubstituteMenu.SMP_Group_6wdawe_a.SMP_Group_6wdawe_d0.SMP_Subconcepts_6wdawe_a3a(), new ConstraintsFilteringSubstituteMenuPartDecorator(new SimpleConceptSubstituteMenuPart(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType")), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType"))); } public class SMP_Subconcepts_6wdawe_a3a extends ConceptMenusPart<SubstituteMenuItem, SubstituteMenuContext> { protected Collection getConcepts(final SubstituteMenuContext _context) { return ConceptDescendantsCache.getInstance().getDirectDescendants(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, "jetbrains.mps.baseLanguage.structure.ClassifierType")); } @Override protected Collection<SubstituteMenuItem> createItemsForConcept(SubstituteMenuContext context, SAbstractConcept concept) { return context.createItems(new DefaultSubstituteMenuLookup(LanguageRegistry.getInstance(context.getEditorContext().getRepository()), concept)); } } } } private static boolean eq_6wdawe_a0a0a0a0a0a1a3b(Object a, Object b) { return (a != null ? a.equals(b) : a == b); } private static boolean eq_6wdawe_a0a0a0a0a0a2a3b(Object a, Object b) { return (a != null ? a.equals(b) : a == b); } private static boolean eq_6wdawe_a0a0a0a0a0a3a3b(Object a, Object b) { return (a != null ? a.equals(b) : a == b); } }