Example #1
0
  private static void assertDeepChildrenEquals(SNode expectedNode, SNode actualNode) {
    Set<String> roles = new HashSet<String>();
    for (SNode child : expectedNode.getChildren()) {
      roles.add(child.getRoleInParent());
    }
    for (SNode child : actualNode.getChildren()) {
      roles.add(child.getRoleInParent());
    }

    for (String role : roles) {
      Iterable<? extends SNode> expectedChildren = expectedNode.getChildren(role);
      Iterable<? extends SNode> actualChildren = actualNode.getChildren(role);

      int esize = IterableUtil.asCollection(expectedChildren).size();
      int asize = IterableUtil.asCollection(actualChildren).size();
      assertEquals(
          getErrorString("child count in role " + role, expectedNode, actualNode), esize, asize);

      Iterator<? extends SNode> actualIterator = actualChildren.iterator();
      for (SNode expectedChild : expectedChildren) {
        SNode actualChild = actualIterator.next();
        assertEquals(
            getErrorString("children in role " + role, expectedNode, actualNode),
            expectedChild.getNodeId(),
            actualChild.getNodeId());
        assertDeepNodeEquals(expectedChild, actualChild);
      }
    }
  }
Example #2
0
 private static void assertPropertyEquals(SNode expectedNode, SNode actualNode) {
   HashSet<String> propertes = new HashSet<String>();
   propertes.addAll(IterableUtil.asCollection(expectedNode.getPropertyNames()));
   propertes.addAll(IterableUtil.asCollection(actualNode.getPropertyNames()));
   for (String key : propertes) {
     String expectedProperty =
         jetbrains.mps.util.SNodeOperations.getProperties(expectedNode).get(key);
     String actualProperty = jetbrains.mps.util.SNodeOperations.getProperties(actualNode).get(key);
     assertEquals(
         getErrorString("property", expectedNode, actualNode), expectedProperty, actualProperty);
   }
 }
Example #3
0
  public SNode coerceSubTypingNew(
      final SNode subtype,
      final IMatchingPattern pattern,
      final boolean isWeak,
      final TypeCheckingContext context) {
    if (subtype == null) return null;
    if (pattern.match(subtype)) return subtype;
    if (!CoerceUtil.canBeCoerced(subtype, pattern.getConceptFQName())) return null;
    if ("jetbrains.mps.lang.typesystem.structure.MeetType"
        .equals(subtype.getConcept().getQualifiedName())) {
      List<SNode> children =
          new ArrayList(IterableUtil.asCollection(subtype.getChildren("argument")));
      for (SNode child : children) {
        SNode result = coerceSubTypingNew(child, pattern, isWeak, context);
        if (result != null) return result;
      }
      return null;
    }
    final TypeCheckingContext typeCheckingContext = context;
    if ("jetbrains.mps.lang.typesystem.structure.JoinType"
        .equals(subtype.getConcept().getQualifiedName())) {
      List<SNode> children =
          new ArrayList(IterableUtil.asCollection(subtype.getChildren("argument")));

      SNode lcs = SubtypingUtil.createLeastCommonSupertype(children, typeCheckingContext);
      return coerceSubTypingNew(lcs, pattern, isWeak, context);
    }

    // asking the cache
    return NodeReadAccessCasterInEditor.runReadTransparentAction(
        new Computable<SNode>() {
          @Override
          public SNode compute() {
            Pair<Boolean, SNode> answer = getCoerceCacheAnswer(subtype, pattern, isWeak);
            if (answer != null && answer.o1) {
              return answer.o2;
            }
            CoercionMatcher coercionMatcher = new CoercionMatcher(pattern);
            SNode result = searchInSuperTypes(subtype, coercionMatcher, isWeak);
            // writing to the cache
            SubtypingCache subtypingCache = myTypeChecker.getSubtypingCache();
            if (subtypingCache != null) {
              subtypingCache.cacheCoerce(subtype, pattern, result, isWeak);
            }
            return result;
          }
        });
  }
