コード例 #1
0
ファイル: BaseModuleValidator.java プロジェクト: sprig/MPS
  @Override
  public List<String> getErrors() {
    List<String> errors = new ArrayList<String>();
    Throwable loadException = myModule.getModuleDescriptor().getLoadException();
    if (loadException != null) {
      errors.add("Couldn't load module: " + loadException.getMessage());
      return errors;
    }

    ModuleDescriptor descriptor = myModule.getModuleDescriptor();
    // null?

    for (Dependency dep : descriptor.getDependencies()) {
      SModuleReference moduleRef = dep.getModuleRef();
      if (MPSModuleRepository.getInstance().getModule(moduleRef) == null) {
        errors.add("Can't find dependency: " + moduleRef.getModuleName());
      }
    }
    for (SModuleReference reference : descriptor.getUsedLanguages()) {
      if (ModuleRepositoryFacade.getInstance().getModule(reference, Language.class) == null) {
        errors.add("Can't find used language: " + reference.getModuleName());
      }
    }
    for (SModuleReference reference : descriptor.getUsedDevkits()) {
      if (MPSModuleRepository.getInstance().getModule(reference) == null) {
        errors.add("Can't find used devkit: " + reference.getModuleName());
      }
    }

    if (descriptor.getSourcePaths() != null && !myModule.isPackaged()) {
      for (String sourcePath : descriptor.getSourcePaths()) {
        IFile file = FileSystem.getInstance().getFileByPath(sourcePath);
        if (file == null || !file.exists()) {
          errors.add("Can't find source path: " + sourcePath);
        }
      }
    }
    if (descriptor.getAdditionalJavaStubPaths() != null) {
      for (String path : descriptor.getAdditionalJavaStubPaths()) {
        IFile file = FileSystem.getInstance().getFileByPath(path);
        if (file == null || !file.exists()) {
          if (new File(path).exists()) {
            errors.add("Idea VFS is not up-to-date. Can't find library: " + path);
          } else {
            errors.add("Can't find library: " + path);
          }
        }
      }
    }

    // todo: =(
    if (!(myModule instanceof Generator)) {
      errors.addAll(validateDependenciesOnGenerators());
    }

    return errors;
  }
コード例 #2
0
 protected void removeSolution(String name) {
   ModuleReference ref = new ModuleReference(null, ModuleId.foreign(name));
   MPSModuleRepository repository = MPSModuleRepository.getInstance();
   IModule m = ModuleRepositoryFacade.getInstance().getModule(ref);
   if (m == null) {
     return;
   }
   repository.unregisterModule(m, this);
 }
コード例 #3
0
 protected void removeSolution(String name) {
   SModuleReference ref =
       new jetbrains.mps.project.structure.modules.ModuleReference(null, ModuleId.foreign(name));
   MPSModuleRepository repository = MPSModuleRepository.getInstance();
   SModule m = ModuleRepositoryFacade.getInstance().getModule(ref);
   if (m == null) {
     return;
   }
   repository.unregisterModule(m, this);
 }
コード例 #4
0
ファイル: NodeNodeData.java プロジェクト: sasundaresan/MPS
 @Override
 public void write(Element element, Project project) throws CantSaveSomethingException {
   super.write(element, project);
   if (myNodePointer.resolve(MPSModuleRepository.getInstance()) != null) {
     Element nodeXML = new Element(NODE);
     nodeXML.addContent(
         ComponentsUtil.nodeToElement(myNodePointer.resolve(MPSModuleRepository.getInstance())));
     element.addContent(nodeXML);
   } else {
     throw new CantSaveSomethingException();
   }
 }
コード例 #5
0
 @NotNull
 public static List<IModule> getVisibleModules_4040588429969394431(IScope scope) {
   List<IModule> result = ListSequence.fromList(new ArrayList<IModule>());
   ListSequence.fromList(result)
       .addSequence(SetSequence.fromSet(MPSModuleRepository.getInstance().getAllModules()));
   return result;
 }
