package jetbrains.mps.lang.plugin.constraints; /*Generated by MPS */ import jetbrains.mps.scope.Scope; import org.jetbrains.mps.openapi.model.SModel; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.lang.plugin.behavior.ActionDataParameterDeclaration__BehaviorDescriptor; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import org.jetbrains.annotations.Nullable; import jetbrains.mps.internal.collections.runtime.Sequence; import jetbrains.mps.internal.collections.runtime.IWhereFilter; import org.jetbrains.annotations.NotNull; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; import java.util.List; import jetbrains.mps.internal.collections.runtime.ListSequence; import java.util.ArrayList; import jetbrains.mps.smodel.SModelOperations; import jetbrains.mps.baseLanguage.behavior.Classifier__BehaviorDescriptor; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import org.jetbrains.mps.openapi.persistence.PersistenceFacade; import jetbrains.mps.smodel.SModelUtil_new; import jetbrains.mps.smodel.SReference; public class DataParameterKeysScope extends Scope { private SModel myModel; public DataParameterKeysScope(SModel model) { myModel = model; } private Iterable<SNode> getAllStaticFields() { return (Iterable<SNode>) ActionDataParameterDeclaration__BehaviorDescriptor.getDataKeys_id1BC2tkUXZ6F.invoke(SNodeOperations.asSConcept(MetaAdapterFactory.getConcept(0x28f9e4973b424291L, 0xaeba0a1039153ab1L, 0x11b69e025e0L, "jetbrains.mps.lang.plugin.structure.ActionDataParameterDeclaration")), myModel); } public Iterable<SNode> getAvailableElements(@Nullable final String prefix) { if (prefix == null) { return getAllStaticFields(); } return Sequence.fromIterable(getAllStaticFields()).where(new IWhereFilter<SNode>() { public boolean accept(SNode it) { String referenceText = getReferenceText(it); return referenceText != null && referenceText.startsWith(prefix); } }); } @Nullable public SNode resolve(SNode contextNode, @NotNull final String refText) { Iterable<SNode> candidates = Sequence.fromIterable(getAllStaticFields()).where(new IWhereFilter<SNode>() { public boolean accept(SNode it) { return refText.equals(getReferenceText(it)); } }); if (Sequence.fromIterable(candidates).count() == 1) { return Sequence.fromIterable(candidates).first(); } return null; } @Nullable public String getReferenceText(SNode contextNode, @NotNull SNode target) { return getReferenceText(target); } @Nullable private String getReferenceText(@NotNull SNode target) { return SPropertyOperations.getString(SNodeOperations.cast(target, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf93c84351fL, "jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration")), MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x116b17c6e46L, 0x116b17cd415L, "resolveInfo")); } @Override public boolean contains(SNode node) { SNode staticField = SNodeOperations.as(node, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf93c84351fL, "jetbrains.mps.baseLanguage.structure.StaticFieldDeclaration")); if (staticField == null) { return false; } List<SModel> allIModels = ListSequence.fromList(new ArrayList<SModel>()); allIModels.add(myModel); allIModels.addAll(SModelOperations.allImportedModels(myModel)); if (!(allIModels.contains(SNodeOperations.getModel(staticField)))) { return false; } return (boolean) Classifier__BehaviorDescriptor.isDescendant_id6dL7A1DpKo1.invoke(SNodeOperations.as(SNodeOperations.getContainingRoot(staticField), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, "jetbrains.mps.baseLanguage.structure.ClassConcept")), SLinkOperations.getTarget(_quotation_createNode_d9tb28_a0a0g0n(), MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, 0x101de490babL, "classifier"))); } private static SNode _quotation_createNode_d9tb28_a0a0g0n() { PersistenceFacade facade = PersistenceFacade.getInstance(); SNode quotedNode_1 = null; quotedNode_1 = SModelUtil_new.instantiateConceptDeclaration(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, "jetbrains.mps.baseLanguage"), 0x101de48bf9eL, "ClassifierType"), null, null, false); quotedNode_1.setReference(MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, 0x101de490babL, "classifier"), SReference.create(MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x101de48bf9eL, 0x101de490babL, "classifier"), quotedNode_1, facade.createModelReference("498d89d2-c2e9-11e2-ad49-6cf049e62fe5/java:com.intellij.openapi.actionSystem(MPS.IDEA/)"), facade.createNodeId("~CommonDataKeys"))); return quotedNode_1; } }