Example #4
0
 private static Iterable<SNodeId> getNodeIdsForNodeGroupChange(
     @NotNull NodeGroupChange ngc,
     @Nullable Tuples._2<SNodeId, List<SNodeId>> lastParentAndNewChildrenIds) {
   List<SNodeId> childrenIds;
   if (lastParentAndNewChildrenIds == null
       || neq_5iuzi5_a0a1a72(lastParentAndNewChildrenIds._0(), ngc.getParentNodeId())) {
     List<? extends SNode> children =
         IterableUtil.asList(
             ngc.getChangeSet()
                 .getNewModel()
                 .getNode(ngc.getParentNodeId())
                 .getChildren(ngc.getRole()));
     childrenIds =
         ListSequence.fromList(children)
             .select(
                 new ISelector<SNode, SNodeId>() {
                   public SNodeId select(SNode n) {
                     return n.getNodeId();
                   }
                 })
             .toListSequence();
   } else {
     childrenIds = lastParentAndNewChildrenIds._1();
   }
   return ListSequence.fromList(childrenIds).page(ngc.getResultBegin(), ngc.getResultEnd());
 }
 public boolean match(SNode nodeToMatch) {
   {
     SNode nodeToMatch_nlist_subtypeOf_list_of_nodes_3tjcdg_a0a_0;
     nodeToMatch_nlist_subtypeOf_list_of_nodes_3tjcdg_a0a_0 = nodeToMatch;
     if (!("jetbrains.mps.baseLanguage.collections.structure.ListType"
         .equals(
             nodeToMatch_nlist_subtypeOf_list_of_nodes_3tjcdg_a0a_0
                 .getConcept()
                 .getConceptId()))) {
       return false;
     }
     {
       String childRole_nlist_subtypeOf_list_of_nodes_3tjcdg_ = "elementType";
       if (!(PatternUtil.hasNChildren(
           nodeToMatch_nlist_subtypeOf_list_of_nodes_3tjcdg_a0a_0,
           childRole_nlist_subtypeOf_list_of_nodes_3tjcdg_,
           1))) {
         return false;
       }
       {
         SNode childVar_nlist_subtypeOf_list_of_nodes_3tjcdg_a0a0 =
             IterableUtil.get(
                 nodeToMatch_nlist_subtypeOf_list_of_nodes_3tjcdg_a0a_0.getChildren(
                     childRole_nlist_subtypeOf_list_of_nodes_3tjcdg_),
                 0);
         this.patternVar_ELEMENT = childVar_nlist_subtypeOf_list_of_nodes_3tjcdg_a0a0;
       }
     }
   }
   return true;
 }
  @Override
  public SearchResults find(SearchQuery query, @NotNull ProgressMonitor monitor) {
    SearchResults<SNode> searchResults = new SearchResults<SNode>();
    Object value = query.getObjectHolder().getObject();
    SModule module = null;
    if (value instanceof SModule) {
      module = ((SModule) value);
    } else if (value instanceof SModuleReference) {
      module = query.getScope().resolve(((SModuleReference) value));
    }
    if (!(module instanceof Language)) {
      return searchResults;
    }
    Language language = (Language) module;
    SModel structureModel = language.getStructureModelDescriptor();
    if (structureModel == null) {
      return searchResults;
    }
    if (!(structureModel.getRootNodes().iterator().hasNext())) {
      return searchResults;
    }
    List<SNode> roots = new LinkedList<SNode>();
    for (SNode root : structureModel.getRootNodes()) {
      roots.add(root);
    }
    searchResults.getSearchedNodes().addAll(roots);

    monitor.start("", IterableUtil.asCollection(structureModel.getRootNodes()).size() + 1);
    try {
      SearchResults<SModel> modelResults =
          FindUtils.getSearchResults(
              monitor.subTask(1),
              new SearchQuery(
                  structureModel.getReference(), GlobalScopeMinusTransient.getInstance()),
              new ModelImportsUsagesFinder());
      List<SModel> models = new ArrayList<SModel>();
      for (SearchResult<SModel> sModelSearchResult : modelResults.getSearchResults()) {
        models.add(sModelSearchResult.getObject());
      }
      SearchScope scope = new ModelsScope(models.toArray(new SModel[models.size()]));
      SearchResults<SNode> results = new SearchResults();
      for (SNode node : roots) {
        if (monitor.isCanceled()) {
          break;
        }
        results.addAll(
            FindUtils.getSearchResults(
                monitor.subTask(1),
                node,
                scope,
                "jetbrains.mps.lang.structure.findUsages.NodeUsages_Finder"));
        results.removeDuplicates();
      }
      searchResults.getSearchResults().addAll(results.getSearchResults());
      return searchResults;
    } finally {
      monitor.done();
    }
  }
Example #7
0
  private void ensureInitialized(Pair<SModuleReference, String> key) {
    if (myStubModulesCache.containsKey(key)) return;

    IModule module = ModuleRepositoryFacade.getInstance().getModule(key.o1);
    Set<SModel> visibleModels =
        new HashSet<SModel>(IterableUtil.asCollection(module.getModuleScope().getModels()));

    fillCacheWithModels(key, visibleModels);
  }
Example #8
0
  @Override
  public Set<SReference> search(
      Set<SNode> nodes, @NotNull SearchScope scope, @NotNull ProgressMonitor monitor) {
    final HashSet<SReference> rv = new HashSet<SReference>();
    CollectConsumer<SReference> consumer = new CollectConsumer<SReference>(rv);
    Collection<FindUsagesParticipant> participants =
        PersistenceRegistry.getInstance().getFindUsagesParticipants();

    monitor.start("Finding usages...", participants.size() + 4);
    try {
      Collection<SModel> current = new LinkedHashSet<SModel>();
      Collection<SModel> simpleSearch = new LinkedHashSet<SModel>();
      for (SModel m : IterableUtil.asCollection(scope.getModels())) {
        if (m instanceof EditableSModel && ((EditableSModel) m).isChanged()) {
          simpleSearch.add(m);
        } else {
          current.add(m);
        }
      }

      for (FindUsagesParticipant participant : participants) {
        final Set<SModel> next = new HashSet<SModel>(current);
        participant.findUsages(
            current,
            nodes,
            consumer,
            new Consumer<SModel>() {
              @Override
              public void consume(SModel sModel) {
                assert !(sModel instanceof EditableSModel && ((EditableSModel) sModel).isChanged());
                next.remove(sModel);
              }
            });
        current = next;
        monitor.advance(1);
      }

      ProgressMonitor subMonitor = monitor.subTask(4, SubProgressKind.DEFAULT);
      subMonitor.start("", current.size() + simpleSearch.size());
      NodeUsageFinder nf = new NodeUsageFinder(nodes, consumer);
      showNoFastFindTipIfNeeded(current);
      current.addAll(simpleSearch);
      for (SModel m : current) {
        subMonitor.step(m.getModelName());
        nf.collectUsages(m);
        if (monitor.isCanceled()) {
          break;
        }
        subMonitor.advance(1);
      }
      subMonitor.done();
    } finally {
      monitor.done();
    }
    return rv;
  }
