private static List<SNode> getOuterVariables_id4zrttnsimEk(@NotNull SNode __thisNode__) {
   List<SNode> allVar =
       SNodeOperations.getNodeDescendants(
           __thisNode__,
           MetaAdapterFactory.getConcept(
               0x7c9e280794ad4afcL,
               0xadf0aaee45eb2895L,
               0x48db75d5dc496b12L,
               "jetbrains.mps.samples.lambdaCalculus.structure.Variable"),
           false,
           new SAbstractConcept[] {});
   List<SNode> allRef =
       SNodeOperations.getNodeDescendants(
           __thisNode__,
           MetaAdapterFactory.getConcept(
               0x7c9e280794ad4afcL,
               0xadf0aaee45eb2895L,
               0x48db75d5dc496b08L,
               "jetbrains.mps.samples.lambdaCalculus.structure.VariableReference"),
           false,
           new SAbstractConcept[] {});
   List<SNode> result = new ArrayList<SNode>();
   for (SNode ref : allRef) {
     if (!(ListSequence.fromList(allVar)
             .contains(
                 SLinkOperations.getTarget(
                     ref,
                     MetaAdapterFactory.getReferenceLink(
                         0x7c9e280794ad4afcL,
                         0xadf0aaee45eb2895L,
                         0x48db75d5dc496b08L,
                         0x48db75d5dc497af4L,
                         "variable"))))
         && !(ListSequence.fromList(result)
             .contains(
                 SLinkOperations.getTarget(
                     ref,
                     MetaAdapterFactory.getReferenceLink(
                         0x7c9e280794ad4afcL,
                         0xadf0aaee45eb2895L,
                         0x48db75d5dc496b08L,
                         0x48db75d5dc497af4L,
                         "variable"))))) {
       ListSequence.fromList(result)
           .addElement(
               SLinkOperations.getTarget(
                   ref,
                   MetaAdapterFactory.getReferenceLink(
                       0x7c9e280794ad4afcL,
                       0xadf0aaee45eb2895L,
                       0x48db75d5dc496b08L,
                       0x48db75d5dc497af4L,
                       "variable")));
     }
   }
   return result;
 }
Exemplo n.º 2
0
  protected void applyTransormMigration(
      SNode origin,
      Computable<SNode> migration,
      _FunctionTypes._void_P2_E0<? super SNode, ? super SNode> postprocess) {
    MigrationScriptBase.SNodePlacePointer pointer = createSNodePlacePointer(origin);
    List<SNode> descendants =
        SNodeOperations.getNodeDescendants(origin, null, true, new SAbstractConcept[] {});

    SNode migrated = migration.compute();

    if (postprocess != null) {
      postprocess.invoke(origin, migrated);
    }

    if (migrated == null) {
      // origin should be removed
      pointer.remove();
    } else {
      if (!(ListSequence.fromList(descendants).contains(migrated))
          && migrated instanceof jetbrains.mps.smodel.SNode) {
        // returned value is new created node
        if (!(ListSequence.fromList(SNodeOperations.getNodeAncestors(origin, null, false))
            .contains(migrated))) {
          // origin is not keeped
          ((jetbrains.mps.smodel.SNode) migrated).setId(origin.getNodeId());
        }
      }
      pointer.insertOrReplace(migrated);
    }
  }
Exemplo n.º 3
0
 private void processEvent(SModelChildEvent event) {
   SetSequence.fromSet(myDependenciesToInvalidate).addElement(event.getParent());
   if (event.isRemoved()) {
     SetSequence.fromSet(myDependenciesToInvalidate).addElement(event.getChild());
   }
   if (event.isAdded()) {
     SetSequence.fromSet(myInvalidNodes)
         .addSequence(
             ListSequence.fromList(
                 SNodeOperations.getNodeDescendants(
                     ((SNode) event.getChild()), null, false, new SAbstractConcept[] {})));
     SetSequence.fromSet(myInvalidNodes).addElement(event.getChild());
   }
 }