コード例 #6
0
ファイル: CreateGroupsBuilder.java プロジェクト: brigand/MPS
  public static List<DefaultActionGroup> getCreateGroups(
      SNodeReference baseNode,
      Collection<RelationDescriptor> possibleTabs,
      @Nullable RelationDescriptor currentAspect,
      NodeChangeCallback callback) {
    List<DefaultActionGroup> groups = new ArrayList<DefaultActionGroup>();

    List<RelationDescriptor> tabs = new ArrayList<RelationDescriptor>(possibleTabs);
    Collections.sort(tabs, new RelationComparator());

    if (currentAspect != null) {
      tabs.remove(currentAspect);
      tabs.add(0, currentAspect);
    }

    for (final RelationDescriptor d : tabs) {
      List<SNode> nodes = d.getNodes(baseNode.resolve(MPSModuleRepository.getInstance()));
      if (!nodes.isEmpty() && d.isSingle()) continue;

      DefaultActionGroup group = getCreateGroup(baseNode, callback, d);
      if (group == null) continue;

      if (tabs.indexOf(d) == 0) {
        group.setPopup(false);
      }

      groups.add(group);
    }
    return groups;
  }
コード例 #7
0
 public SNode getTemplateNodeForLogging() {
   return myScript != null
       ? myScript
       : myScriptPointer != null
           ? myScriptPointer.resolve(MPSModuleRepository.getInstance())
           : null;
 }
 protected boolean checkLibraryName(String libraryName) {
   if (MPSModuleRepository.getInstance().getModuleByUID(libraryName) != null) {
     myThis.getDialog().setErrorText("Duplicate library name: " + libraryName);
     return false;
   }
   return true;
 }
  CodeOrchestraStreamHandler(
      SModelDescriptor modelDescriptor,
      IFile outputDir,
      CodeOrchestraGenerationFileProcessor processor) {
    myOriginalOutputDir = outputDir;

    CodeOrchestraGenerateManager codeOrchestraGenerateManager =
        processor.getProject().getComponent(CodeOrchestraGenerateManager.class);
    CodeOrchestraGenerationContext currentContext =
        codeOrchestraGenerateManager.getCurrentContext();
    if (currentContext == null) {
      myOutputDir = outputDir;
      myCachesOutputDir = FileGenerationUtil.getCachesDir(outputDir);
    } else {
      ModuleReference rootModuleReference = currentContext.getRootModule();

      // We override the output path for the AS & JS modules
      if (currentContext.isSingleOutputContext()) {
        IModule rootModule = MPSModuleRepository.getInstance().getModule(rootModuleReference);
        myOutputDir =
            FileSystem.getInstance().getFileByPath(rootModule.getOutputFor(modelDescriptor));
        myCachesOutputDir = FileGenerationUtil.getCachesDir(myOutputDir);
      } else {
        myOutputDir = outputDir;
        myCachesOutputDir = FileGenerationUtil.getCachesDir(outputDir);
      }
    }

    myModelDescriptor = modelDescriptor;
    myProcessor = processor;
  }
コード例 #10
0
 @Nullable
 public static IModule call_getModule_4040588429969043137(SNode thisNode) {
   if (SPropertyOperations.getString(thisNode, "moduleId") == null) {
     return null;
   }
   return MPSModuleRepository.getInstance()
       .getModuleById(ModuleId.fromString(SPropertyOperations.getString(thisNode, "moduleId")));
 }
コード例 #11
0
ファイル: ModuleNavigatable.java プロジェクト: blutkind/MPS
  @Override
  protected void doNavigate(boolean focus) {
    IModule module = MPSModuleRepository.getInstance().getModule(moduleReference);
    if (module == null) return;

    ModuleContext context = new ModuleContext(module, project);
    NavigationSupport.getInstance().selectInTree(context, module, focus);
  }
コード例 #12
0
 public String getItemLabel(Object value) {
   ModuleReference moduleReference = (ModuleReference) value;
   final IModule module = MPSModuleRepository.getInstance().getModule(moduleReference);
   if (module == null) {
     String moduleName = moduleReference.getModuleFqName();
     return (moduleName.equals("") ? "<no name>" : moduleName);
   }
   return moduleReference.getModuleFqName();
 }
コード例 #13
0
 protected void addListeners() {
   VirtualFileManager.getInstance().addVirtualFileManagerListener(myRefreshListener);
   SModelRepository.getInstance().addModelRepositoryListener(mySModelRepositoryListener);
   ModelAccess.instance().addCommandListener(myModelAccessListener);
   MPSModuleRepository.getInstance().addModuleRepositoryListener(myRepositoryListener);
   if (IMakeService.INSTANCE.isSessionActive()) {
     IMakeService.INSTANCE.get().addListener(myMakeNotificationListener);
   }
   ClassLoaderManager.getInstance().addReloadHandler(myReloadListener);
 }
