package jetbrains.mps.baseLanguage.regexp.behavior;
/*Generated by MPS */
import jetbrains.mps.core.aspects.behaviour.BaseBHDescriptor;
import org.jetbrains.mps.openapi.language.SAbstractConcept;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import jetbrains.mps.core.aspects.behaviour.api.BehaviorRegistry;
import jetbrains.mps.smodel.language.ConceptRegistry;
import jetbrains.mps.core.aspects.behaviour.api.SMethod;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.core.aspects.behaviour.SMethodBuilder;
import jetbrains.mps.core.aspects.behaviour.SJavaCompoundTypeImpl;
import jetbrains.mps.core.aspects.behaviour.SModifiersImpl;
import jetbrains.mps.core.aspects.behaviour.AccessPrivileges;
import java.util.List;
import java.util.Arrays;
import org.jetbrains.annotations.NotNull;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import java.util.ArrayList;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SConceptOperations;
import java.util.regex.Pattern;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import jetbrains.mps.core.aspects.behaviour.api.SConstructor;
import org.jetbrains.annotations.Nullable;
import jetbrains.mps.core.aspects.behaviour.api.BHMethodNotFoundException;
public final class Regexp__BehaviorDescriptor extends BaseBHDescriptor {
private static final SAbstractConcept CONCEPT = MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174a06efdL, "jetbrains.mps.baseLanguage.regexp.structure.Regexp");
private static final BehaviorRegistry REGISTRY = ConceptRegistry.getInstance().getBehaviorRegistry();
public static final SMethod<SNode> getTopLevelRegexp_idhNm6Oh5 = new SMethodBuilder<SNode>(new SJavaCompoundTypeImpl((Class<SNode>) ((Class) Object.class))).name("getTopLevelRegexp").modifiers(SModifiersImpl.create(0, AccessPrivileges.PUBLIC)).concept(CONCEPT).id("hNm6Oh5").registry(REGISTRY).build();
public static final SMethod<String> toString_idhEwIUjb = new SMethodBuilder<String>(new SJavaCompoundTypeImpl(String.class)).name("toString").modifiers(SModifiersImpl.create(8, AccessPrivileges.PUBLIC)).concept(CONCEPT).id("hEwIUjb").registry(REGISTRY).build();
public static final SMethod<String> getString_idhMuDF1A = new SMethodBuilder<String>(new SJavaCompoundTypeImpl(String.class)).name("getString").modifiers(SModifiersImpl.create(8, AccessPrivileges.PUBLIC)).concept(CONCEPT).id("hMuDF1A").registry(REGISTRY).build(SMethodBuilder.createJavaParameter((Class<List<SNode>>) ((Class) Object.class), ""));
public static final SMethod<String> par_idhMuIPHY = new SMethodBuilder<String>(new SJavaCompoundTypeImpl(String.class)).name("par").modifiers(SModifiersImpl.create(0, AccessPrivileges.PROTECTED)).concept(CONCEPT).id("hMuIPHY").registry(REGISTRY).build(SMethodBuilder.createJavaParameter(String.class, ""));
public static final SMethod<Boolean> checkStringForUnicode_idhMRXRyL = new SMethodBuilder<Boolean>(new SJavaCompoundTypeImpl(Boolean.TYPE)).name("checkStringForUnicode").modifiers(SModifiersImpl.create(0, AccessPrivileges.PROTECTED)).concept(CONCEPT).id("hMRXRyL").registry(REGISTRY).build(SMethodBuilder.createJavaParameter(String.class, ""));
public static final SMethod<String> quote_idhMRXVXe = new SMethodBuilder<String>(new SJavaCompoundTypeImpl(String.class)).name("quote").modifiers(SModifiersImpl.create(0, AccessPrivileges.PROTECTED)).concept(CONCEPT).id("hMRXVXe").registry(REGISTRY).build(SMethodBuilder.createJavaParameter(Character.TYPE, ""));
public static final SMethod<String> escape_id1b8uQvZ_lG7 = new SMethodBuilder<String>(new SJavaCompoundTypeImpl(String.class)).name("escape").modifiers(SModifiersImpl.create(0, AccessPrivileges.PROTECTED)).concept(CONCEPT).id("1b8uQvZ_lG7").registry(REGISTRY).build(SMethodBuilder.createJavaParameter(String.class, ""));
public static final SMethod<Boolean> needParentheses_id1b8uQvZynii = new SMethodBuilder<Boolean>(new SJavaCompoundTypeImpl(Boolean.TYPE)).name("needParentheses").modifiers(SModifiersImpl.create(8, AccessPrivileges.PUBLIC)).concept(CONCEPT).id("1b8uQvZynii").registry(REGISTRY).build();
public static final SMethod<Boolean> isValid_id48bMILtL4il = new SMethodBuilder<Boolean>(new SJavaCompoundTypeImpl(Boolean.TYPE)).name("isValid").modifiers(SModifiersImpl.create(8, AccessPrivileges.PUBLIC)).concept(CONCEPT).id("48bMILtL4il").registry(REGISTRY).build();
private static final List<SMethod<?>> BH_METHODS = Arrays.<SMethod<?>>asList(getTopLevelRegexp_idhNm6Oh5, toString_idhEwIUjb, getString_idhMuDF1A, par_idhMuIPHY, checkStringForUnicode_idhMRXRyL, quote_idhMRXVXe, escape_id1b8uQvZ_lG7, needParentheses_id1b8uQvZynii, isValid_id48bMILtL4il);
private static void ___init___(@NotNull SNode __thisNode__) {
}
/*package*/ static SNode getTopLevelRegexp_idhNm6Oh5(@NotNull SNode __thisNode__) {
if (SNodeOperations.isInstanceOf(SNodeOperations.getParent(__thisNode__), MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174a06efdL, "jetbrains.mps.baseLanguage.regexp.structure.Regexp"))) {
return Regexp__BehaviorDescriptor.getTopLevelRegexp_idhNm6Oh5.invoke(SNodeOperations.cast(SNodeOperations.getParent(__thisNode__), MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174a06efdL, "jetbrains.mps.baseLanguage.regexp.structure.Regexp")));
}
return __thisNode__;
}
/*package*/ static String toString_idhEwIUjb(@NotNull SNode __thisNode__) {
return Regexp__BehaviorDescriptor.escape_id1b8uQvZ_lG7.invoke(__thisNode__, Regexp__BehaviorDescriptor.getString_idhMuDF1A.invoke(__thisNode__, new ArrayList<SNode>()));
}
/*package*/ static String getString_idhMuDF1A(@NotNull SNode __thisNode__, List<SNode> vars) {
return SConceptOperations.conceptAlias(SNodeOperations.getConcept(__thisNode__));
}
/*package*/ static String par_idhMuIPHY(@NotNull SNode __thisNode__, String s) {
return "(?:" + s + ")";
}
/*package*/ static boolean checkStringForUnicode_idhMRXRyL(@NotNull SNode __thisNode__, String s) {
return s.startsWith("\\u");
}
/*package*/ static String quote_idhMRXVXe(@NotNull SNode __thisNode__, char ch) {
return Pattern.quote("" + ch);
}
/*package*/ static String escape_id1b8uQvZ_lG7(@NotNull SNode __thisNode__, String s) {
if (s == null || s.indexOf('\\') == -1) {
return s;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '\\' || c == '"') {
sb.append("\\");
}
sb.append(c);
}
return sb.toString();
}
/*package*/ static boolean needParentheses_id1b8uQvZynii(@NotNull SNode __thisNode__) {
return false;
}
/*package*/ static boolean isValid_id48bMILtL4il(@NotNull SNode __thisNode__) {
for (SNode n : ListSequence.fromList(SNodeOperations.getChildren(__thisNode__))) {
if (SNodeOperations.isInstanceOf(n, MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174a06efdL, "jetbrains.mps.baseLanguage.regexp.structure.Regexp")) && !((boolean) Regexp__BehaviorDescriptor.isValid_id48bMILtL4il.invoke(SNodeOperations.cast(n, MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174a06efdL, "jetbrains.mps.baseLanguage.regexp.structure.Regexp"))))) {
return false;
}
}
return true;
}
/*package*/ Regexp__BehaviorDescriptor() {
super(REGISTRY);
}
@Override
protected void initNode(@NotNull SNode node, @NotNull SConstructor constructor, @Nullable Object[] parameters) {
___init___(node);
}
@Override
protected <T> T invokeSpecial0(@NotNull SNode node, @NotNull SMethod<T> method, @Nullable Object[] parameters) {
int methodIndex = BH_METHODS.indexOf(method);
if (methodIndex < 0) {
throw new BHMethodNotFoundException(this, method);
}
switch (methodIndex) {
case 0:
return (T) ((SNode) getTopLevelRegexp_idhNm6Oh5(node));
case 1:
return (T) ((String) toString_idhEwIUjb(node));
case 2:
return (T) ((String) getString_idhMuDF1A(node, (List<SNode>) parameters[0]));
case 3:
return (T) ((String) par_idhMuIPHY(node, (String) parameters[0]));
case 4:
return (T) ((Boolean) checkStringForUnicode_idhMRXRyL(node, (String) parameters[0]));
case 5:
return (T) ((String) quote_idhMRXVXe(node, ((char) (Character) parameters[0])));
case 6:
return (T) ((String) escape_id1b8uQvZ_lG7(node, (String) parameters[0]));
case 7:
return (T) ((Boolean) needParentheses_id1b8uQvZynii(node));
case 8:
return (T) ((Boolean) isValid_id48bMILtL4il(node));
default:
throw new BHMethodNotFoundException(this, method);
}
}
@Override
protected <T> T invokeSpecial0(@NotNull SAbstractConcept concept, @NotNull SMethod<T> method, @Nullable Object[] parameters) {
int methodIndex = BH_METHODS.indexOf(method);
if (methodIndex < 0) {
throw new BHMethodNotFoundException(this, method);
}
switch (methodIndex) {
default:
throw new BHMethodNotFoundException(this, method);
}
}
@NotNull
@Override
public List<SMethod<?>> getDeclaredMethods() {
return BH_METHODS;
}
@NotNull
@Override
public SAbstractConcept getConcept() {
return CONCEPT;
}
}