Пример #1
0
 @Override
 protected List<SModuleReference> getAllVisibleElements() {
   final List<SModuleReference> allLanguages = new ArrayList<SModuleReference>();
   for (Language language : ModuleRepositoryFacade.getInstance().getAllModules(Language.class)) {
     allLanguages.add(language.getModuleReference());
   }
   return allLanguages;
 }
Пример #2
0
  @Test
  public void testUsedLanguageDependencyNotInScope() {
    Solution s1 = createSolution();

    Solution ld = createSolution();
    Language l1 = createLanguage();
    l1.addDependency(ld.getModuleReference(), true);

    s1.addUsedLanguage(l1.getModuleReference());

    assertFalse(new GlobalModuleDependenciesManager(s1).getModules(Deptype.VISIBLE).contains(ld));
    assertFalse(IterableUtil.asCollection(s1.getScope().getVisibleModules()).contains(ld));
  }
Пример #3
0
 protected void addBuiltInImports() {
   SLanguage base =
       MetaAdapterFactory.getLanguage(
           MetaIdFactory.langId(0xde1ad86d6e504a02L, 0xb306d4d17f64c375L),
           "jetbrains.mps.console.base");
   Collection<SLanguage> baseAndExtensions =
       new SLanguageHierarchy(Collections.singleton(base)).getExtending();
   SModelInternal modelInternal = ((SModelInternal) myModel);
   for (SLanguage l : CollectionSequence.fromCollection(baseAndExtensions)) {
     modelInternal.addLanguage(l);
     Language sourceLangModule = (Language) l.getSourceModule();
     if (sourceLangModule == null) {
       continue;
     }
     modelInternal.addModelImport(
         sourceLangModule.getStructureModelDescriptor().getReference(), false);
     ((AbstractModule) myModel.getModule())
         .addDependency(sourceLangModule.getModuleReference(), false);
   }
   modelInternal.addDevKit(
       PersistenceFacade.getInstance()
           .createModuleReference(
               "fbc25dd2-5da4-483a-8b19-70928e1b62d7(jetbrains.mps.devkit.general-purpose)"));
 }