Exemplo n.º 4
0
 public void apply() {
   if (myNodesToApply.isEmpty()) {
     return;
   }
   SNode first = myNodesToApply.iterator().next();
   SModel model = first.getModel();
   if (model == null) {
     LOG.warning(
         "Checking node which is not attached to the model: "
             + first.getPresentation()
             + " "
             + first.getNodeId());
     return;
   }
   // XXX could I demand here that model has to be attached to a repository, so that I can use one
   // to obtain LanguageRegistry?
   for (SLanguage language : SModelOperations.getAllLanguageImports(model)) {
     LanguageRuntime languageRuntime = LanguageRegistry.getInstance().getLanguage(language);
     if (languageRuntime == null) {
       continue;
     }
     DataFlowAspectDescriptor aspect = languageRuntime.getAspect(DataFlowAspectDescriptor.class);
     if (aspect == null) {
       continue;
     }
     for (DataFlowConstructor rule : aspect.getConstructors(myAnalyzerId)) {
       myRules.add(rule);
     }
   }
   Set<SNode> descendants = new LinkedHashSet<SNode>();
   for (SNode myNodeToApply : myNodesToApply) {
     descendants.addAll(
         SNodeOperations.getNodeDescendants(
             myNodeToApply, null, false, new SAbstractConcept[] {}));
   }
   for (SNode descendant : descendants) {
     getRules(descendant).forEach(rule -> rule.performActions(myProgram, descendant));
   }
 }
Exemplo n.º 5
0
 public static SNode virtual_getLooseType_5744862332972792015(
     SNode thisNode, @NotNull Set<SNode> visitedTypes) {
   SNode looseType = SNodeOperations.copyNode(thisNode);
   for (SNode varRef :
       SNodeOperations.getNodeDescendants(
           looseType,
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x102467229d8L,
               "jetbrains.mps.baseLanguage.structure.TypeVariableReference"),
           false,
           new SAbstractConcept[] {})) {
     SNodeOperations.replaceWithAnother(
         varRef,
         BehaviorReflection.invokeVirtual(
             (Class<SNode>) ((Class) Object.class),
             varRef,
             "virtual_getLooseType_5744862332972792015",
             new Object[] {visitedTypes}));
   }
   return looseType;
 }