Example #9
0
  @Test
  public void testDependencyInScope() {
    Solution s1 = createSolution();
    Solution s2 = createSolution();

    s1.addDependency(s2.getModuleReference(), false);

    assertTrue(new GlobalModuleDependenciesManager(s1).getModules(Deptype.VISIBLE).contains(s2));
    assertTrue(IterableUtil.asCollection(s1.getScope().getVisibleModules()).contains(s2));
  }
Example #10
0
 public static List<SNode> removeAllChildren(SNode parent, String role) {
   if (parent == null) {
     return jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations.EMPTY_LIST;
   }
   Iterable<? extends SNode> children = parent.getChildren(role);
   for (SNode child : children) {
     parent.removeChild(child);
   }
   return IterableUtil.asList(children);
 }
Example #11
0
 public org.jetbrains.mps.openapi.model.SNode getRoot(int oneBasedIndex) {
   assert myModel != null : "call createModel() first";
   for (SNode r : myModel.getRootNodes()) {
     if (--oneBasedIndex > 0) {
       continue;
     }
     return r;
   }
   throw new IllegalArgumentException(
       Integer.toString(IterableUtil.asCollection(myModel.getRootNodes()).size()));
 }
Example #12
0
 public boolean match(SNode nodeToMatch) {
   {
     SNode nodeToMatch_7fbm30_a1a0a0 = nodeToMatch;
     if (!("jetbrains.mps.baseLanguage.structure.NotEqualsExpression"
         .equals(nodeToMatch_7fbm30_a1a0a0.getConcept().getQualifiedName()))) {
       return false;
     }
     {
       String childRole_7fbm30__2 = "leftExpression";
       if (!(PatternUtil.hasNChildren(nodeToMatch_7fbm30_a1a0a0, childRole_7fbm30__2, 1))) {
         return false;
       }
       {
         SNode childVar_7fbm30_a0b0a0a =
             IterableUtil.get(nodeToMatch_7fbm30_a1a0a0.getChildren(childRole_7fbm30__2), 0);
         {
           SNode nodeToMatch_7fbm30_a0b0a0a = childVar_7fbm30_a0b0a0a;
           if (!("jetbrains.mps.baseLanguage.structure.NullLiteral"
               .equals(nodeToMatch_7fbm30_a0b0a0a.getConcept().getQualifiedName()))) {
             return false;
           }
         }
       }
     }
     {
       String childRole_7fbm30__3 = "rightExpression";
       if (!(PatternUtil.hasNChildren(nodeToMatch_7fbm30_a1a0a0, childRole_7fbm30__3, 1))) {
         return false;
       }
       {
         SNode childVar_7fbm30_a0b0a0a_0 =
             IterableUtil.get(nodeToMatch_7fbm30_a1a0a0.getChildren(childRole_7fbm30__3), 0);
         {
           SNode nodeToMatch_7fbm30_a0b0a0a_0 = childVar_7fbm30_a0b0a0a_0;
           patternVar_p = nodeToMatch_7fbm30_a0b0a0a_0;
         }
       }
     }
   }
   return true;
 }
Example #13
0
 private void removeDescendantChanges(SNodeId parentId, String role) {
   SNode oldNode = getOldNode(parentId);
   assert oldNode != null;
   List<? extends SNode> children = IterableUtil.asList(oldNode.getChildren(role));
   ListSequence.fromList(children)
       .visitAll(
           new IVisitor<SNode>() {
             public void visit(SNode c) {
               removeDescendantChanges(c.getNodeId());
             }
           });
 }
Example #14
0
  @Test
  public void testUsedLanguageDependencyNotInScope() {
    Solution s1 = createSolution();

    Solution ld = createSolution();
    Language l1 = createLanguage();
    l1.addDependency(ld.getModuleReference(), true);

    s1.addUsedLanguage(l1.getModuleReference());

    assertFalse(new GlobalModuleDependenciesManager(s1).getModules(Deptype.VISIBLE).contains(ld));
    assertFalse(IterableUtil.asCollection(s1.getScope().getVisibleModules()).contains(ld));
  }
Example #15
0
 @Override
 public Iterable<SModel> getModels() {
   List<SModel> result = new ArrayList<SModel>();
   synchronized (LOCK) {
     initialize();
     for (IModule module : myVisibleModules) {
       result.addAll(IterableUtil.asCollection(module.getModels()));
     }
     for (Language language : myUsedLanguages) {
       result.addAll(language.getModels()); // todo: ?
       result.addAll(language.getAccessoryModels());
     }
   }
   return result;
 }