コード例 #14
0
 protected void removeListeners() {
   ClassLoaderManager.getInstance().removeReloadHandler(myReloadListener);
   SModelRepository.getInstance().removeModelRepositoryListener(mySModelRepositoryListener);
   ModelAccess.instance().removeCommandListener(myModelAccessListener);
   MPSModuleRepository.getInstance().removeModuleRepositoryListener(myRepositoryListener);
   if (IMakeService.INSTANCE.hasMakeService()) {
     IMakeService.INSTANCE.get().removeListener(myMakeNotificationListener);
   }
   VirtualFileManager.getInstance().removeVirtualFileManagerListener(myRefreshListener);
 }
コード例 #15
0
ファイル: CellAction_PasteNode.java プロジェクト: yan96in/MPS
  @Override
  public boolean canExecute(EditorContext context) {
    Selection selection = context.getSelectionManager().getSelection();
    List<SNode> pasteNodes =
        CopyPasteUtil.getNodesFromClipboard(selection.getSelectedNodes().get(0).getModel());

    if (pasteNodes == null || pasteNodes.isEmpty()) {
      // it used to be ok because conversion would be invoked in this case
      return false;
    }

    boolean disposed = false;
    for (SNode node : selection.getSelectedNodes()) {
      if (!SNodeUtil.isAccessible(node, MPSModuleRepository.getInstance())) {
        disposed = true;
        break;
      }
    }

    boolean canPasteWithRemove =
        !disposed && canPasteViaNodePasterWithRemove(selection.getSelectedNodes(), pasteNodes);
    if (selection instanceof SingularSelection
        && (selection instanceof EditorCellLabelSelection
                && !isCompletelySelected((EditorCellLabelSelection) selection)
            || (selection instanceof EditorCellSelection && !canPasteWithRemove))) {
      EditorCell selectedCell = getCellToPasteTo(context.getSelectedCell());
      if (selectedCell == null) {
        return false;
      }
      SNode selectedNode = selectedCell.getSNode();
      if (selectedNode == null
          || !(SNodeUtil.isAccessible(selectedNode, MPSModuleRepository.getInstance()))) {
        return false;
      }

      return canPasteViaNodePaster(selectedCell, pasteNodes);

    } else if ((selection instanceof MultipleSelection || selection instanceof EditorCellSelection)
        && canPasteWithRemove) {
      return true;
    }
    return false;
  }
コード例 #16
0
 @Override
 public SLink findLink(String role) {
   SNode ld =
       new ConceptAndSuperConceptsScope(getConcept().resolve(MPSModuleRepository.getInstance()))
           .getLinkDeclarationByRole(role);
   return (ld == null
       ? null
       : new SLinkNodeAdapter(
           SNodeOperations.cast(ld, "jetbrains.mps.lang.structure.structure.LinkDeclaration")));
 }
コード例 #17
0
ファイル: AbstractModule.java プロジェクト: JetBrains/MPS
 @Override
 public Iterable<FileSystemListener> getListenerDependencies() {
   List<FileSystemListener> listeners = new ArrayList<FileSystemListener>();
   for (MPSModuleOwner owner : MPSModuleRepository.getInstance().getOwners(this)) {
     if (owner instanceof FileSystemListener) {
       listeners.add((FileSystemListener) owner);
     }
   }
   return listeners.isEmpty() ? null : listeners;
 }
コード例 #18
0
  public void createModule(final SModule module) {
    if (myModuleMap.containsKey(module)) {
      return;
    }

    final TransientModelsModule transientModelsModule =
        new TransientModelsModule(module, TransientModelsProvider.this);
    MPSModuleRepository.getInstance().registerModule(transientModelsModule, myOwner);
    myModuleMap.put(module, transientModelsModule);
  }
コード例 #19
0
 private Set<SNode> getDependenciesToInvalidate(SModel model) {
   Set<SNode> result = new HashSet<SNode>();
   for (SNode dependency : MapSequence.fromMap(myDependenciesToNodes).keySet()) {
     if (!(SNodeUtil.isAccessible(dependency, MPSModuleRepository.getInstance()))
         || SNodeOperations.getModel(dependency) == model) {
       SetSequence.fromSet(result).addElement(dependency);
     }
   }
   return result;
 }
