コード例 #1
0
ファイル: ModelContentUtil.java プロジェクト: sprig/MPS
 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;
 }
コード例 #2
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;
  }
コード例 #3
0
ファイル: ModuleDependencyNode.java プロジェクト: yan96in/MPS
 /*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());
 }
コード例 #4
0
ファイル: DefaultScope.java プロジェクト: brigand/MPS
  @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;
      }
    }
  }
コード例 #5
0
ファイル: ModulesWatcher.java プロジェクト: ozlembb/MPS
  /** @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;
  }
コード例 #6
0
ファイル: AbstractModule.java プロジェクト: JetBrains/MPS
  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());
    }
  }
コード例 #7
0
 @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;
 }
コード例 #8
0
ファイル: GeneratorValidator.java プロジェクト: brigand/MPS
 @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;
 }
コード例 #9
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;
  }
コード例 #10
0
 public SModule getModule(@NotNull SModuleReference ref) {
   return ref.getModuleId() != null
       ? REPO.getModuleById(ref.getModuleId())
       : REPO.getModuleByFqName(ref.getModuleName());
 }
コード例 #11
0
 @Override
 protected String getText(SModuleReference moduleReference) {
   return moduleReference.getModuleName();
 }
コード例 #12
0
 @Override
 public int compare(SModuleReference o1, SModuleReference o2) {
   return o1.getModuleName().compareTo(o2.getModuleName());
 }
コード例 #13
0
 @Override
 public String getLanguageFqName() {
   return myLanguageReference.getModuleName();
 }