Example #16
0
 private boolean nodeGroupChangesSymmetric(NodeGroupChange mine, NodeGroupChange repository) {
   if (mine.getBegin() == repository.getBegin() && mine.getEnd() == repository.getEnd()) {
     if (mine.getResultEnd() - mine.getResultBegin()
         == repository.getResultEnd() - repository.getResultBegin()) {
       List<? extends SNode> myChildren =
           IterableUtil.asList(
               myMyModel.getNode(mine.getParentNodeId()).getChildren(mine.getRole()));
       List<? extends SNode> repositoryChildren =
           IterableUtil.asList(
               myRepositoryModel
                   .getNode(repository.getParentNodeId())
                   .getChildren(repository.getRole()));
       for (int o = 0; o < mine.getResultEnd() - mine.getResultBegin(); o++) {
         if (!(SNodeCompare.nodeEquals(
             myChildren.get(mine.getResultBegin() + o),
             repositoryChildren.get(repository.getResultBegin() + o)))) {
           return false;
         }
       }
       return true;
     }
   }
   return false;
 }
 public void applyNonTypeSystemRulesToRoot(
     TypeCheckingContext typeCheckingContext, SNode rootNode) {
   if (rootNode == null) return;
   doInvalidate();
   try {
     Queue<SNode> frontier = new LinkedList<SNode>();
     frontier.add(rootNode);
     while (!(frontier.isEmpty())) {
       SNode sNode = frontier.remove();
       applyNonTypesystemRulesToNode(sNode, typeCheckingContext);
       frontier.addAll(IterableUtil.asCollection(sNode.getChildren()));
     }
     // all error reporters must be simple reporters, no error expansion needed
   } finally {
     setInvalidationWasPerformed(false);
   }
 }
Example #18
0
 public boolean match(SNode nodeToMatch) {
   {
     SNode nodeToMatch_7fbm30_a0a = nodeToMatch;
     if (!("jetbrains.mps.baseLanguage.structure.AssertStatement"
         .equals(nodeToMatch_7fbm30_a0a.getConcept().getQualifiedName()))) {
       return false;
     }
     {
       String childRole_7fbm30_ = "condition";
       if (!(PatternUtil.hasNChildren(nodeToMatch_7fbm30_a0a, childRole_7fbm30_, 1))) {
         return false;
       }
       {
         SNode childVar_7fbm30_a0a0 =
             IterableUtil.get(nodeToMatch_7fbm30_a0a.getChildren(childRole_7fbm30_), 0);
         {
           SNode nodeToMatch_7fbm30_a0a0 = childVar_7fbm30_a0a0;
           {
             boolean orMatches = false;
             GeneratedMatchingPattern orPattern;
             orPattern =
                 new RuleAssertNotNull.Pattern_7fbm30_a0a
                     .Pattern_7fbm30_a0a0a2a1a1a1a1a0a1a1a0a0a0a();
             if (orPattern.match(nodeToMatch_7fbm30_a0a0)) {
               orMatches = true;
               myOrPattern_7fbm30_a0a0 = orPattern;
             }
             orPattern =
                 new RuleAssertNotNull.Pattern_7fbm30_a0a
                     .Pattern_7fbm30_a0a0a3a1a1a1a1a0a1a1a0a0a0a();
             if (orPattern.match(nodeToMatch_7fbm30_a0a0)) {
               orMatches = true;
               myOrPattern_7fbm30_a0a0 = orPattern;
             }
             if (!(orMatches)) {
               return false;
             }
           }
         }
         this.patternVar_action_var_5730083271929373007 = childVar_7fbm30_a0a0;
       }
     }
   }
   return true;
 }
 public boolean match(SNode nodeToMatch) {
   {
     SNode nodeToMatch_6isygg_a0a0a0 = nodeToMatch;
     if (!(MetaAdapterFactory.getConcept(
             0xf3061a5392264cc5L,
             0xa443f952ceaf5816L,
             0x101de48bf9eL,
             "jetbrains.mps.baseLanguage.structure.ClassifierType")
         .equals(nodeToMatch_6isygg_a0a0a0.getConcept()))) {
       return false;
     }
     {
       SNodeReference pointer = SNODE_POINTER_w1n2qe_a0a0a0a0b0b0a0b0a0a0a0c7;
       if (!(PatternUtil.matchReferentWithNode(
           pointer,
           nodeToMatch_6isygg_a0a0a0.getReferenceTarget(
               MetaAdapterFactory.getReferenceLink(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x101de48bf9eL,
                   0x101de490babL,
                   "classifier"))))) {
         return false;
       }
     }
     {
       SContainmentLink childRole_6isygg_ =
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x101de48bf9eL,
               0x102419671abL,
               "parameter");
       if (!(PatternUtil.hasNChildren(nodeToMatch_6isygg_a0a0a0, childRole_6isygg_, 1))) {
         return false;
       }
       {
         SNode childVar_6isygg_a0a0a0a =
             IterableUtil.get(nodeToMatch_6isygg_a0a0a0.getChildren(childRole_6isygg_), 0);
         this.patternVar_elem = childVar_6isygg_a0a0a0a;
       }
     }
   }
   return true;
 }
 public boolean match(SNode nodeToMatch) {
   {
     SNode nodeToMatch_twopzc_a0a = nodeToMatch;
     if (!("jetbrains.mps.baseLanguage.collections.structure.SetType"
         .equals(nodeToMatch_twopzc_a0a.getConcept().getQualifiedName()))) {
       return false;
     }
     {
       String childRole_twopzc_ = "elementType";
       if (!(PatternUtil.hasNChildren(nodeToMatch_twopzc_a0a, childRole_twopzc_, 1))) {
         return false;
       }
       {
         SNode childVar_twopzc_a0a0 =
             IterableUtil.get(nodeToMatch_twopzc_a0a.getChildren(childRole_twopzc_), 0);
         this.patternVar_elementType = childVar_twopzc_a0a0;
       }
     }
   }
   return true;
 }
