Esempio n. 1
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;
      }
    }
  }
Esempio n. 2
0
  @Override
  public Iterable<SDependency> getDeclaredDependencies() {
    assertCanRead();
    ModuleDescriptor descriptor = getModuleDescriptor();
    if (descriptor == null) {
      return Collections.emptyList();
    }
    HashSet<SDependency> result = new HashSet<SDependency>();
    final SRepository repo = getRepository();
    if (repo == null) {
      throw new IllegalStateException(
          "It is not possible to resolve all declared dependencies with a null repository : module "
              + this);
    }

    // add declared dependencies
    for (Dependency d : descriptor.getDependencies()) {
      result.add(new SDependencyImpl(d.getModuleRef(), repo, d.getScope(), d.isReexport()));
    }

    // add dependencies provided by devkits as nonreexport dependencies
    for (SModuleReference usedDevkit : descriptor.getUsedDevkits()) {
      final SModule devkit = usedDevkit.resolve(repo);
      if (DevKit.class.isInstance(devkit)) {
        for (Solution solution : ((DevKit) devkit).getAllExportedSolutions()) {
          result.add(
              new SDependencyImpl(
                  solution.getModuleReference(), repo, SDependencyScope.DEFAULT, false));
        }
      }
    }
    return result;
  }
Esempio n. 3
0
  private static SModule getModuleForModel(MPSProject project, SModel model) {
    // language's and solution's own models (+generator models in language)
    SModule owner = model.getModule();
    SModule mainModule =
        owner instanceof Generator ? ((Generator) owner).getSourceLanguage() : owner;
    if (project.isProjectModule(mainModule)) return owner;

    // accessories models in languages
    /*
      //with this enabled, alt-f1 does not work in case node is in non-owned accessory model to a project language
      for (Language l : project.getProjectLanguages()) {
        if (l.isAccessoryModel(model.getSModelReference())) return l;
      }
    */

    // runtime models in languages
    for (Language l : project.getProjectModules(Language.class)) {
      for (SModuleReference depModule : l.getRuntimeModulesReferences()) {
        if (depModule.equals(mainModule.getModuleReference())) return owner;
      }
    }

    // accessories models in devkits

    // runtime models in devkits

    return owner;
  }
Esempio n. 4
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;
 }
Esempio n. 5
0
  // fills collections with of imported languages and devkits.
  // Languages include directly imported and coming immediately through devkits; listed devkits are
  // imported directly, without those they extend (why?).
  public LangAndDevkits collectLanguagesAndDevkits() {
    Set<SLanguage> usedLanguages = new LinkedHashSet<>();
    Set<SModuleReference> devkits = new LinkedHashSet<>();

    // perhaps, shall introduce ModuleImports similar to ModelImports to accomplish this?
    for (SModel m : getModels()) {
      final SModelInternal modelInternal = (SModelInternal) m;
      usedLanguages.addAll(modelInternal.importedLanguageIds());
      devkits.addAll(modelInternal.importedDevkits());
    }
    // XXX why don't we respect extended devkits here?
    final SRepository repository = getRepository();
    if (repository != null) {
      for (SModuleReference devkitRef : devkits) {
        final SModule module = devkitRef.resolve(repository);
        if (module instanceof DevKit) {
          for (SLanguage l : ((DevKit) module).getAllExportedLanguageIds()) {
            usedLanguages.add(l);
          }
        }
      }
    }
    usedLanguages.add(BootstrapLanguages.getLangCore());
    return new LangAndDevkits(usedLanguages, devkits);
  }
Esempio n. 6
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;
  }
Esempio n. 7
0
 /*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());
 }
Esempio n. 8
0
 private String[] getUsedLanguagesStringArray() {
   List<SModuleReference> moduleReferences = getElements();
   String[] usedLanguages = new String[moduleReferences.size()];
   int i = 0;
   for (SModuleReference moduleReference : moduleReferences) {
     usedLanguages[i] = moduleReference.toString();
     i++;
   }
   return usedLanguages;
 }
Esempio n. 9
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;
 }
Esempio n. 10
0
 private static String asString(SModuleReference generatorRef) {
   Generator generator = (Generator) ModuleRepositoryFacade.getInstance().getModule(generatorRef);
   if (generator == null) {
     return "unknown(" + generatorRef.toString() + ")";
   }
   return generator.getAlias();
 }
Esempio n. 11
0
 /*package*/ void updateIcon(SRepository repo) {
   SModule m = myModule.resolve(repo);
   if (m == null) {
     setIcon(IdeIcons.DEFAULT_ICON);
   } else {
     setIcon(IconManager.getIconFor(m));
   }
 }