Пример #4
0
  private List<DepLink> dependencies(DependencyUtil.Role role, SModuleReference moduleRef) {
    List<DepLink> result = ListSequence.fromList(new ArrayList<DepLink>());
    SModule module = moduleRef.resolve(myRepo);
    ModuleDescriptor descr = ((AbstractModule) module).getModuleDescriptor();
    if (descr == null) {
      return result;
    }
    switch (role) {
      case OwnedGenerator:
      case None:
        // first step
        addDeps(
            result,
            descr.getUsedDevkits(),
            DependencyUtil.Role.UsedDevkit,
            DependencyUtil.LinkType.UsesDevkit);
        for (SLanguage lang : module.getUsedLanguages()) {
          SModule langModule = lang.getSourceModule();
          if (langModule != null) {
            ListSequence.fromList(result)
                .addElement(
                    new DepLink(
                        langModule.getModuleReference(),
                        DependencyUtil.Role.UsedLanguage,
                        DependencyUtil.LinkType.UsesLanguage));
          }
        }
        for (SDependency dep : module.getDeclaredDependencies()) {
          switch (dep.getScope()) {
            case EXTENDS:
              SModule t = dep.getTarget();
              if (t instanceof Language) {
                ListSequence.fromList(result)
                    .addElement(
                        new DepLink(
                            dep.getTargetModule(),
                            DependencyUtil.Role.RegularDependency,
                            DependencyUtil.LinkType.ExtendsLanguage));
              } else if (t instanceof Generator) {
                ListSequence.fromList(result)
                    .addElement(
                        new DepLink(
                            dep.getTargetModule(),
                            DependencyUtil.Role.RegularDependency,
                            DependencyUtil.LinkType.ExtendsGenerator));
              } else {
                // just in case module could not be resolved
                ListSequence.fromList(result)
                    .addElement(
                        new DepLink(
                            dep.getTargetModule(),
                            DependencyUtil.Role.RegularDependency,
                            DependencyUtil.LinkType.Depends));
              }
              break;
            case DESIGN:
              ListSequence.fromList(result)
                  .addElement(
                      new DepLink(
                          dep.getTargetModule(),
                          DependencyUtil.Role.RegularDependency,
                          DependencyUtil.LinkType.Depends));
              break;
            case RUNTIME:
              ListSequence.fromList(result)
                  .addElement(
                      new DepLink(
                          dep.getTargetModule(),
                          DependencyUtil.Role.RuntimeDependency,
                          DependencyUtil.LinkType.Depends));
              break;
            default:
              ListSequence.fromList(result)
                  .addElement(
                      new DepLink(
                          dep.getTargetModule(),
                          DependencyUtil.Role.RegularDependency,
                          (dep.isReexport()
                              ? DependencyUtil.LinkType.ReexportsDep
                              : DependencyUtil.LinkType.Depends)));
          }
        }
        if (module instanceof Language) {
          // generators and generators dependencies are now also added to language dependencies
          // (MPS-15883)
          for (Generator g : ((Language) module).getGenerators()) {
            ListSequence.fromList(result)
                .addElement(
                    new DepLink(
                        g.getModuleReference(),
                        DependencyUtil.Role.OwnedGenerator,
                        DependencyUtil.LinkType.Generator));
          }
        }
        if (module instanceof Generator) {
          Language srcLang = ((Generator) module).getSourceLanguage();
          ListSequence.fromList(result)
              .addElement(
                  new DepLink(
                      srcLang.getModuleReference(),
                      DependencyUtil.Role.SourceLanguage,
                      DependencyUtil.LinkType.GeneratorLanguage));
        }
        break;

      case UsedDevkit:
        // explicit use of devkit
      case DependencyDevkit:
        DevkitDescriptor devkit = as_he47wm_a0a0a3e0g(descr, DevkitDescriptor.class);
        if (devkit == null) {
          break;
        }
        boolean direct = role == DependencyUtil.Role.UsedDevkit;
        addDeps(
            result,
            devkit.getExtendedDevkits(),
            (direct ? DependencyUtil.Role.UsedDevkit : DependencyUtil.Role.DependencyDevkit),
            DependencyUtil.LinkType.ExtendsDevkit);
        addDeps(
            result,
            devkit.getExportedLanguages(),
            (direct ? DependencyUtil.Role.UsedLanguage : DependencyUtil.Role.DependencyLanguage),
            DependencyUtil.LinkType.ExportsLanguage);
        addDeps(
            result,
            devkit.getExportedSolutions(),
            (direct
                ? DependencyUtil.Role.RegularDependency
                : DependencyUtil.Role.RuntimeDependency),
            DependencyUtil.LinkType.ExportsSolution);
        break;

      case UsedLanguage:
        LanguageDescriptor lang = as_he47wm_a0a0a4e0g(descr, LanguageDescriptor.class);
        if (lang == null) {
          break;
        }
        addDeps(
            result,
            lang.getExtendedLanguages(),
            DependencyUtil.Role.UsedLanguage,
            DependencyUtil.LinkType.ExtendsLanguage);
        if (myNeedRuntime) {
          addDeps(
              result,
              lang.getRuntimeModules(),
              DependencyUtil.Role.RuntimeDependency,
              DependencyUtil.LinkType.ExportsRuntime);
        }
        break;

      case RegularDependency:
        addDeps(
            result,
            getReexportDeps(descr),
            DependencyUtil.Role.RegularDependency,
            DependencyUtil.LinkType.ReexportsDep);
        if (descr instanceof LanguageDescriptor) {
          addDeps(
              result,
              (as_he47wm_a0a1a0a1a5e0g(descr, LanguageDescriptor.class)).getExtendedLanguages(),
              DependencyUtil.Role.RegularDependency,
              DependencyUtil.LinkType.ExtendsLanguage);
        }
        if (myNeedRuntime) {
          addDeps(
              result,
              getNonreexportDeps(descr),
              DependencyUtil.Role.RuntimeDependency,
              DependencyUtil.LinkType.Depends);
          addDeps(
              result,
              descr.getUsedLanguages(),
              DependencyUtil.Role.DependencyLanguage,
              DependencyUtil.LinkType.UsesLanguage);
          addDeps(
              result,
              descr.getUsedDevkits(),
              DependencyUtil.Role.DependencyDevkit,
              DependencyUtil.LinkType.UsesDevkit);
        }
        break;

      case RuntimeDependency:
        if (myNeedRuntime) {
          addDeps(
              result,
              getReexportDeps(descr),
              DependencyUtil.Role.RuntimeDependency,
              DependencyUtil.LinkType.ReexportsDep);
          addDeps(
              result,
              getNonreexportDeps(descr),
              DependencyUtil.Role.RuntimeDependency,
              DependencyUtil.LinkType.Depends);
          addDeps(
              result,
              descr.getUsedLanguages(),
              DependencyUtil.Role.DependencyLanguage,
              DependencyUtil.LinkType.UsesLanguage);
          addDeps(
              result,
              descr.getUsedDevkits(),
              DependencyUtil.Role.DependencyDevkit,
              DependencyUtil.LinkType.UsesDevkit);
          if (descr instanceof LanguageDescriptor) {
            addDeps(
                result,
                (as_he47wm_a0a1a0a4a0a6e0g(descr, LanguageDescriptor.class)).getExtendedLanguages(),
                DependencyUtil.Role.RuntimeDependency,
                DependencyUtil.LinkType.ExtendsLanguage);
          }
          if (descr instanceof GeneratorDescriptor) {
            GeneratorDescriptor gen = (GeneratorDescriptor) descr;
            // generator languages are now also dependencies
            addDeps(
                result,
                gen.getDepGenerators(),
                DependencyUtil.Role.RuntimeDependency,
                DependencyUtil.LinkType.DependsOnGenerator);
            ListSequence.fromList(result)
                .addElement(
                    new DepLink(
                        (as_he47wm_a0a0a0a0a3a5a0a6e0g(module, Generator.class))
                            .getSourceLanguage()
                            .getModuleReference(),
                        DependencyUtil.Role.RuntimeDependency,
                        DependencyUtil.LinkType.GeneratorLanguage));
          }
        }
        break;

      case SourceLanguage:
        // dependency from generator to its source language
        addDeps(
            result,
            check_he47wm_b0b0h4a6(as_he47wm_a0b0b0h4a6(descr, LanguageDescriptor.class)),
            DependencyUtil.Role.SourceLanguage,
            DependencyUtil.LinkType.ExtendsLanguage);
        addDeps(
            result,
            check_he47wm_b0c0h4a6(as_he47wm_a0b0c0h4a6(descr, LanguageDescriptor.class)),
            DependencyUtil.Role.RuntimeDependency,
            DependencyUtil.LinkType.ExportsRuntime);
        break;

      case DependencyLanguage:
        addDeps(
            result,
            check_he47wm_b0a0i4a6(as_he47wm_a0b0a0i4a6(descr, LanguageDescriptor.class)),
            DependencyUtil.Role.DependencyLanguage,
            DependencyUtil.LinkType.ExtendsLanguage);
        addDeps(
            result,
            check_he47wm_b0b0i4a6(as_he47wm_a0b0b0i4a6(descr, LanguageDescriptor.class)),
            DependencyUtil.Role.RuntimeDependency,
            DependencyUtil.LinkType.ExportsRuntime);
        break;

      default:
    }
    return result;
  }