package jetbrains.mps.lang.smodel.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 java.util.ArrayList;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import jetbrains.mps.internal.collections.runtime.Sequence;
import java.util.Collections;
import jetbrains.mps.internal.collections.runtime.ITranslator2;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.internal.collections.runtime.IWhereFilter;
import jetbrains.mps.internal.collections.runtime.ISelector;
import jetbrains.mps.core.aspects.behaviour.api.SConstructor;
import org.jetbrains.annotations.Nullable;
import jetbrains.mps.core.aspects.behaviour.api.BHMethodNotFoundException;
public final class AbstractNodeRefExpression__BehaviorDescriptor extends BaseBHDescriptor {
private static final SAbstractConcept CONCEPT = MetaAdapterFactory.getConcept(0x7866978ea0f04cc7L, 0x81bc4d213d9375e1L, 0x319fd776da5d8e3cL, "jetbrains.mps.lang.smodel.structure.AbstractNodeRefExpression");
private static final BehaviorRegistry REGISTRY = ConceptRegistry.getInstance().getBehaviorRegistry();
public static final SMethod<SNode> getTargetNode_id36vPRrqnscn = new SMethodBuilder<SNode>(new SJavaCompoundTypeImpl((Class<SNode>) ((Class) Object.class))).name("getTargetNode").modifiers(SModifiersImpl.create(12, AccessPrivileges.PUBLIC)).concept(CONCEPT).id("36vPRrqnscn").registry(REGISTRY).build();
public static final SMethod<Iterable<SNode>> getPossibleTargetNodes_id4x3U0fpSqvX = new SMethodBuilder<Iterable<SNode>>(new SJavaCompoundTypeImpl((Class<Iterable<SNode>>) ((Class) Object.class))).name("getPossibleTargetNodes").modifiers(SModifiersImpl.create(0, AccessPrivileges.PUBLIC)).concept(CONCEPT).id("4x3U0fpSqvX").registry(REGISTRY).build();
private static final List<SMethod<?>> BH_METHODS = Arrays.<SMethod<?>>asList(getTargetNode_id36vPRrqnscn, getPossibleTargetNodes_id4x3U0fpSqvX);
private static void ___init___(@NotNull SNode __thisNode__) {
}
/*package*/ static Iterable<SNode> getPossibleTargetNodes_id4x3U0fpSqvX(@NotNull SNode __thisNode__) {
List<SNode> thisList = new ArrayList<SNode>();
ListSequence.fromList(thisList).addElement(AbstractNodeRefExpression__BehaviorDescriptor.getTargetNode_id36vPRrqnscn.invoke(__thisNode__));
Iterable<SNode> children = thisList;
Iterable<SNode> result = Sequence.fromIterable(Collections.<SNode>emptyList());
while (Sequence.fromIterable(children).isNotEmpty()) {
children = Sequence.fromIterable(children).translate(new ITranslator2<SNode, SNode>() {
public Iterable<SNode> translate(SNode it) {
return SNodeOperations.getChildren(it);
}
});
result = Sequence.fromIterable(result).concat(Sequence.fromIterable(children).where(new IWhereFilter<SNode>() {
public boolean accept(SNode it) {
return SNodeOperations.isInstanceOf(it, MetaAdapterFactory.getInterfaceConcept(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, "jetbrains.mps.lang.core.structure.INamedConcept"));
}
}).select(new ISelector<SNode, SNode>() {
public SNode select(SNode it) {
return SNodeOperations.cast(it, MetaAdapterFactory.getInterfaceConcept(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, "jetbrains.mps.lang.core.structure.INamedConcept"));
}
}));
children = Sequence.fromIterable(children).where(new IWhereFilter<SNode>() {
public boolean accept(SNode it) {
return !(SNodeOperations.isInstanceOf(it, MetaAdapterFactory.getInterfaceConcept(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, "jetbrains.mps.lang.core.structure.INamedConcept")));
}
});
}
return result;
}
/*package*/ AbstractNodeRefExpression__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 1:
return (T) ((Iterable<SNode>) getPossibleTargetNodes_id4x3U0fpSqvX(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;
}
}