public List<?> createParameterObjects(
     SNode node, IOperationContext operationContext, EditorContext editorContext) {
   SAbstractConcept concept =
       MetaAdapterFactory.getConcept(
           0x7a5dda6291404668L,
           0xab76d5ed1746f2b2L,
           0x111b251a62aL,
           "jetbrains.mps.lang.typesystem.structure.ReportErrorStatement");
   AbstractModule module = ((AbstractModule) SNodeOperations.getModel(node).getModule());
   Set<SNode> errorInstances =
       FindUsagesManager.getInstance()
           .findInstances(
               module.getScope(),
               Collections.singleton(concept),
               true,
               new EmptyProgressMonitor());
   return SetSequence.fromSet(errorInstances)
       .toListSequence()
       .select(
           new ISelector<SNode, SNode>() {
             public SNode select(SNode it) {
               return SNodeOperations.cast(
                   it,
                   MetaAdapterFactory.getConcept(
                       0x7a5dda6291404668L,
                       0xab76d5ed1746f2b2L,
                       0x111b251a62aL,
                       "jetbrains.mps.lang.typesystem.structure.ReportErrorStatement"));
             }
           })
       .toListSequence();
 }
Beispiel #2
0
 public static Library getOrCreateAutoLibrary(
     AbstractModule usedModule, Project project, LibrariesContainer container) {
   Library library = getAutoLibrary(usedModule.getModuleReference(), project);
   if (library != null) {
     return library;
   }
   Set<VirtualFile> stubFiles = ModuleLibraryType.getModuleJars(usedModule);
   IFile descriptorFile = usedModule.getDescriptorFile();
   VirtualFile descriptorVirtualFile = null;
   if (descriptorFile != null) {
     descriptorVirtualFile = VirtualFileUtils.getOrCreateVirtualFile(descriptorFile);
   }
   return createAutoLibrary(
       usedModule.getModuleName(), stubFiles, descriptorVirtualFile, container);
 }
Beispiel #3
0
 @Nullable
 public static IFile getRealDescriptorFile(SModule m) {
   if (!(m instanceof AbstractModule)) {
     return null;
   }
   AbstractModule module = (AbstractModule) m;
   if (module.getModuleSourceDir() != null
       && module.getModuleDescriptor() != null
       && module.getModuleDescriptor().getDeploymentDescriptor() != null) {
     return module
         .getModuleSourceDir()
         .getDescendant(
             module.getModuleDescriptor().getDeploymentDescriptor().getDescriptorFile());
   }
   return null;
 }
  private VirtualFile[] getSelectedFiles() {
    List<VirtualFile> selectedFilesList = new LinkedList<VirtualFile>();

    // add selected model files
    List<SModelDescriptor> descriptors = getSelectedModels();
    if (descriptors != null) {
      for (SModelDescriptor descriptor : descriptors) {
        selectedFilesList.addAll(ModelUtil.getVFilesByModelDescriptor(descriptor));
      }
    }

    // add selected modules files
    List<SModule> modules = getSelectedModules();
    if (modules != null) {
      for (SModule m : modules) {
        if (!(m instanceof AbstractModule)) continue;
        AbstractModule module = (AbstractModule) m;
        IFile home = module.getBundleHome();
        if (home != null) {
          VirtualFile vfile = VirtualFileUtils.getVirtualFile(home);
          if (vfile != null) {
            selectedFilesList.add(vfile);
          }
        }
        IFile ifile = module.getDescriptorFile();
        if (ifile != null) {
          VirtualFile vfile = VirtualFileUtils.getVirtualFile(ifile);
          if (vfile != null) {
            selectedFilesList.add(vfile);
          }
        }
      }
    }

    if (selectedFilesList.size() == 0) {
      return null;
    }

    return selectedFilesList.toArray(new VirtualFile[selectedFilesList.size()]);
  }
Beispiel #5
0
 public void dispose() {
   super.dispose();
   ModelAccess.instance()
       .runWriteAction(
           new Runnable() {
             public void run() {
               EvaluationAuxModule.this.clearAll();
               MPSModuleRepository.getInstance().removeModule(EvaluationAuxModule.this);
               SModelRepository.getInstance().unRegisterModelDescriptors(EvaluationAuxModule.this);
               CleanupManager.getInstance().cleanup();
               // loaded stubs are removed from model repository
             }
           });
 }
Beispiel #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);
       }
     }
   }
 }
Beispiel #7
0
  void update(boolean refreshFiles) {
    ModelAccess.assertLegalWrite();

    List<ModuleHandle> moduleHandles =
        Collections.unmodifiableList(ModulesMiner.getInstance().collectModules(file, refreshFiles));
    myHandles.set(moduleHandles);
    List<SModule> loaded = new ArrayList<SModule>();
    for (ModuleHandle moduleHandle : moduleHandles) {
      SModule module = ModuleRepositoryFacade.createModule(moduleHandle, this);
      if (module != null) {
        loaded.add(module);
      }
    }
    for (SModule module : loaded) {
      ((AbstractModule) module).onModuleLoad();
    }
  }
 @Override
 protected void dependenciesChanged() {
   super.dependenciesChanged();
   if (!willLoad()) return;
   fireDependenciesChanged();
 }
Beispiel #9
0
 @Override
 public void dispose() {
   clearAll();
   super.dispose();
 }