Esempio n. 12
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;
 }
Esempio n. 13
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;
  }
Esempio n. 14
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;
  }
Esempio n. 15
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());
    }
  }
Esempio n. 16
0
  @Override
  public Dependency addDependency(@NotNull SModuleReference moduleRef, boolean reexport) {
    // we do not add a dependency into solution, we add dependency to idea module instead
    ModifiableRootModel modifiableModel =
        ModuleRootManager.getInstance(myModule).getModifiableModel();

    SModule sModule = moduleRef.resolve(MPSModuleRepository.getInstance()); // FIXME module repo

    if (sModule instanceof SolutionIdea) {
      // we add dependency between idea modules
      Module otherIdeaModule = ((SolutionIdea) sModule).getIdeaModule();
      modifiableModel.addModuleOrderEntry(otherIdeaModule);
    } else {
      ModuleRuntimeLibrariesImporter.importForUsedModules(
          myModule, Collections.singleton(moduleRef), modifiableModel);
    }
    modifiableModel.commit();
    return null;
  }
 @Override
 public String getLanguageFqName() {
   return myLanguageReference.getModuleName();
 }
  public static void saveGeneratorDescriptor(
      Element languageGeneratorsElement, GeneratorDescriptor descriptor, MacroHelper macroHelper) {
    Element generator = new Element("generator");
    if (descriptor.getNamespace() != null) {
      generator.setAttribute("name", descriptor.getNamespace());
    }
    if (descriptor.getGeneratorUID() != null) {
      generator.setAttribute("generatorUID", descriptor.getGeneratorUID());
    }
    if (descriptor.getUUID() != null) {
      generator.setAttribute("uuid", descriptor.getUUID());
    }
    if (descriptor.isGenerateTemplates()) {
      generator.setAttribute(
          "generate-templates", Boolean.toString(descriptor.isGenerateTemplates()));
    }
    if (!(descriptor.isReflectiveQueries())) {
      generator.setAttribute("reflective-queries", Boolean.toString(false));
    }
    if (!(descriptor.needsOperationContext())) {
      generator.setAttribute("needs-opctx", Boolean.toString(false));
    }

    Element models = new Element("models");
    ModuleDescriptorPersistence.saveModelRoots(
        models, descriptor.getModelRootDescriptors(), macroHelper);
    generator.addContent(models);

    if (!(descriptor.getModuleFacetDescriptors().isEmpty())) {
      Element facets = new Element("facets");
      ModuleDescriptorPersistence.saveFacets(
          facets, descriptor.getModuleFacetDescriptors(), macroHelper);
      generator.addContent(facets);
    }

    // "depends on" generators
    Element extTemplates = new Element("external-templates");
    for (SModuleReference generatorReference : SetSequence.fromSet(descriptor.getDepGenerators())) {
      XmlUtil.tagWithAttribute(
          extTemplates, "generator", "generatorUID", generatorReference.toString());
    }
    generator.addContent(extTemplates);

    ModuleDescriptorPersistence.saveDependencies(generator, descriptor);

    // mapping priority rules
    Element mapPrio = new Element("mapping-priorities");
    for (MappingPriorityRule rule : ListSequence.fromList(descriptor.getPriorityRules())) {
      Element ruleElement = new Element("mapping-priority-rule");
      ruleElement.setAttribute("kind", rule.getType().getName());

      Element gpm = new Element("greater-priority-mapping");
      saveGeneratorMappingConfigRef(rule.getLeft(), gpm);
      ruleElement.addContent(gpm);

      Element lpm = new Element("lesser-priority-mapping");
      saveGeneratorMappingConfigRef(rule.getRight(), lpm);
      ruleElement.addContent(lpm);

      mapPrio.addContent(ruleElement);
    }
    generator.addContent(mapPrio);

    languageGeneratorsElement.addContent(generator);
  }
