package jetbrains.mps.lang.editor.menus.substitute.testLanguage.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.substitute.ConstraintsFilteringSubstituteMenuPartDecorator; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.lang.editor.menus.substitute.WrapperSubstituteMenuPart; import jetbrains.mps.editor.runtime.menus.SubstituteItemFacade; import jetbrains.mps.lang.editor.menus.substitute.SubstituteMenuItemWrapper; import org.jetbrains.mps.openapi.model.SNode; import org.jetbrains.annotations.Nullable; import org.jetbrains.mps.openapi.language.SAbstractConcept; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SConceptOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; import jetbrains.mps.openapi.editor.menus.substitute.SubstituteMenuLookup; import jetbrains.mps.openapi.editor.EditorContext; import jetbrains.mps.lang.editor.menus.substitute.DefaultSubstituteMenuLookup; import jetbrains.mps.smodel.language.LanguageRegistry; public class TestSubstitituteWrapper_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 ConstraintsFilteringSubstituteMenuPartDecorator(new TestSubstitituteWrapper_SubstituteMenu.SMP_Wrap_9l3s43_a(), MetaAdapterFactory.getConcept(0xcb6d57037c8e46a9L, 0xb993c1373dc0942fL, 0x401156263ff3470bL, "jetbrains.mps.lang.editor.menus.substitute.testLanguage.structure.TestSubstitituteWrapper"))); result.add(new ConstraintsFilteringSubstituteMenuPartDecorator(new TestSubstitituteWrapper_SubstituteMenu.SMP_Wrap_9l3s43_b(), MetaAdapterFactory.getConcept(0xcb6d57037c8e46a9L, 0xb993c1373dc0942fL, 0x401156263ff3470bL, "jetbrains.mps.lang.editor.menus.substitute.testLanguage.structure.TestSubstitituteWrapper"))); return result; } private class SMP_Wrap_9l3s43_a extends WrapperSubstituteMenuPart { @NotNull @Override protected SubstituteMenuItem wrapItem(final SubstituteMenuItem item, final SubstituteMenuContext _context) { final SubstituteItemFacade wrappedItem = new SubstituteItemFacade(item); return new SubstituteMenuItemWrapper(item) { private SNode myCreatedNode; @Nullable @Override public SAbstractConcept getOutputConcept() { return MetaAdapterFactory.getConcept(0xcb6d57037c8e46a9L, 0xb993c1373dc0942fL, 0x401156263ff3470bL, "jetbrains.mps.lang.editor.menus.substitute.testLanguage.structure.TestSubstitituteWrapper"); } @Nullable @Override public SNode createNode(@NotNull String pattern) { SNode nodeToWrap = super.createNode(pattern); myCreatedNode = nodeToWrap; SNode wrapper = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xcb6d57037c8e46a9L, 0xb993c1373dc0942fL, 0x401156263ff3470bL, "jetbrains.mps.lang.editor.menus.substitute.testLanguage.structure.TestSubstitituteWrapper")); SLinkOperations.setTarget(wrapper, MetaAdapterFactory.getContainmentLink(0xcb6d57037c8e46a9L, 0xb993c1373dc0942fL, 0x401156263ff3470bL, 0x401156263ff3470fL, "child"), nodeToWrap); SPropertyOperations.set(wrapper, MetaAdapterFactory.getProperty(0xcb6d57037c8e46a9L, 0xb993c1373dc0942fL, 0x401156263ff3470bL, 0x52ae9daefcc45c00L, "wrappedMatchingText"), wrappedItem.getMatchingText(pattern)); SPropertyOperations.set(wrapper, MetaAdapterFactory.getProperty(0xcb6d57037c8e46a9L, 0xb993c1373dc0942fL, 0x401156263ff3470bL, 0x52ae9daefcc45c02L, "wrappedDescriptionText"), wrappedItem.getDescriptionText(pattern)); return wrapper; } @Override public void select(@NotNull SNode createdNode, @NotNull String pattern) { super.select(myCreatedNode, pattern); } @Override public boolean canExecute(@NotNull String pattern) { return canExecute_internal(pattern, false); } @Override public boolean canExecuteStrictly(@NotNull String pattern) { return canExecute_internal(pattern, true); } public boolean canExecute_internal(@NotNull String pattern, boolean strictly) { String string = wrappedItem.getMatchingText(pattern) + " wrapper matching text"; if (strictly) { return string.equals(pattern); } else { return string.startsWith(pattern); } } @Nullable @Override public String getMatchingText(@NotNull String pattern) { return wrappedItem.getMatchingText(pattern) + " wrapper matching text"; } @Nullable @Override public String getDescriptionText(@NotNull String pattern) { return wrappedItem.getDescriptionText(pattern) + " wrapper description text"; } }; } @Nullable @Override protected SubstituteMenuLookup getLookup(SubstituteMenuContext _context) { final EditorContext editorContext = _context.getEditorContext(); return new DefaultSubstituteMenuLookup(LanguageRegistry.getInstance(editorContext.getRepository()), MetaAdapterFactory.getConcept(0xcb6d57037c8e46a9L, 0xb993c1373dc0942fL, 0x401156263ff3470cL, "jetbrains.mps.lang.editor.menus.substitute.testLanguage.structure.TestSubstitituteChildOfWrapper")); } } private class SMP_Wrap_9l3s43_b extends WrapperSubstituteMenuPart { @NotNull @Override protected SubstituteMenuItem wrapItem(final SubstituteMenuItem item, final SubstituteMenuContext _context) { final SubstituteItemFacade wrappedItem = new SubstituteItemFacade(item); return new SubstituteMenuItemWrapper(item) { private SNode myCreatedNode; @Nullable @Override public SAbstractConcept getOutputConcept() { return MetaAdapterFactory.getConcept(0xcb6d57037c8e46a9L, 0xb993c1373dc0942fL, 0x401156263ff3470bL, "jetbrains.mps.lang.editor.menus.substitute.testLanguage.structure.TestSubstitituteWrapper"); } @Nullable @Override public SNode createNode(@NotNull String pattern) { SNode nodeToWrap = super.createNode(pattern); myCreatedNode = nodeToWrap; SNode wrapper = SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0xcb6d57037c8e46a9L, 0xb993c1373dc0942fL, 0x401156263ff3470bL, "jetbrains.mps.lang.editor.menus.substitute.testLanguage.structure.TestSubstitituteWrapper")); SLinkOperations.setTarget(wrapper, MetaAdapterFactory.getContainmentLink(0xcb6d57037c8e46a9L, 0xb993c1373dc0942fL, 0x401156263ff3470bL, 0x401156263ff3470fL, "child"), nodeToWrap); SPropertyOperations.set(wrapper, MetaAdapterFactory.getProperty(0xcb6d57037c8e46a9L, 0xb993c1373dc0942fL, 0x401156263ff3470bL, 0x52ae9daefcc45c05L, "wrappedConceptAlias"), SConceptOperations.conceptAlias(wrappedItem.getOutputConcept())); return wrapper; } @Override public void select(@NotNull SNode createdNode, @NotNull String pattern) { super.select(myCreatedNode, pattern); } @Override public boolean canExecute(@NotNull String pattern) { return canExecute_internal(pattern, false); } @Override public boolean canExecuteStrictly(@NotNull String pattern) { return canExecute_internal(pattern, true); } public boolean canExecute_internal(@NotNull String pattern, boolean strictly) { String matchingText = SConceptOperations.conceptAlias(wrappedItem.getOutputConcept()) + " wrapper matching text"; if (strictly) { return matchingText.equals(pattern); } else { return matchingText.startsWith(pattern); } } @Nullable @Override public String getMatchingText(@NotNull String pattern) { return SConceptOperations.conceptAlias(wrappedItem.getOutputConcept()) + " wrapper matching text"; } @Nullable @Override public String getDescriptionText(@NotNull String pattern) { return SConceptOperations.conceptAlias(wrappedItem.getOutputConcept()) + " wrapper description text"; } }; } @Nullable @Override protected SubstituteMenuLookup getLookup(SubstituteMenuContext _context) { final EditorContext editorContext = _context.getEditorContext(); return new DefaultSubstituteMenuLookup(LanguageRegistry.getInstance(editorContext.getRepository()), MetaAdapterFactory.getConcept(0xcb6d57037c8e46a9L, 0xb993c1373dc0942fL, 0x401156263ff3470cL, "jetbrains.mps.lang.editor.menus.substitute.testLanguage.structure.TestSubstitituteChildOfWrapper")); } } }