Class ModuleDescriptor

  • All Implemented Interfaces:
    Copyable<ModuleDescriptor>, CopyableDescriptor<ModuleDescriptor>
    Direct Known Subclasses:
    DeploymentDescriptor, DevkitDescriptor, GeneratorDescriptor, LanguageDescriptor, LibraryDescriptor, SolutionDescriptor

    public class ModuleDescriptor
    extends Object
    implements CopyableDescriptor<ModuleDescriptor>
    This class captures persistence and editing aspects of SModule. Client code shall not use this class unless its purpose is to edit or persist module properties. Use SModule API (or Language/Generator/Solution/DevKit subclasses) to read module dependencies and identity information. ----------------------------------------------------------------------------------------------------------------------------------- FIXME This class mixes up the persistence and editing aspects of the AbstractModule class. FIXME in order to edit facets/model roots in the module a client needs to access such entities as ModuleFacetDescriptor, ModelRootDescriptor directly, FIXME when he has just an AbstractModule (which leads to a low-level module#getModuleDescriptor.getFacetDescriptors().add...) FIXME obviously it is wrong: a client should rather work with SModuleFacet entities in the case of editing an AbstractModule, not descriptors. FIXME OTOH it cannot be a plain persistence descriptor since in order to update (more or less) any properties of an AbstractModule FIXME we use such pattern in the AbstractModule as: AbstractModule module; var descriptor = module.getDescriptor(); module.setDescriptor(descriptor); // commit descriptor which is needed in order to guarantee a consistency of the AbstractModule operations. TODO Also I would rather use in the ModuleDescriptor hierarchy composition instead of inheritance. The myDeploymentDescriptor reference is especially repelling here. Road map: We separate the persistence descriptor from the special editing 'handle'. We ensure that the persistence descriptor reflects all the properties we find in our module persistence. AP
    • Constructor Detail

      • ModuleDescriptor

        public ModuleDescriptor()
    • Method Detail

      • setId

        public final void setId​(ModuleId id)
      • getNamespace

        public final String getNamespace()
      • setNamespace

        public final void setNamespace​(String namespace)
      • getTimestamp

        public final String getTimestamp()
      • setTimestamp

        public final void setTimestamp​(String timestamp)
      • getCompileInMPS

        public boolean getCompileInMPS()
      • needsExternalIdeaCompile

        public boolean needsExternalIdeaCompile()
        This is MPS internal flag intended for developers that run MPS from sources. Unlike compileInMPS, it is NOT exposed in JavaModuleFacet intentionally; it's our internal setting, after all Use SModuleOperations.isCompileInIdea(SModule) to find out if module demands external IDEA compilation.
        Returns:
        true if a module with compileInMPS == false shall get compiled with a help of an IDEA instance by means of idea integration plugin
      • setNeedsExternalIdeaCompile

        public void setNeedsExternalIdeaCompile​(boolean value)
      • addFacetDescriptor

        public final void addFacetDescriptor​(@NotNull
                                             SModuleFacet facet)
        PROVISIONAL API, DO NOT USE OUTSIDE OF MPS When facet is added/replaced in a module, we need to register it with persistence (module descriptor).

        With this methods, we keep facet persistence management in a single place (rather than facet.save(new Memento()) scattered around)

      • removeFacetDescriptor

        public final void removeFacetDescriptor​(@NotNull
                                                SModuleFacet facet)
        PROVISIONAL API, DO NOT USE OUTSIDE OF MPS Forget persistence information for the given facet
      • updateFacetDescriptor

        public final void updateFacetDescriptor​(@NotNull
                                                SModuleFacet facet)
        PROVISIONAL API, DO NOT USE OUTSIDE OF MPS Push facet settings into persistence. If there's no descriptor for the facet, it's ignored (use addFacetDescriptor(SModuleFacet) first) This behavior (no update for missing descriptors) is important as facet removal is three-fold - we remove descriptor first, while facet at the module still active, then we update persistent values of existing facets, and then reload module with new descriptor. If we would update missing descriptors, we would effectively resurrect removed descriptors.

        It's not clear whether this code shall be part of AbstractModule#save or not. It seems reasonable to push facet settings into persistence on module save, OTOH, the way module settings are edited/updated (i.e. with changes into descriptor and AbstractModule.setModuleDescriptor() + AM.save(), see ModulePropertiesConfigurable) makes me feel update in the descriptor, not in the module, is better option (after all, it's ModuleDescriptor that is responsible for editing of module settings) - it's sort of changes snapshot, applied with a single setModuleDescriptor operation, rather than sequence of SModule changes.

      • getUsedLanguages

        @Deprecated
        public final Collection<SModuleReference> getUsedLanguages()
        Deprecated.
        Now, used languages of a module are derived from models it owns, and thus this list is generally empty. Although generally there might be modules that keep their used languages, and ModuleDescriptor may keep the list, it shall be the list of SLanguage anyway.
      • getAdditionalJavaStubPaths

        public final Collection<String> getAdditionalJavaStubPaths()
        Paths to extra jar files needed to compile and run given module, generally empty unless a module has some peculiar dependencies on existing java libraries. As of today, these come from <stubModelEntry path=""/> in a module descriptor. according to LanguageDescriptorPersistence, legacy entries were classPath and runtimeClassPath FIXME WHY DOES IT USE String for File location, which FS shall I use to resolve these locations?
      • setDeploymentDescriptor

        public final void setDeploymentDescriptor​(DeploymentDescriptor deploymentDescriptor)
      • updateModelRefs

        public boolean updateModelRefs​(SRepository repository)
      • updateModuleRefs

        public boolean updateModuleRefs​(SRepository repository)
      • getLoadException

        public Throwable getLoadException()
      • setLoadException

        public void setLoadException​(Throwable loadException)
      • isUseTransientOutput

        public boolean isUseTransientOutput()
      • setUseTransientOutput

        public void setUseTransientOutput​(boolean useTransientOutput)
      • getHeaderMarker

        protected int getHeaderMarker()
      • setHasLanguageVersions

        @Deprecated
        public final void setHasLanguageVersions​(boolean hasLanguageVersions)
        Deprecated.
        needed it for migration (3.1->3.2)
      • setHasDependencyVersions

        @Deprecated
        public final void setHasDependencyVersions​(boolean hasDependencyVersions)
        Deprecated.
        needed it for migration (3.2->3.3)
      • hasLanguageVersions

        @Deprecated
        public final boolean hasLanguageVersions()
        Deprecated.
      • hasDependencyVersions

        @Deprecated
        public final boolean hasDependencyVersions()
        Deprecated.
      • getModuleVersion

        public final int getModuleVersion()
      • setModuleVersion

        public final void setModuleVersion​(int version)
      • copy0

        protected final <T extends ModuleDescriptor> T copy0​(@NotNull
                                                             Supplier<T> concreteConstructor)
        utility method to help subclasses implementing the copy() method
        Parameters:
        concreteConstructor - the module descriptor constructor to put the copy inside