Exemplo n.º 6
0
 protected void addNodeImports(SNode node) {
   final SModelInternal modelInternal = (SModelInternal) myModel;
   final AbstractModule module = ((AbstractModule) myModel.getModule());
   final Collection<SLanguage> importedLanguages = modelInternal.importedLanguageIds();
   for (SNode subNode :
       ListSequence.fromList(
           SNodeOperations.getNodeDescendants(node, null, true, new SAbstractConcept[] {}))) {
     SLanguage usedLanguage = subNode.getConcept().getLanguage();
     if (!(importedLanguages.contains(usedLanguage))) {
       modelInternal.addLanguage(usedLanguage);
     }
     for (SReference ref : ListSequence.fromList(SNodeOperations.getReferences(subNode))) {
       SModel usedModel = SNodeOperations.getModel(SLinkOperations.getTargetNode(ref));
       if (usedModel != null && !(modelInternal.importedModels().contains(usedModel))) {
         modelInternal.addModelImport(usedModel.getReference(), false);
         module.addDependency(
             SNodeOperations.getModel(SLinkOperations.getTargetNode(ref))
                 .getModule()
                 .getModuleReference(),
             false);
       }
     }
   }
 }
 public static List<SNode> call_getInferrableTypeVars_6848250892784543828(
     final SNode __thisNode__) {
   List<SNode> returnTypeVars =
       ListSequence.fromList(
               SNodeOperations.getNodeDescendants(
                   SLinkOperations.getTarget(
                       __thisNode__,
                       MetaAdapterFactory.getContainmentLink(
                           0xf3061a5392264cc5L,
                           0xa443f952ceaf5816L,
                           0xf8cc56b1fcL,
                           0xf8cc56b1fdL,
                           "returnType")),
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0x102467229d8L,
                       "jetbrains.mps.baseLanguage.structure.TypeVariableReference"),
                   false,
                   new SAbstractConcept[] {}))
           .select(
               new ISelector<SNode, SNode>() {
                 public SNode select(SNode it) {
                   return SLinkOperations.getTarget(
                       it,
                       MetaAdapterFactory.getReferenceLink(
                           0xf3061a5392264cc5L,
                           0xa443f952ceaf5816L,
                           0x102467229d8L,
                           0x1024673a581L,
                           "typeVariableDeclaration"));
                 }
               })
           .where(
               new IWhereFilter<SNode>() {
                 public boolean accept(SNode it) {
                   return SNodeOperations.getParent(it) == __thisNode__;
                 }
               })
           .toListSequence();
   List<SNode> boundTypeVars =
       ListSequence.fromList(
               SLinkOperations.getChildren(
                   __thisNode__,
                   MetaAdapterFactory.getContainmentLink(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0xf8cc56b1fcL,
                       0xf8cc56b1feL,
                       "parameter")))
           .translate(
               new ITranslator2<SNode, SNode>() {
                 public Iterable<SNode> translate(SNode p) {
                   return SNodeOperations.getNodeDescendants(
                       p,
                       MetaAdapterFactory.getConcept(
                           0xf3061a5392264cc5L,
                           0xa443f952ceaf5816L,
                           0x102467229d8L,
                           "jetbrains.mps.baseLanguage.structure.TypeVariableReference"),
                       false,
                       new SAbstractConcept[] {});
                 }
               })
           .select(
               new ISelector<SNode, SNode>() {
                 public SNode select(SNode it) {
                   return SLinkOperations.getTarget(
                       it,
                       MetaAdapterFactory.getReferenceLink(
                           0xf3061a5392264cc5L,
                           0xa443f952ceaf5816L,
                           0x102467229d8L,
                           0x1024673a581L,
                           "typeVariableDeclaration"));
                 }
               })
           .where(
               new IWhereFilter<SNode>() {
                 public boolean accept(SNode it) {
                   return SNodeOperations.getParent(it) == __thisNode__;
                 }
               })
           .toListSequence();
   return ListSequence.fromList(returnTypeVars)
       .subtract(ListSequence.fromList(boundTypeVars))
       .toListSequence();
 }
 @Override
 protected void init() {
   List<SNode> allMethods = new ArrayList<SNode>();
   List<SNode> classifiers =
       ((ClassifierAndSuperClassifiersCache) this.getOwnerCache()).getClassifiers();
   for (SNode classifier : classifiers) {
     ListSequence.fromList(allMethods)
         .addSequence(
             Sequence.fromIterable(
                 ((Iterable<SNode>)
                     BHReflection.invoke(
                         classifier,
                         SMethodTrimmedId.create(
                             "methods",
                             MetaAdapterFactory.getConcept(
                                 0xf3061a5392264cc5L,
                                 0xa443f952ceaf5816L,
                                 0x101d9d3ca30L,
                                 "jetbrains.mps.baseLanguage.structure.Classifier"),
                             "4_LVZ3pBKCn")))));
     ListSequence.fromList(allMethods)
         .addSequence(
             Sequence.fromIterable(
                 ((Iterable<SNode>)
                     BHReflection.invoke(
                         classifier,
                         SMethodTrimmedId.create(
                             "staticMethods",
                             MetaAdapterFactory.getConcept(
                                 0xf3061a5392264cc5L,
                                 0xa443f952ceaf5816L,
                                 0x101d9d3ca30L,
                                 "jetbrains.mps.baseLanguage.structure.Classifier"),
                             "7fFTwQrQPHW")))));
   }
   this.myMethodsByName = MapSequence.fromMap(new HashMap<String, List<SNode>>());
   this.myOverriddenMethods = MapSequence.fromMap(new HashMap<SNode, List<SNode>>());
   forEachInAllMethods:
   for (SNode currMethod : allMethods) {
     String name =
         SPropertyOperations.getString(
             currMethod,
             MetaAdapterFactory.getProperty(
                 0xceab519525ea4f22L,
                 0x9b92103b95ca8c0cL,
                 0x110396eaaa4L,
                 0x110396ec041L,
                 "name"));
     if (name == null) {
       name = "";
     }
     if (!(MapSequence.fromMap(this.myMethodsByName).containsKey(name))) {
       List<SNode> methods = new ArrayList<SNode>();
       methods.add(currMethod);
       MapSequence.fromMap(myMethodsByName).put(name, methods);
       MapSequence.fromMap(myOverriddenMethods).put(currMethod, new ArrayList<SNode>());
     } else {
       int currMethodParmCount =
           ListSequence.fromList(
                   SLinkOperations.getChildren(
                       currMethod,
                       MetaAdapterFactory.getContainmentLink(
                           0xf3061a5392264cc5L,
                           0xa443f952ceaf5816L,
                           0xf8cc56b1fcL,
                           0xf8cc56b1feL,
                           "parameter")))
               .count();
       List<SNode> equalParmCountMethods = new ArrayList<SNode>();
       List<SNode> methods = MapSequence.fromMap(this.myMethodsByName).get(name);
       for (SNode method : methods) {
         if ((SNodeOperations.getParent(currMethod) != SNodeOperations.getParent(method))
             && ListSequence.fromList(
                         SLinkOperations.getChildren(
                             method,
                             MetaAdapterFactory.getContainmentLink(
                                 0xf3061a5392264cc5L,
                                 0xa443f952ceaf5816L,
                                 0xf8cc56b1fcL,
                                 0xf8cc56b1feL,
                                 "parameter")))
                     .count()
                 == currMethodParmCount) {
           equalParmCountMethods.add(method);
         }
       }
       if (equalParmCountMethods.size() > 0) {
         if (currMethodParmCount == 0) {
           ListSequence.fromList(
                   MapSequence.fromMap(myOverriddenMethods)
                       .get(ListSequence.fromList(equalParmCountMethods).first()))
               .addElement(currMethod);
           continue forEachInAllMethods;
         }
         Map<SNode, SNode> typeByTypeVar =
             ((ClassifierAndSuperClassifiersCache) this.getOwnerCache())
                 .getTypeByTypeVariableMap();
         String currentParms = this.createMethodParameterTypesString(currMethod, typeByTypeVar);
         for (SNode otherMethod : equalParmCountMethods) {
           String otherParms = this.createMethodParameterTypesString(otherMethod, typeByTypeVar);
           if (otherParms.equals(currentParms)) {
             MapSequence.fromMap(this.myOverriddenMethods).get(otherMethod).add(currMethod);
             continue forEachInAllMethods;
           }
         }
       }
       ListSequence.fromList(MapSequence.fromMap(myMethodsByName).get(name))
           .addElement(currMethod);
       MapSequence.fromMap(myOverriddenMethods).put(currMethod, new ArrayList<SNode>());
     }
   }
   this.myDependsOnNodes = SetSequence.fromSet(new HashSet<SNode>());
   for (SNode classifier : classifiers) {
     SetSequence.fromSet(this.myDependsOnNodes).addElement(classifier);
   }
   for (SNode method : allMethods) {
     SetSequence.fromSet(this.myDependsOnNodes).addElement(method);
     for (SNode parm :
         SLinkOperations.getChildren(
             method,
             MetaAdapterFactory.getContainmentLink(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0xf8cc56b1fcL,
                 0xf8cc56b1feL,
                 "parameter"))) {
       SNode type =
           SLinkOperations.getTarget(
               parm,
               MetaAdapterFactory.getContainmentLink(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x450368d90ce15bc3L,
                   0x4ed4d318133c80ceL,
                   "type"));
       if (type == null) {
         continue;
       }
       SetSequence.fromSet(myDependsOnNodes).addElement(type);
       SetSequence.fromSet(myDependsOnNodes)
           .addSequence(
               ListSequence.fromList(
                   SNodeOperations.getNodeDescendants(
                       type, null, false, new SAbstractConcept[] {})));
     }
   }
 }
 @Override
 protected void init() {
   this.myTypeByTypeVariable = MapSequence.fromMap(new HashMap<SNode, SNode>());
   this.myClassifiers =
       ClassifierAndSuperClassifiersCache.ClassifiersDataSet.getImplementedAndExtended(
           this.myTopClassifier, this.myTypeByTypeVariable);
   this.myDependsOnNodes = SetSequence.fromSet(new HashSet<SNode>());
   for (SNode classifier : this.myClassifiers) {
     SetSequence.fromSet(this.myDependsOnNodes).addElement(classifier);
     if (SNodeOperations.isInstanceOf(
         classifier,
         MetaAdapterFactory.getConcept(
             0xf3061a5392264cc5L,
             0xa443f952ceaf5816L,
             0x1107e0cb103L,
             "jetbrains.mps.baseLanguage.structure.AnonymousClass"))) {
       for (SNode type :
           SLinkOperations.getChildren(
               (SNodeOperations.cast(
                   classifier,
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0x1107e0cb103L,
                       "jetbrains.mps.baseLanguage.structure.AnonymousClass"))),
               MetaAdapterFactory.getContainmentLink(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x1107e0cb103L,
                   0x117ac45a693L,
                   "typeParameter"))) {
         SetSequence.fromSet(this.myDependsOnNodes).addElement(type);
         SetSequence.fromSet(this.myDependsOnNodes)
             .addSequence(
                 ListSequence.fromList(
                     SNodeOperations.getNodeDescendants(
                         type, null, false, new SAbstractConcept[] {})));
       }
     } else {
       for (SNode typeVariableDecl :
           SLinkOperations.getChildren(
               classifier,
               MetaAdapterFactory.getContainmentLink(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x102463b447aL,
                   0x102463bb98eL,
                   "typeVariableDeclaration"))) {
         SetSequence.fromSet(this.myDependsOnNodes).addElement(typeVariableDecl);
       }
     }
     if (SNodeOperations.isInstanceOf(
             classifier,
             MetaAdapterFactory.getConcept(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0xf8c108ca66L,
                 "jetbrains.mps.baseLanguage.structure.ClassConcept"))
         && !(SNodeOperations.isInstanceOf(
             classifier,
             MetaAdapterFactory.getConcept(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0x1107e0cb103L,
                 "jetbrains.mps.baseLanguage.structure.AnonymousClass")))) {
       SNode classifierType0 =
           SLinkOperations.getTarget(
               (SNodeOperations.cast(
                   classifier,
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0xf8c108ca66L,
                       "jetbrains.mps.baseLanguage.structure.ClassConcept"))),
               MetaAdapterFactory.getContainmentLink(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0xf8c108ca66L,
                   0x10f6353296dL,
                   "superclass"));
       if (classifierType0 != null) {
         SetSequence.fromSet(this.myDependsOnNodes).addElement(classifierType0);
         SetSequence.fromSet(this.myDependsOnNodes)
             .addSequence(
                 ListSequence.fromList(
                     SNodeOperations.getNodeDescendants(
                         classifierType0, null, false, new SAbstractConcept[] {})));
       }
       for (SNode classifierType1 :
           SLinkOperations.getChildren(
               (SNodeOperations.cast(
                   classifier,
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0xf8c108ca66L,
                       "jetbrains.mps.baseLanguage.structure.ClassConcept"))),
               MetaAdapterFactory.getContainmentLink(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0xf8c108ca66L,
                   0xff2ac0b419L,
                   "implementedInterface"))) {
         SetSequence.fromSet(this.myDependsOnNodes).addElement(classifierType1);
         SetSequence.fromSet(this.myDependsOnNodes)
             .addSequence(
                 ListSequence.fromList(
                     SNodeOperations.getNodeDescendants(
                         classifierType1, null, false, new SAbstractConcept[] {})));
       }
     } else if (SNodeOperations.isInstanceOf(
         classifier,
         MetaAdapterFactory.getConcept(
             0xf3061a5392264cc5L,
             0xa443f952ceaf5816L,
             0x101edd46144L,
             "jetbrains.mps.baseLanguage.structure.Interface"))) {
       for (SNode classifierType :
           SLinkOperations.getChildren(
               (SNodeOperations.cast(
                   classifier,
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0x101edd46144L,
                       "jetbrains.mps.baseLanguage.structure.Interface"))),
               MetaAdapterFactory.getContainmentLink(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x101edd46144L,
                   0x101eddadad7L,
                   "extendedInterface"))) {
         SetSequence.fromSet(this.myDependsOnNodes).addElement(classifierType);
         SetSequence.fromSet(this.myDependsOnNodes)
             .addSequence(
                 ListSequence.fromList(
                     SNodeOperations.getNodeDescendants(
                         classifierType, null, false, new SAbstractConcept[] {})));
       }
     }
   }
 }
 public void build(
     final IOperationContext operationContext, final DataFlowBuilderContext _context) {
   List<SNode> methods =
       SNodeOperations.getNodeDescendants(
           _context.getNode(),
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0xf8cc56b1fcL,
               "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration"),
           false,
           new SAbstractConcept[] {});
   Set<SNode> vars = SetSequence.fromSet(new HashSet<SNode>());
   for (SNode method : methods) {
     SetSequence.fromSet(vars)
         .addSequence(
             SetSequence.fromSet(
                 StatementList_Behavior.call_getExternalVariablesDeclarations_1214501165480(
                     SLinkOperations.getTarget(
                         method,
                         MetaAdapterFactory.getContainmentLink(
                             0xf3061a5392264cc5L,
                             0xa443f952ceaf5816L,
                             0xf8cc56b1fcL,
                             0xf8cc56b1ffL,
                             "body")))));
   }
   for (SNode var : vars) {
     _context
         .getBuilder()
         .emitRead(
             var,
             "r:3e9b7681-85ee-48b2-91d2-9a45a96731b1(jetbrains.mps.baseLanguageInternal.dataFlow)/3421461530438560096");
   }
   for (SNode expr :
       SLinkOperations.getChildren(
           SLinkOperations.getTarget(
               _context.getNode(),
               MetaAdapterFactory.getContainmentLink(
                   0xdf345b11b8c74213L,
                   0xac6648d2a9b75d88L,
                   0x2f7b79225e746808L,
                   0x2f7b79225e74691fL,
                   "cls")),
           MetaAdapterFactory.getContainmentLink(
               0xdf345b11b8c74213L,
               0xac6648d2a9b75d88L,
               0x2f7b79225e746809L,
               0x2f7b79225e74680cL,
               "constructorArgument"))) {
     _context.getBuilder().build((SNode) expr);
   }
   for (SNode fieldDeclaration :
       ClassConcept_Behavior.call_fields_5292274854859383272(
           SLinkOperations.getTarget(
               _context.getNode(),
               MetaAdapterFactory.getContainmentLink(
                   0xdf345b11b8c74213L,
                   0xac6648d2a9b75d88L,
                   0x2f7b79225e746808L,
                   0x2f7b79225e74691fL,
                   "cls")))) {
     _context.getBuilder().build((SNode) fieldDeclaration);
   }
 }