Example #21
0
  @Override
  public Set<SReference> search(
      Set<SNode> nodes, SearchScope scope, @NotNull ProgressMonitor monitor) {
    CollectConsumer<SReference> consumer = new CollectConsumer(new HashSet<SReference>());
    Collection<FindUsagesParticipant> participants =
        FastFindUsagesRegistry.getInstance().getParticipants();

    monitor.start("Finding usages...", participants.size() + 4);
    try {
      Collection<SModel> current = IterableUtil.asCollection(scope.getModels());
      for (FindUsagesParticipant participant : participants) {
        final Set<SModel> next = new HashSet<SModel>(current);
        participant.findUsages(
            current,
            nodes,
            consumer,
            new Consumer<SModel>() {
              @Override
              public void consume(SModel sModel) {
                next.remove(sModel);
              }
            });
        current = next;
        monitor.advance(1);
      }

      ProgressMonitor subMonitor = monitor.subTask(4, SubProgressKind.DEFAULT);
      subMonitor.start("", current.size());
      for (SModel m : current) {
        subMonitor.step(m.getModelName());
        FindUsagesManager.collectUsages(m, nodes, consumer);
        if (monitor.isCanceled()) break;
        subMonitor.advance(1);
      }
      subMonitor.done();
    } finally {
      monitor.done();
    }
    return (Set<SReference>) consumer.getResult();
  }
Example #22
0
 private static List<SNode> allNodesIncludingImported(
     SModel sModel, boolean roots, @Nullable SAbstractConcept concept) {
   List<SModel> modelsList = new ArrayList<SModel>();
   modelsList.add(sModel);
   List<SModel> modelDescriptors = jetbrains.mps.smodel.SModelOperations.allImportedModels(sModel);
   for (SModel descriptor : modelDescriptors) {
     modelsList.add(descriptor);
   }
   List<SNode> resultNodes = new ArrayList<SNode>();
   final Condition<SNode> instanceCondition =
       (concept == null ? null : new InstanceOfCondition(concept));
   for (SModel aModel : modelsList) {
     if (concept == null || roots) {
       ConditionalIterable<SNode> nodes =
           new ConditionalIterable<SNode>(
               (roots ? aModel.getRootNodes() : SNodeUtil.getDescendants(aModel)),
               instanceCondition);
       resultNodes.addAll(IterableUtil.asList(nodes));
     } else {
       resultNodes.addAll(jetbrains.mps.smodel.SModelOperations.getNodes(aModel, concept));
     }
   }
   return resultNodes;
 }