コード例 #20
0
 public StubPath addStubPath(String stubPath) {
   StubPath path = new StubPath(stubPath, STUBS_MANAGER);
   if (myStubPaths.contains(path)) {
     path = null;
   } else {
     myStubPaths.add(path);
   }
   updateClassPath();
   MPSModuleRepository.getInstance().fireModuleChanged(this);
   return path;
 }
コード例 #21
0
 private EditableSModel getContextModel(AbstractTreeNode selectedNode) {
   if (selectedNode instanceof MPSPsiElementTreeNode) {
     MPSPsiNodeBase value = ((MPSPsiElementTreeNode) selectedNode).getValue();
     return getModel(value);
   } else if (selectedNode instanceof MPSPsiModelTreeNode) {
     MPSPsiModel psiModel = ((MPSPsiModelTreeNode) selectedNode).getModel();
     SModel sModel = psiModel.getSModelReference().resolve(MPSModuleRepository.getInstance());
     return (EditableSModel) sModel;
   }
   return null;
 }
コード例 #22
0
  public void stopListening() {
    ModelAccess.instance().removeCommandListener(myCommandListener);

    myNodes.clear();
    myModels.clear();
    myModules.clear();

    GlobalSModelEventsManager.getInstance().removeGlobalCommandListener(myModelListener);
    SModelRepository.getInstance().removeModelRepositoryListener(myModelRepositoryListener);
    MPSModuleRepository.getInstance().removeRepositoryListener(myModuleRepositoryListener);
  }
コード例 #23
0
 @Override
 public Iterable<SDependency> getDeclaredDependencies() {
   Iterable<SModule> modules = MPSModuleRepository.getInstance().getModules();
   return Sequence.fromIterable(modules)
       .select(
           new ISelector<SModule, SDependency>() {
             public SDependency select(SModule it) {
               return ((SDependency) new SDependencyImpl(it, SDependencyScope.DEFAULT, false));
             }
           });
 }
コード例 #24
0
ファイル: TypeContextManager.java プロジェクト: sprig/MPS
 public void modelsReplaced(Set<SModel> replacedModels) {
   for (SModel md : replacedModels) {
     if (!myListeningForModels.contains(md)) {
       continue;
     }
     SModelReference modelRef = md.getReference();
     synchronized (myLock) {
       for (SNodeReference nodePointer :
           new ArrayList<SNodeReference>(myTypeCheckingContexts.keySet())) {
         if (nodePointer == null) continue;
         SNode node = nodePointer.resolve(MPSModuleRepository.getInstance());
         if (node == null
             || !SNodeUtil.isAccessible(node, MPSModuleRepository.getInstance())
             || modelRef.equals(nodePointer.getModelReference())) {
           removeContextForNode(nodePointer);
         }
       }
     }
   }
 }
コード例 #25
0
ファイル: CreateGroupsBuilder.java プロジェクト: brigand/MPS
  public static DefaultActionGroup getCreateGroup(
      SNodeReference baseNode, NodeChangeCallback callback, RelationDescriptor d) {
    List<SNode> concepts = d.getConcepts(baseNode.resolve(MPSModuleRepository.getInstance()));
    if (concepts.isEmpty()) return new DefaultActionGroup();

    DefaultActionGroup group = new DefaultActionGroup(d.getTitle(), true);
    for (final SNode concept : concepts) {
      group.add(new CreateAction(concept, d, baseNode, callback));
    }
    return group;
  }
