Exemple #1
0
 public static Collection<String> getUsedLanguageNamespaces(
     SModel model, boolean isTemplateModel) {
   if (isTemplateModel) {
     return getUsedLanguageNamespacesInTemplateModel(model);
   }
   if (SModelStereotype.isGeneratorModel(model)) {
     TemplateModelScanner templateModelScanner = new TemplateModelScanner(model);
     templateModelScanner.scan();
     Set<String> namespaces = new HashSet<String>(templateModelScanner.getQueryLanguages());
     for (SModuleReference ref :
         ((jetbrains.mps.smodel.SModelInternal) model).engagedOnGenerationLanguages()) {
       namespaces.add(ref.getModuleName());
     }
     return namespaces;
   }
   Set<String> namespaces = new HashSet<String>();
   for (SModuleReference ref :
       ((jetbrains.mps.smodel.SModelInternal) model).engagedOnGenerationLanguages()) {
     namespaces.add(ref.getModuleName());
   }
   for (SNode root : model.getRootNodes()) {
     namespaces.add(NameUtil.namespaceFromConceptFQName(root.getConcept().getId()));
     for (SNode child : jetbrains.mps.util.SNodeOperations.getDescendants(root, null)) {
       namespaces.add(NameUtil.namespaceFromConceptFQName(child.getConcept().getId()));
     }
   }
   // empty behavior model should have it's behavior aspect descriptor generated
   if (model.getModule() instanceof Language && LanguageAspect.BEHAVIOR.is(model)) {
     namespaces.add(BootstrapLanguages.BEHAVIOR.getModuleName());
   }
   return namespaces;
 }
Exemple #2
0
  @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;
  }
 /*package*/ ModuleDependencyNode(
     SModuleReference module, Iterable<DepLink> relations, boolean isUsedLanguage) {
   // module serves as dependency target (dependencies are captured with relations sequence)
   super(Sequence.fromIterable(relations).toListSequence());
   myModule = module;
   myIsUsedLang = isUsedLanguage;
   setText(module.getModuleName());
   setNodeIdentifier(module.getModuleName());
 }
Exemple #4
0
  @Override
  public SModule resolve(SModuleReference reference) {
    if (reference == null) {
      return null;
    }

    SModule module;
    if (reference.getModuleId() != null) {
      module = MPSModuleRepository.getInstance().getModule(reference.getModuleId());
    } else {
      module = MPSModuleRepository.getInstance().getModuleByFqName(reference.getModuleName());
    }

    if (module == null) {
      return null;
    }

    synchronized (LOCK) {
      initialize();
      if (myVisibleModules.contains(module)
          || myUsedLanguages.contains(module)
          || myUsedDevkits.contains(module)) {
        return module;
      } else {
        return null;
      }
    }
  }
Exemple #5
0
  /** @return message with the problem description or null if the module is valid */
  @Nullable
  @Hack
  private String getModuleProblemMessage(
      SModuleReference mRef,
      Map<ReloadableModule, AbsentDependencyException> modulesWithAbsentDeps) {
    assert !isChanged();
    if (isModuleDisposed(mRef)) {
      return String.format(
          "Module %s is disposed and therefore was marked invalid for class loading",
          mRef.getModuleName());
    }

    ReloadableModule module = (ReloadableModule) mRef.resolve(myRepository);
    assert module != null;

    // FIXME does not work for now, enable in the 3.4
    if (modulesWithAbsentDeps.containsKey(module)) {
      AbsentDependencyException exception = modulesWithAbsentDeps.get(module);
      return String.format(
          "%s has got an absent dependency problem and therefore was marked invalid for class loading: %s",
          module, exception.getMessage());
    }
    for (SDependency dep : module.getDeclaredDependencies()) {
      if (dep.getScope() == SDependencyScope.DESIGN
          || dep.getScope() == SDependencyScope.GENERATES_INTO) {
        continue;
      }
      if (isModuleDisposed(dep.getTargetModule())) {
        return String.format(
            "%s depends on a disposed module %s and therefore was marked invalid for class loading",
            module, dep.getTargetModule());
      }
    }
    return null;
  }
Exemple #6
0
  protected void setModuleReference(@NotNull SModuleReference reference) {
    assertCanChange();

    assert reference.getModuleId() != null : "module must have an id";
    assert myModuleReference == null
            || reference.getModuleId().equals(myModuleReference.getModuleId())
        : "module id can't be changed";

    SModuleReference oldValue = myModuleReference;
    myModuleReference = reference;
    if (oldValue != null
        && oldValue.getModuleName() != null
        && !oldValue.getModuleName().equals(myModuleReference.getModuleName())) {

      MPSModuleRepository.getInstance().moduleFqNameChanged(this, oldValue.getModuleName());
    }
  }
 @Nullable
 private static Library getAutoLibrary(SModuleReference reference, Project project) {
   String libraryName = LIBRARY_PREFIX + reference.getModuleName() + AUTO_SUFFIX;
   for (Library lib : ModuleLibrariesUtil.getLibraries(reference, project)) {
     if (lib.getName().equals(libraryName)) {
       return lib;
     }
   }
   return null;
 }
Exemple #8
0
 @Override
 public List<String> getErrors() {
   List<String> errors = new ArrayList<String>(super.getErrors());
   for (SModuleReference gen : myModule.getModuleDescriptor().getDepGenerators()) {
     if (ModuleRepositoryFacade.getInstance().getModule(gen) == null) {
       errors.add("Can't find generator dependency: " + gen.getModuleName());
     }
   }
   return errors;
 }
  @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;
  }
 public SModule getModule(@NotNull SModuleReference ref) {
   return ref.getModuleId() != null
       ? REPO.getModuleById(ref.getModuleId())
       : REPO.getModuleByFqName(ref.getModuleName());
 }
 @Override
 protected String getText(SModuleReference moduleReference) {
   return moduleReference.getModuleName();
 }
 @Override
 public int compare(SModuleReference o1, SModuleReference o2) {
   return o1.getModuleName().compareTo(o2.getModuleName());
 }
 @Override
 public String getLanguageFqName() {
   return myLanguageReference.getModuleName();
 }