Example #23
0
 public boolean match(SNode nodeToMatch) {
   {
     SNode nodeToMatch_xihehy_a0a1a2c = nodeToMatch;
     if (!(MetaAdapterFactory.getConcept(
             0xf3061a5392264cc5L,
             0xa443f952ceaf5816L,
             0x116b46a08c4L,
             "jetbrains.mps.baseLanguage.structure.DotExpression")
         .equals(nodeToMatch_xihehy_a0a1a2c.getConcept()))) {
       return false;
     }
     {
       SContainmentLink childRole_xihehy_ =
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x116b46a08c4L,
               0x116b46a4416L,
               "operand");
       if (!(PatternUtil.hasNChildren(nodeToMatch_xihehy_a0a1a2c, childRole_xihehy_, 1))) {
         return false;
       }
       {
         SNode childVar_xihehy_a0a0b0c2 =
             IterableUtil.get(nodeToMatch_xihehy_a0a1a2c.getChildren(childRole_xihehy_), 0);
         {
           SNode nodeToMatch_xihehy_a0a0b0c2 = childVar_xihehy_a0a0b0c2;
           if (!(MetaAdapterFactory.getConcept(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0xf940c80846L,
                   "jetbrains.mps.baseLanguage.structure.StaticFieldReference")
               .equals(nodeToMatch_xihehy_a0a0b0c2.getConcept()))) {
             return false;
           }
           patternVar_className =
               nodeToMatch_xihehy_a0a0b0c2.getReferenceTarget(
                   MetaAdapterFactory.getReferenceLink(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0xf940c80846L,
                       0x10a75869f9bL,
                       "classifier"));
           patternVar_field =
               nodeToMatch_xihehy_a0a0b0c2.getReferenceTarget(
                   MetaAdapterFactory.getReferenceLink(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0xf8c77f1e98L,
                       0xf8cc6bf960L,
                       "variableDeclaration"));
         }
       }
     }
     {
       SContainmentLink childRole_xihehy__0 =
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x116b46a08c4L,
               0x116b46b36c4L,
               "operation");
       if (!(PatternUtil.hasNChildren(nodeToMatch_xihehy_a0a1a2c, childRole_xihehy__0, 1))) {
         return false;
       }
       {
         SNode childVar_xihehy_a0a0b0c2_0 =
             IterableUtil.get(nodeToMatch_xihehy_a0a1a2c.getChildren(childRole_xihehy__0), 0);
         {
           SNode nodeToMatch_xihehy_a0a0b0c2_0 = childVar_xihehy_a0a0b0c2_0;
           if (!(MetaAdapterFactory.getConcept(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x118154a6332L,
                   "jetbrains.mps.baseLanguage.structure.InstanceMethodCallOperation")
               .equals(nodeToMatch_xihehy_a0a0b0c2_0.getConcept()))) {
             return false;
           }
           patternVar_method =
               nodeToMatch_xihehy_a0a0b0c2_0.getReferenceTarget(
                   MetaAdapterFactory.getReferenceLink(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0x11857355952L,
                       0xf8c78301adL,
                       "baseMethodDeclaration"));
           {
             SContainmentLink childRole_xihehy__1 =
                 MetaAdapterFactory.getContainmentLink(
                     0xf3061a5392264cc5L,
                     0xa443f952ceaf5816L,
                     0x11857355952L,
                     0xf8c78301aeL,
                     "actualArgument");
             if (!(PatternUtil.hasNChildren(
                 nodeToMatch_xihehy_a0a0b0c2_0, childRole_xihehy__1, 1))) {
               return false;
             }
             {
               SNode childVar_xihehy_a0a0a1a2c =
                   IterableUtil.get(
                       nodeToMatch_xihehy_a0a0b0c2_0.getChildren(childRole_xihehy__1), 0);
               {
                 SNode nodeToMatch_xihehy_a0a0a1a2c = childVar_xihehy_a0a0a1a2c;
                 if (!(MetaAdapterFactory.getConcept(
                         0xf3061a5392264cc5L,
                         0xa443f952ceaf5816L,
                         0xf93d565d10L,
                         "jetbrains.mps.baseLanguage.structure.StringLiteral")
                     .equals(nodeToMatch_xihehy_a0a0a1a2c.getConcept()))) {
                   return false;
                 }
                 patternVar_printed =
                     SNodeAccessUtil.getProperty(
                         nodeToMatch_xihehy_a0a0a1a2c,
                         MetaAdapterFactory.getProperty(
                             0xf3061a5392264cc5L,
                             0xa443f952ceaf5816L,
                             0xf93d565d10L,
                             0xf93d565d11L,
                             "value"));
               }
             }
           }
         }
       }
     }
   }
   return true;
 }
Example #24
0
 public boolean match(SNode nodeToMatch) {
   {
     SNode nodeToMatch_x583g4_a0a0a78 = nodeToMatch;
     if (!("jetbrains.mps.core.xml.structure.XmlElement"
         .equals(nodeToMatch_x583g4_a0a0a78.getConcept().getQualifiedName()))) {
       return false;
     }
     if (!("classpath"
         .equals(SNodeAccessUtil.getProperty(nodeToMatch_x583g4_a0a0a78, "tagName")))) {
       return false;
     }
     {
       String childRole_x583g4__5 = "content";
       if (!(PatternUtil.hasNChildren(nodeToMatch_x583g4_a0a0a78, childRole_x583g4__5, 1))) {
         return false;
       }
       {
         SNode childVar_x583g4_a0a0a0jd =
             IterableUtil.get(nodeToMatch_x583g4_a0a0a78.getChildren(childRole_x583g4__5), 0);
         {
           SNode nodeToMatch_x583g4_a0a0a0jd = childVar_x583g4_a0a0a0jd;
           if (!("jetbrains.mps.core.xml.structure.XmlElement"
               .equals(nodeToMatch_x583g4_a0a0a0jd.getConcept().getQualifiedName()))) {
             return false;
           }
           if (!("true"
               .equals(
                   SNodeAccessUtil.getProperty(
                       nodeToMatch_x583g4_a0a0a0jd, "shortEmptyNotation")))) {
             return false;
           }
           if (!("pathelement"
               .equals(SNodeAccessUtil.getProperty(nodeToMatch_x583g4_a0a0a0jd, "tagName")))) {
             return false;
           }
           {
             String childRole_x583g4__6 = "attributes";
             if (!(PatternUtil.hasNChildren(
                 nodeToMatch_x583g4_a0a0a0jd, childRole_x583g4__6, 1))) {
               return false;
             }
             {
               SNode childVar_x583g4_a0a0a0a78 =
                   IterableUtil.get(
                       nodeToMatch_x583g4_a0a0a0jd.getChildren(childRole_x583g4__6), 0);
               {
                 SNode nodeToMatch_x583g4_a0a0a0a78 = childVar_x583g4_a0a0a0a78;
                 if (!("jetbrains.mps.core.xml.structure.XmlAttribute"
                     .equals(nodeToMatch_x583g4_a0a0a0a78.getConcept().getQualifiedName()))) {
                   return false;
                 }
                 if (!("path"
                     .equals(
                         SNodeAccessUtil.getProperty(
                             nodeToMatch_x583g4_a0a0a0a78, "attrName")))) {
                   return false;
                 }
                 {
                   String childRole_x583g4__7 = "value";
                   if (!(PatternUtil.hasNChildren(
                       nodeToMatch_x583g4_a0a0a0a78, childRole_x583g4__7, 1))) {
                     return false;
                   }
                   {
                     SNode childVar_x583g4_a0a0a0a0jd =
                         IterableUtil.get(
                             nodeToMatch_x583g4_a0a0a0a78.getChildren(childRole_x583g4__7), 0);
                     this.patternVar_pathvalue = childVar_x583g4_a0a0a0a0jd;
                   }
                 }
               }
             }
           }
         }
       }
     }
   }
   return true;
 }