コード例 #26
0
 public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) {
   try {
     NodeHighlightManager highlightManager =
         ((EditorComponent) MapSequence.fromMap(_params).get("editorComponent"))
             .getHighlightManager();
     EditorMessageOwner messageOwner =
         ((EditorComponent) MapSequence.fromMap(_params).get("editorComponent"))
             .getHighlightMessagesOwner();
     highlightManager.mark(
         ((EditorCell) MapSequence.fromMap(_params).get("editorCell")).getSNode(),
         HighlightConstants.NODE_COLOR,
         "node",
         messageOwner);
     Set<SNode> nodes =
         ((EditorComponent) MapSequence.fromMap(_params).get("editorComponent"))
             .getNodesCellDependOn(((EditorCell) MapSequence.fromMap(_params).get("editorCell")));
     if (nodes != null) {
       for (SNode node : SetSequence.fromSet(nodes)) {
         highlightManager.mark(node, HighlightConstants.DEPENDENCY_COLOR, "usage", messageOwner);
       }
     }
     Set<SNodeReference> copyOfRefTargets =
         ((EditorComponent) MapSequence.fromMap(_params).get("editorComponent"))
             .getCopyOfRefTargetsCellDependsOn(
                 ((EditorCell) MapSequence.fromMap(_params).get("editorCell")));
     if (copyOfRefTargets != null) {
       for (SNodeReference nodePointer : SetSequence.fromSet(copyOfRefTargets)) {
         if (((SNodePointer) nodePointer).resolve(MPSModuleRepository.getInstance()) != null) {
           highlightManager.mark(
               ((SNodePointer) nodePointer).resolve(MPSModuleRepository.getInstance()),
               HighlightConstants.DEPENDENCY_COLOR,
               "usage",
               messageOwner);
         }
       }
     }
     highlightManager.repaintAndRebuildEditorMessages();
   } catch (Throwable t) {
     LOG.error("User's action execute method failed. Action:" + "HighlightCellDependencies", t);
   }
 }
コード例 #27
0
ファイル: CellAction_PasteNode.java プロジェクト: yan96in/MPS
 private boolean checkDisposed(SNodeReference currentSelectedReference, SNode selectedNode) {
   if (!SNodeUtil.isAccessible(selectedNode, MPSModuleRepository.getInstance())) {
     LOG.error(
         "Selected node is disposed: node = "
             + selectedNode.toString()
             + " ; node pointer = ("
             + currentSelectedReference.toString()
             + ")");
     return true;
   }
   return false;
 }
コード例 #28
0
  @Override
  public List<String> getErrors() {
    List<String> errors = new ArrayList<String>(super.getErrors());
    for (SModuleReference lang : myModule.getExtendedLanguageRefs()) {
      if (MPSModuleRepository.getInstance().getModule(lang) == null) {
        errors.add("Can't find extended language: " + lang.getModuleName());
      }
    }
    checkBehaviorAspectPresence(myModule, errors);
    for (SModuleReference mr : myModule.getRuntimeModulesReferences()) {
      SModule runtimeModule = MPSModuleRepository.getInstance().getModule(mr);
      if (runtimeModule == null) continue;
      if (!(runtimeModule instanceof Solution)) {
        errors.add("Runtime module " + runtimeModule + " is not a solution");
      }
    }
    for (SModelReference accessory : myModule.getModuleDescriptor().getAccessoryModels()) {
      // this check is wrong in common as we don't know what the user wants to do with the acc model
      // in build.
      // but I'll not delete it until accessories removal just to have some warning on project
      // consistency
      org.jetbrains.mps.openapi.model.SModel accModel =
          accessory.resolve(MPSModuleRepository.getInstance());
      if (accModel == null) continue;

      if (!VisibilityUtil.isVisible(myModule, accModel)) {
        errors.add(
            "Can't find accessory model: "
                + SModelStereotype.withoutStereotype(accessory.getModelName()));
      }
    }
    for (SModuleReference ref : myModule.getModuleDescriptor().getRuntimeModules()) {
      if (MPSModuleRepository.getInstance().getModule(ref) == null) {
        errors.add("Can't find runtime module: " + ref.getModuleName());
      }
    }
    return errors;
  }
コード例 #29
0
 @Override
 public Iterable<SProperty> getProperties() {
   return ListSequence.fromList(
           SLinkOperations.getTargets(
               ((SNode) getConcept().resolve(MPSModuleRepository.getInstance())),
               "propertyDeclaration",
               true))
       .select(
           new ISelector<SNode, SProperty>() {
             public SProperty select(SNode it) {
               return ((SProperty) new SPropertyNodeAdapter(it));
             }
           });
 }
コード例 #30
0
 private Class<KeyMap> findKeyMapClassByDeclaration(SNode declaration) {
   String fqName =
       BehaviorReflection.invokeVirtual(
           String.class, declaration, "virtual_getFqName_1213877404258", new Object[] {});
   String namespace = NameUtil.namespaceFromLongName(fqName);
   assert namespace.endsWith(".editor");
   String languageNamespace = namespace.substring(0, namespace.length() - ".editor".length());
   Language language =
       (Language) MPSModuleRepository.getInstance().getModuleByFqName(languageNamespace);
   if (language == null) {
     return null;
   }
   return language.getClass(fqName);
 }