Esempio n. 19
0
 @Override
 public int compare(SModuleReference o1, SModuleReference o2) {
   return o1.getModuleName().compareTo(o2.getModuleName());
 }
Esempio n. 20
0
 @Override
 protected String getText(SModuleReference moduleReference) {
   return moduleReference.getModuleName();
 }
  public static void saveLanguageDescriptor(
      IFile file, LanguageDescriptor descriptor, MacroHelper macroHelper) {
    if (file.isReadOnly()) {
      if (LOG.isEnabledFor(Priority.ERROR)) {
        LOG.error("Cant't save " + file.getPath());
      }
      return;
    }

    Element languageElement = new Element("language");
    languageElement.setAttribute("namespace", descriptor.getNamespace());
    String uuid = descriptor.getUUID();
    if (uuid != null) {
      languageElement.setAttribute("uuid", uuid);
    }
    if (descriptor.getGenPath() != null) {
      languageElement.setAttribute(
          "generatorOutputPath", macroHelper.shrinkPath(descriptor.getGenPath()));
    }

    Element models = new Element("models");
    ModuleDescriptorPersistence.saveModelRoots(
        models, descriptor.getModelRootDescriptors(), macroHelper);
    languageElement.addContent(models);

    if (!(descriptor.getModuleFacetDescriptors().isEmpty())) {
      Element facets = new Element("facets");
      ModuleDescriptorPersistence.saveFacets(
          facets, descriptor.getModuleFacetDescriptors(), macroHelper);
      languageElement.addContent(facets);
    }

    Element accessoryModels = new Element("accessoryModels");
    for (SModelReference model : SetSequence.fromSet(descriptor.getAccessoryModels())) {
      XmlUtil.tagWithAttribute(accessoryModels, "model", "modelUID", model.toString());
    }
    languageElement.addContent(accessoryModels);

    Element generators = new Element("generators");
    for (GeneratorDescriptor generatorDescriptor :
        ListSequence.fromList(descriptor.getGenerators())) {
      GeneratorDescriptorPersistence.saveGeneratorDescriptor(
          generators, generatorDescriptor, macroHelper);
    }
    languageElement.addContent(generators);

    if (!(descriptor.getAdditionalJavaStubPaths().isEmpty())) {
      Element stubModelEntries = new Element("stubModelEntries");
      ModuleDescriptorPersistence.saveStubModelEntries(
          stubModelEntries, descriptor.getAdditionalJavaStubPaths(), macroHelper);
      languageElement.addContent(stubModelEntries);
    }

    Element sourcePath = new Element("sourcePath");
    for (String p : descriptor.getSourcePaths()) {
      XmlUtil.tagWithAttribute(sourcePath, "source", "path", macroHelper.shrinkPath(p));
    }
    languageElement.addContent(sourcePath);

    ModuleDescriptorPersistence.saveDependencies(languageElement, descriptor);

    Element extendedLanguages = new Element("extendedLanguages");
    for (SModuleReference ref : SetSequence.fromSet(descriptor.getExtendedLanguages())) {
      XmlUtil.tagWithText(extendedLanguages, "extendedLanguage", ref.toString());
    }
    languageElement.addContent(extendedLanguages);

    try {
      OutputStream os = file.openOutputStream();
      JDOMUtil.writeDocument(new Document(languageElement), os);
    } catch (Exception e) {
      if (LOG.isEnabledFor(Priority.ERROR)) {
        LOG.error("", e);
      }
    }
    ModuleDescriptorPersistence.setTimestamp(descriptor, file);
  }
Esempio n. 22
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;
  }
Esempio n. 23
0
 /**
  * Note: here we are interested in the actual status of module. (not {@link
  * ReferenceStorage#resolveRef}) if it has been already disposed but still remains in our graphs
  * (i.e. ClassLoader is not disposed yet [!]), we need to mark it invalid
  */
 private boolean isModuleDisposed(SModuleReference mRef) {
   SModule resolvedModule = mRef.resolve(myRepository);
   return (resolvedModule == null || resolvedModule.getRepository() == null);
 }
Esempio n. 24
0
 public SModule getModule(@NotNull SModuleReference ref) {
   return ref.getModuleId() != null
       ? REPO.getModuleById(ref.getModuleId())
       : REPO.getModuleByFqName(ref.getModuleName());
 }