package jetbrains.mps.lang.editor.constraints;
/*Generated by MPS */
import jetbrains.mps.scope.Scope;
import org.jetbrains.mps.openapi.model.SNode;
import org.jetbrains.mps.openapi.language.SContainmentLink;
import org.jetbrains.mps.openapi.language.SAbstractConcept;
import jetbrains.mps.scope.ModelPlusImportedScope;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import jetbrains.mps.scope.EmptyScope;
import jetbrains.mps.scope.FilteringScope;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations;
public class MenuScopes {
public static Scope getNamedMenus(SNode contextNode, SContainmentLink link, int position, SAbstractConcept concept) {
final Scope allNamedMenus = new ModelPlusImportedScope(SNodeOperations.getModel(contextNode), true, concept);
// Uses the scope of allowed concepts (for default menus) to restrict the set of named menus to those
// that reference allowed concepts.
final Scope allowedConcepts = Scope.getScope(contextNode, link, position, MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x1103553c5ffL, "jetbrains.mps.lang.structure.structure.AbstractConceptDeclaration"));
if (allowedConcepts == null) {
return new EmptyScope();
}
return new FilteringScope(allNamedMenus) {
@Override
public boolean isExcluded(SNode node) {
return !(allowedConcepts.contains(SLinkOperations.getTarget(SNodeOperations.cast(node, MetaAdapterFactory.getInterfaceConcept(0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0x169efbc9a9048c46L, "jetbrains.mps.lang.editor.structure.IMenu_Named")), MetaAdapterFactory.getReferenceLink(0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0x169efbc9a9048c53L, 0x5b7b4c4d511049b4L, "conceptDeclaration"))));
}
};
}
}