Example #25
0
  private Iterable<SNode> getDependencies(SNode module, final boolean reexportOnly) {
    Iterable<SNode> dependencies =
        Sequence.fromIterable(
                SNodeOperations.ofConcept(
                    dependencies(module),
                    MetaAdapterFactory.getConcept(
                        0xcf935df46994e9cL,
                        0xa132fa109541cba3L,
                        0x48e82d508334b11aL,
                        "jetbrains.mps.build.mps.structure.BuildMps_ModuleDependencyOnModule")))
            .where(
                new IWhereFilter<SNode>() {
                  public boolean accept(SNode it) {
                    return (!(reexportOnly)
                        || SPropertyOperations.getBoolean(
                            it,
                            MetaAdapterFactory.getProperty(
                                0xcf935df46994e9cL,
                                0xa132fa109541cba3L,
                                0x48e82d508334b11aL,
                                0x48e82d5083341cc1L,
                                "reexport")));
                  }
                })
            .select(
                new ISelector<SNode, SNode>() {
                  public SNode select(SNode it) {
                    return SLinkOperations.getTarget(
                        it,
                        MetaAdapterFactory.getReferenceLink(
                            0xcf935df46994e9cL,
                            0xa132fa109541cba3L,
                            0x48e82d508334b11aL,
                            0x48e82d5083341cb9L,
                            "module"));
                  }
                });

    // add extended langs
    dependencies =
        Sequence.fromIterable(dependencies)
            .concat(
                Sequence.fromIterable(
                        SNodeOperations.ofConcept(
                            dependencies(module),
                            MetaAdapterFactory.getConcept(
                                0xcf935df46994e9cL,
                                0xa132fa109541cba3L,
                                0x3b60c4a45c19032eL,
                                "jetbrains.mps.build.mps.structure.BuildMps_ModuleDependencyExtendLanguage")))
                    .select(
                        new ISelector<SNode, SNode>() {
                          public SNode select(SNode it) {
                            return SLinkOperations.getTarget(
                                it,
                                MetaAdapterFactory.getReferenceLink(
                                    0xcf935df46994e9cL,
                                    0xa132fa109541cba3L,
                                    0x3b60c4a45c19032eL,
                                    0x3b60c4a45c190330L,
                                    "language"));
                          }
                        }));

    if (reexportOnly) {
      return toOriginal(dependencies);
    }

    Iterable<SNode> usedDevkits =
        Sequence.fromIterable(includingExtended(usedDevkits(module))).toListSequence();
    if (trackDevkits) {
      SetSequence.fromSet(devkits).addSequence(Sequence.fromIterable(usedDevkits));
    }
    Iterable<SNode> solutionsFromDevkits =
        Sequence.fromIterable(usedDevkits)
            .translate(
                new ITranslator2<SNode, SNode>() {
                  public Iterable<SNode> translate(SNode it) {
                    return Sequence.fromIterable(
                            SNodeOperations.ofConcept(
                                SLinkOperations.getChildren(
                                    it,
                                    MetaAdapterFactory.getContainmentLink(
                                        0xcf935df46994e9cL,
                                        0xa132fa109541cba3L,
                                        0x4780308f5d2060eL,
                                        0x4780308f5d29d82L,
                                        "exports")),
                                MetaAdapterFactory.getConcept(
                                    0xcf935df46994e9cL,
                                    0xa132fa109541cba3L,
                                    0x4780308f5d29d7aL,
                                    "jetbrains.mps.build.mps.structure.BuildMps_DevKitExportSolution")))
                        .select(
                            new ISelector<SNode, SNode>() {
                              public SNode select(SNode iit) {
                                return SLinkOperations.getTarget(
                                    iit,
                                    MetaAdapterFactory.getReferenceLink(
                                        0xcf935df46994e9cL,
                                        0xa132fa109541cba3L,
                                        0x4780308f5d29d7aL,
                                        0x4780308f5d29d7bL,
                                        "solution"));
                              }
                            });
                  }
                });
    // "core" language is added in loadModules pre-script
    return toOriginal(
        IterableUtil.distinct(IterableUtil.merge(dependencies, solutionsFromDevkits)));
  }
