Class ModuleDescriptor
- java.lang.Object
 - 
- jetbrains.mps.project.structure.modules.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 theAbstractModuleclass. FIXME in order to edit facets/model roots in the module a client needs to access such entities asModuleFacetDescriptor,ModelRootDescriptordirectly, FIXME when he has just anAbstractModule(which leads to a low-level module#getModuleDescriptor.getFacetDescriptors().add...) FIXME obviously it is wrong: a client should rather work withSModuleFacetentities in the case of editing anAbstractModule, not descriptors. FIXME OTOH it cannot be a plain persistence descriptor since in order to update (more or less) any properties of anAbstractModuleFIXME we use such pattern in theAbstractModuleas:AbstractModule module; var descriptor = module.getDescriptor();which is needed in order to guarantee a consistency of themodule.setDescriptor(descriptor); // commit descriptor AbstractModuleoperations. TODO Also I would rather use in the ModuleDescriptor hierarchy composition instead of inheritance. ThemyDeploymentDescriptorreference 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 Summary
Constructors Constructor Description ModuleDescriptor() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddFacetDescriptor(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).ModuleDescriptorcopy()protected <T extends ModuleDescriptor>
Tcopy0(Supplier<T> concreteConstructor)utility method to help subclasses implementing thecopy()methodCollection<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.booleangetCompileInMPS()Collection<Dependency>getDependencies()Map<SModuleReference,Integer>getDependencyVersions()DeploymentDescriptorgetDeploymentDescriptor()protected intgetHeaderMarker()ModuleIdgetId()Map<SLanguage,Integer>getLanguageVersions()ThrowablegetLoadException()Collection<ModelRootDescriptor>getModelRootDescriptors()Collection<ModuleFacetDescriptor>getModuleFacetDescriptors()SModuleReferencegetModuleReference()intgetModuleVersion()StringgetNamespace()Collection<String>getSourcePaths()Additional source files to compile along with module's own generated output.StringgetTimestamp()Collection<SModuleReference>getUsedDevkits()Collection<SModuleReference>getUsedLanguages()Deprecated.Now, used languages of a module are derived from models it owns, and thus this list is generally empty.booleanhasDependencyVersions()Deprecated.booleanhasLanguageVersions()Deprecated.booleanisUseTransientOutput()voidload(ModelInputStream stream)booleanneedsExternalIdeaCompile()This is MPS internal flag intended for developers that run MPS from sources.voidremoveFacetDescriptor(SModuleFacet facet)PROVISIONAL API, DO NOT USE OUTSIDE OF MPS Forget persistence information for the given facetvoidsave(ModelOutputStream stream)voidsetDeploymentDescriptor(DeploymentDescriptor deploymentDescriptor)voidsetHasDependencyVersions(boolean hasDependencyVersions)Deprecated.needed it for migration (3.2->3.3)voidsetHasLanguageVersions(boolean hasLanguageVersions)Deprecated.needed it for migration (3.1->3.2)voidsetId(ModuleId id)voidsetLoadException(Throwable loadException)voidsetModuleVersion(int version)voidsetNamespace(String namespace)voidsetNeedsExternalIdeaCompile(boolean value)voidsetTimestamp(String timestamp)voidsetUseTransientOutput(boolean useTransientOutput)voidupdateFacetDescriptor(SModuleFacet facet)PROVISIONAL API, DO NOT USE OUTSIDE OF MPS Push facet settings into persistence.booleanupdateModelRefs(SRepository repository)booleanupdateModuleRefs(SRepository repository) 
 - 
 
- 
- 
Method Detail
- 
getId
public final ModuleId getId()
 
- 
setId
public final void setId(ModuleId id)
 
- 
getNamespace
public final String getNamespace()
 
- 
setNamespace
public final void setNamespace(String namespace)
 
- 
getModuleReference
public final SModuleReference getModuleReference()
 
- 
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 UseSModuleOperations.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)
 
- 
getModelRootDescriptors
public final Collection<ModelRootDescriptor> getModelRootDescriptors()
 
- 
getModuleFacetDescriptors
public final Collection<ModuleFacetDescriptor> getModuleFacetDescriptors()
 
- 
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 thanfacet.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 (useaddFacetDescriptor(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. 
- 
getDependencies
public final Collection<Dependency> getDependencies()
 
- 
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. 
- 
getDependencyVersions
public final Map<SModuleReference,Integer> getDependencyVersions()
 
- 
getUsedDevkits
public final Collection<SModuleReference> getUsedDevkits()
 
- 
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 toLanguageDescriptorPersistence, legacy entries wereclassPathandruntimeClassPathFIXME WHY DOES IT USE String for File location, which FS shall I use to resolve these locations? 
- 
getSourcePaths
public final Collection<String> getSourcePaths()
Additional source files to compile along with module's own generated output. Though, uses are bit odd: - There's unusedAbstractModule.getSourcePaths()- JavaModuleFacet manifests theseJavaModuleFacet.getAdditionalSourcePaths(), likely using module descriptor just as a storage (it's what JMF does anyway) - Make respects these to compile a module 
- 
getDeploymentDescriptor
@Nullable public final DeploymentDescriptor getDeploymentDescriptor()
 
- 
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()
 
- 
save
public void save(ModelOutputStream stream) throws IOException
- Throws:
 IOException
 
- 
load
public void load(ModelInputStream stream) throws IOException
- Throws:
 IOException
 
- 
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 thecopy()method- Parameters:
 concreteConstructor- the module descriptor constructor to put the copy inside
 
- 
copy
@NotNull public ModuleDescriptor copy()
- Specified by:
 copyin interfaceCopyable<ModuleDescriptor>- Returns:
 - full deep-copy of the T instance
 
 
 - 
 
 -