public SearchResults find(SearchQuery query, ProgressMonitor monitor) {
    SearchResults<SNode> searchResults = new SearchResults<SNode>();
    IHolder holder = query.getObjectHolder();
    assert holder instanceof ModuleHolder;
    IModule module = ((ModuleHolder) holder).getObject();
    assert module instanceof Language;
    Language language = (Language) module;
    SModelDescriptor structureModel = language.getStructureModelDescriptor();
    if (structureModel == null) {
      return searchResults;
    }
    SModel sModel = structureModel.getSModel();
    if (sModel == null) {
      return searchResults;
    }
    if (sModel.rootsCount() == 0) {
      return searchResults;
    }
    List<SNode> roots = new LinkedList<SNode>();
    for (SNode root : sModel.roots()) {
      roots.add(root);
    }
    searchResults.getSearchedNodes().addAll(roots);

    monitor.start("", sModel.rootsCount() + 1);
    try {
      SearchResults<SModel> modelResults =
          FindUtils.getSearchResults(
              monitor.subTask(1),
              new SearchQuery(sModel, GlobalScopeMinusTransient.getInstance()),
              new ModelUsagesFinder());
      List<SModelDescriptor> models = new ArrayList<SModelDescriptor>();
      for (SearchResult<SModel> sModelSearchResult : modelResults.getSearchResults()) {
        models.add(sModelSearchResult.getObject().getModelDescriptor());
      }
      IScope scope = new ModelsOnlyScope(models.toArray(new SModelDescriptor[models.size()]));
      SearchResults results = new SearchResults();
      for (SNode node : roots) {
        if (monitor != null && 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();
    }
  }
Пример #2
0
 public static Iterable sourceNodesQuery_1220369573364040170(
     final IOperationContext operationContext, final SourceSubstituteMacroNodesContext _context) {
   List<SNode> result = new ArrayList<SNode>();
   List<Language> langs =
       SModelOperations.getLanguages(
           SNodeOperations.getModel(_context.getNode()), GlobalScope.getInstance());
   for (Language lang : langs) {
     for (ModuleReference mr : lang.getRuntimeModulesReferences()) {
       for (SModelDescriptor smd :
           MPSModuleRepository.getInstance().getModule(mr).getOwnModelDescriptors()) {
         SModel rtModel = smd.getSModel();
         for (SNode gwtmod :
             jetbrains.mps.lang.smodel.generator.smodelAdapter.SModelOperations.getRoots(
                 rtModel, "jetbrains.mps.gwt.client.structure.GWTModule")) {
           ListSequence.fromList(result).addElement(gwtmod);
         }
       }
     }
   }
   return result;
 }
Пример #3
0
 public void onCreate(SModelDescriptor model) {
   if (!model.getModule().getUsedLanguagesReferences().contains(BootstrapLanguages.UNITTEST)) {
     model.getModule().addUsedLanguage(BootstrapLanguages.UNITTEST);
   }
   model.getSModel().addLanguage(BootstrapLanguages.UNITTEST);
 }
Пример #4
0
 public SNode findRuleNode() {
   SModelDescriptor modelDescriptor =
       SModelRepository.getInstance().getModelDescriptor(SModelReference.fromString(myRuleModel));
   if (modelDescriptor == null) return null;
   return modelDescriptor.getSModel().getNodeById(myRuleId);
 }