Example #26
0
  private Iterable<SNode> getUsedLanguages(SNode module) {
    Iterable<SNode> usedLangs =
        Sequence.fromIterable(
                SNodeOperations.ofConcept(
                    dependencies(module),
                    MetaAdapterFactory.getConcept(
                        0xcf935df46994e9cL,
                        0xa132fa109541cba3L,
                        0x2c4467914643d2d2L,
                        "jetbrains.mps.build.mps.structure.BuildMps_ModuleDependencyUseLanguage")))
            .select(
                new ISelector<SNode, SNode>() {
                  public SNode select(SNode it) {
                    return SLinkOperations.getTarget(
                        it,
                        MetaAdapterFactory.getReferenceLink(
                            0xcf935df46994e9cL,
                            0xa132fa109541cba3L,
                            0x2c4467914643d2d2L,
                            0x2c4467914643d2d3L,
                            "language"));
                  }
                });

    Iterable<SNode> usedDevkits =
        Sequence.fromIterable(includingExtended(usedDevkits(module))).toListSequence();
    if (trackDevkits) {
      SetSequence.fromSet(devkits).addSequence(Sequence.fromIterable(usedDevkits));
    }
    Iterable<SNode> languagesFromDevkits =
        Sequence.fromIterable(usedDevkits)
            .translate(
                new ITranslator2<SNode, SNode>() {
                  public Iterable<SNode> translate(SNode it) {
                    return Sequence.fromIterable(
                            SNodeOperations.ofConcept(
                                SLinkOperations.getChildren(
                                    it,
                                    MetaAdapterFactory.getContainmentLink(
                                        0xcf935df46994e9cL,
                                        0xa132fa109541cba3L,
                                        0x4780308f5d2060eL,
                                        0x4780308f5d29d82L,
                                        "exports")),
                                MetaAdapterFactory.getConcept(
                                    0xcf935df46994e9cL,
                                    0xa132fa109541cba3L,
                                    0x4780308f5d29d6aL,
                                    "jetbrains.mps.build.mps.structure.BuildMps_DevKitExportLanguage")))
                        .select(
                            new ISelector<SNode, SNode>() {
                              public SNode select(SNode iit) {
                                return SLinkOperations.getTarget(
                                    iit,
                                    MetaAdapterFactory.getReferenceLink(
                                        0xcf935df46994e9cL,
                                        0xa132fa109541cba3L,
                                        0x4780308f5d29d6aL,
                                        0x4780308f5d29d73L,
                                        "language"));
                              }
                            });
                  }
                });

    // use "core" language is added in loadModules pre-script
    return toOriginalLangs(
        includingExtendedLanguages(IterableUtil.merge(usedLangs, languagesFromDevkits)));
  }
Example #27
0
    private void processChild(SModelChildEvent event, Map<SNode, Set<String>> childChanged) {
      SNode parent = event.getParent();
      if (parent.getModel() == null) {
        return;
      }
      final String childRole = event.getChildRole();

      // tyring to avoid update task execution for the same child role twice
      Set<String> childRoles = MapSequence.fromMap(childChanged).get(parent);
      if (childRoles == null) {
        childRoles = SetSequence.fromSet(new HashSet<String>());
        MapSequence.fromMap(childChanged).put(parent, childRoles);
      }
      if (SetSequence.fromSet(childRoles).contains(childRole)) {
        return;
      } else {
        SetSequence.fromSet(childRoles).addElement(childRole);
      }
      final SNodeId parentId = parent.getNodeId();

      final Wrappers._T<List<? extends SNode>> childrenRightAfterEvent =
          new Wrappers._T<List<? extends SNode>>(
              IterableUtil.asList(parent.getChildren(childRole)));
      childrenRightAfterEvent.value =
          ListSequence.fromList(childrenRightAfterEvent.value)
              .select(
                  new ISelector<SNode, SNode>() {
                    public SNode select(SNode n) {
                      return CopyUtil.copyAndPreserveId(n, false);
                    }
                  })
              .toListSequence();
      runUpdateTask(
          new _FunctionTypes._void_P0_E0() {
            public void invoke() {

              removeChanges(
                  parentId,
                  NodeGroupChange.class,
                  new _FunctionTypes._return_P1_E0<Boolean, NodeGroupChange>() {
                    public Boolean invoke(NodeGroupChange ch) {
                      return childRole.equals(ch.getRole());
                    }
                  });
              removeDescendantChanges(parentId, childRole);
              myLastParentAndNewChildrenIds =
                  MultiTuple.<SNodeId, List<SNodeId>>from(
                      parentId,
                      ListSequence.fromList(childrenRightAfterEvent.value)
                          .select(
                              new ISelector<SNode, SNodeId>() {
                                public SNodeId select(SNode n) {
                                  return n.getNodeId();
                                }
                              })
                          .toListSequence());
              buildAndAddChanges(
                  new _FunctionTypes._void_P1_E0<ChangeSetBuilder>() {
                    public void invoke(ChangeSetBuilder b) {
                      b.buildForNodeRole(
                          IterableUtil.asList(getOldNode(parentId).getChildren(childRole)),
                          childrenRightAfterEvent.value,
                          parentId,
                          childRole);
                    }
                  });
            }
          },
          parent,
          event);
    }