package jetbrains.mps.baseLanguage.regexp.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.SingleItemSubstituteMenuPart;
import org.jetbrains.annotations.Nullable;
import jetbrains.mps.lang.editor.menus.substitute.DefaultSubstituteMenuItem;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.smodel.action.SNodeFactoryOperations;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations;
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;
import java.util.regex.Pattern;
public class Regexp_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 Regexp_SubstituteMenu.SMP_Action_6gqf7r_a(), MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11831260718L, "jetbrains.mps.baseLanguage.regexp.structure.UnicodeCharacterRegexp")));
result.add(new ConstraintsFilteringSubstituteMenuPartDecorator(new Regexp_SubstituteMenu.SMP_Action_6gqf7r_b(), MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x111797946c7L, "jetbrains.mps.baseLanguage.regexp.structure.MatchParensRegexp")));
result.add(new ConstraintsFilteringSubstituteMenuPartDecorator(new Regexp_SubstituteMenu.SMP_Action_6gqf7r_c(), MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174a0992dL, "jetbrains.mps.baseLanguage.regexp.structure.StringLiteralRegexp")));
result.add(new ConstraintsFilteringSubstituteMenuPartDecorator(new Regexp_SubstituteMenu.SMP_Action_6gqf7r_d(), MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174a0992dL, "jetbrains.mps.baseLanguage.regexp.structure.StringLiteralRegexp")));
result.add(new Regexp_SubstituteMenu.SMP_Subconcepts_6gqf7r_e());
return result;
}
private class SMP_Action_6gqf7r_a extends SingleItemSubstituteMenuPart {
@Nullable
@Override
protected SubstituteMenuItem createItem(SubstituteMenuContext _context) {
return new Regexp_SubstituteMenu.SMP_Action_6gqf7r_a.Item(_context);
}
private class Item extends DefaultSubstituteMenuItem {
private final SubstituteMenuContext _context;
public Item(SubstituteMenuContext context) {
super(MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11831260718L, "jetbrains.mps.baseLanguage.regexp.structure.UnicodeCharacterRegexp"), context.getParentNode(), context.getCurrentTargetNode(), context.getEditorContext());
_context = context;
}
@Nullable
@Override
public SNode createNode(@NotNull String pattern) {
SNode literal = SNodeFactoryOperations.createNewNode(SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11831260718L, "jetbrains.mps.baseLanguage.regexp.structure.UnicodeCharacterRegexp")), null);
SPropertyOperations.set(literal, MetaAdapterFactory.getProperty(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11831260718L, 0x1183127443bL, "code"), pattern.substring(2));
return literal;
}
@Nullable
@Override
public String getMatchingText(@NotNull String pattern) {
return 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) {
return REGEXP_6gqf7r_a0a0a7c1.matcher(pattern).matches();
}
}
}
private class SMP_Action_6gqf7r_b extends SingleItemSubstituteMenuPart {
@Nullable
@Override
protected SubstituteMenuItem createItem(SubstituteMenuContext _context) {
return new Regexp_SubstituteMenu.SMP_Action_6gqf7r_b.Item(_context);
}
private class Item extends DefaultSubstituteMenuItem {
private final SubstituteMenuContext _context;
public Item(SubstituteMenuContext context) {
super(MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x111797946c7L, "jetbrains.mps.baseLanguage.regexp.structure.MatchParensRegexp"), context.getParentNode(), context.getCurrentTargetNode(), context.getEditorContext());
_context = context;
}
@Nullable
@Override
public SNode createNode(@NotNull String pattern) {
SNode node = SNodeFactoryOperations.createNewNode(SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x111797946c7L, "jetbrains.mps.baseLanguage.regexp.structure.MatchParensRegexp")), _context.getCurrentTargetNode());
SPropertyOperations.set(node, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), (pattern.endsWith(":") ? pattern.substring(1, pattern.length() - 1) : ((pattern == null || pattern.length() == 0) ? "" : pattern.substring(1))));
return node;
}
@Nullable
@Override
public String getMatchingText(@NotNull String pattern) {
if (!(REGEXP_6gqf7r_a0a0a0e2c.matcher(pattern).matches())) {
return "(name:";
}
String s = pattern;
if (!(s.endsWith(":"))) {
s += ":";
}
return s;
}
}
}
private class SMP_Action_6gqf7r_c extends SingleItemSubstituteMenuPart {
@Nullable
@Override
protected SubstituteMenuItem createItem(SubstituteMenuContext _context) {
return new Regexp_SubstituteMenu.SMP_Action_6gqf7r_c.Item(_context);
}
private class Item extends DefaultSubstituteMenuItem {
private final SubstituteMenuContext _context;
public Item(SubstituteMenuContext context) {
super(MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174a0992dL, "jetbrains.mps.baseLanguage.regexp.structure.StringLiteralRegexp"), context.getParentNode(), context.getCurrentTargetNode(), context.getEditorContext());
_context = context;
}
@Nullable
@Override
public SNode createNode(@NotNull String pattern) {
SNode literal = SNodeFactoryOperations.createNewNode(SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174a0992dL, "jetbrains.mps.baseLanguage.regexp.structure.StringLiteralRegexp")), null);
SPropertyOperations.set(literal, MetaAdapterFactory.getProperty(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174a0992dL, 0x11174a0b84fL, "text"), pattern);
return literal;
}
@Nullable
@Override
public String getMatchingText(@NotNull String pattern) {
return pattern;
}
@Nullable
@Override
public String getDescriptionText(@NotNull String pattern) {
return "string literal";
}
@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) {
return REGEXP_6gqf7r_a0a0a8c3.matcher(pattern).matches();
}
}
}
private class SMP_Action_6gqf7r_d extends SingleItemSubstituteMenuPart {
@Nullable
@Override
protected SubstituteMenuItem createItem(SubstituteMenuContext _context) {
return new Regexp_SubstituteMenu.SMP_Action_6gqf7r_d.Item(_context);
}
private class Item extends DefaultSubstituteMenuItem {
private final SubstituteMenuContext _context;
public Item(SubstituteMenuContext context) {
super(MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174a0992dL, "jetbrains.mps.baseLanguage.regexp.structure.StringLiteralRegexp"), context.getParentNode(), context.getCurrentTargetNode(), context.getEditorContext());
_context = context;
}
@Nullable
@Override
public SNode createNode(@NotNull String pattern) {
SNode literal = SNodeFactoryOperations.createNewNode(SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174a0992dL, "jetbrains.mps.baseLanguage.regexp.structure.StringLiteralRegexp")), null);
SPropertyOperations.set(literal, MetaAdapterFactory.getProperty(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174a0992dL, 0x11174a0b84fL, "text"), pattern.substring(1));
return literal;
}
@Nullable
@Override
public String getMatchingText(@NotNull String pattern) {
return pattern;
}
@Nullable
@Override
public String getDescriptionText(@NotNull String pattern) {
return "string literal";
}
@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) {
return REGEXP_6gqf7r_a0a0a8c4.matcher(pattern).matches();
}
}
}
public class SMP_Subconcepts_6gqf7r_e extends ConceptMenusPart<SubstituteMenuItem, SubstituteMenuContext> {
protected Collection getConcepts(final SubstituteMenuContext _context) {
return ConceptDescendantsCache.getInstance().getDirectDescendants(MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174a06efdL, "jetbrains.mps.baseLanguage.regexp.structure.Regexp"));
}
@Override
protected Collection<SubstituteMenuItem> createItemsForConcept(SubstituteMenuContext context, SAbstractConcept concept) {
return context.createItems(new DefaultSubstituteMenuLookup(LanguageRegistry.getInstance(context.getEditorContext().getRepository()), concept));
}
}
private static Pattern REGEXP_6gqf7r_a0a0a7c1 = Pattern.compile("\\\\u[\\da-fA-F]{4}", 0);
private static Pattern REGEXP_6gqf7r_a0a0a0e2c = Pattern.compile("\\(\\w+:?", 0);
private static Pattern REGEXP_6gqf7r_a0a0a8c3 = Pattern.compile("[^\\-\\+\\*\\[\\]\\.\\{\\}\\(\\)\\\\\\^'\\$]+", 0);
private static Pattern REGEXP_6gqf7r_a0a0a8c4 = Pattern.compile("^\\\\[\\-\\+\\*\\[\\]\\.\\{\\}\\(\\)\\^'\\$]$", 0);
}