Package jetbrains.mps.smodel
Class DefaultSModelDescriptor
- java.lang.Object
 - 
- jetbrains.mps.extapi.model.SModelDescriptorStub
 - 
- jetbrains.mps.extapi.model.SModelBase
 - 
- jetbrains.mps.extapi.model.EditableSModelBase
 - 
- jetbrains.mps.smodel.LazyEditableSModelBase
 - 
- jetbrains.mps.smodel.DefaultSModelDescriptor
 
 
 
 
 
 
- 
- All Implemented Interfaces:
 GeneratableSModel,ModelWithAttributes,ModelWithDisposeInfo,PersistenceVersionAware,FastNodeFinder.Factory,SModelInternal,EditableSModel,SModel
public class DefaultSModelDescriptor extends LazyEditableSModelBase implements GeneratableSModel, PersistenceVersionAware, ModelWithAttributes
 
- 
- 
Nested Class Summary
- 
Nested classes/interfaces inherited from interface org.jetbrains.mps.openapi.model.SModel
SModel.Problem 
 - 
 
- 
Field Summary
- 
Fields inherited from class jetbrains.mps.extapi.model.EditableSModelBase
myTimestampTracker 
- 
Fields inherited from interface jetbrains.mps.extapi.model.GeneratableSModel
FILE, HEADER 
 - 
 
- 
Constructor Summary
Constructors Constructor Description DefaultSModelDescriptor(LazyLoadFacility persistence, SModelHeader header) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidforEach(BiConsumer<String,String> action)Iterate over all available attributes.StringgetAttribute(String key)Retrieve extra model data.SModelHeadergetHeaderCopy()ModelFactorygetModelFactory()ActualModelFactorywhich is currently responsible for model load/save, ornullif model knowns nothing about persistence at the moment.StringgetModelHash()intgetPersistenceVersion()Since we expose persistence aspects of a model from (openapi)SModel, it's reasonable to keep persistence attributes we are not yet ready to expose here in the implementation.booleanisDoNotGenerate()booleanisGeneratable()Generally,doNotGenerateis a primary reason to generate (or not) the model.booleanisGenerateIntoModelFolder()protected ModelLoadResultloadSModel(ModelLoadingState state)loads model from the source, w/o changing state of SModelDescriptorprotected voidreloadContents()voidreplace(SModelData modelData)protected booleansaveModel()returns true if the content should be reloaded from storage after savevoidsetAttribute(String key, String value)Record extra data with a modelvoidsetDoNotGenerate(boolean value)voidsetGenerateIntoModelFolder(boolean value)PROVISIONAL API.voidsetPersistenceVersion(int persistenceVersion)Indicated persistence version for model serializationprotected booleanshouldCorrectModelRef()- 
Methods inherited from class jetbrains.mps.smodel.LazyEditableSModelBase
doUnload, getCurrentModelInternal, getSModelInternal, load 
- 
Methods inherited from class jetbrains.mps.extapi.model.EditableSModelBase
addChangeListener, addRootNode, attach, detach, isChanged, isReadOnly, needsReloading, reloadFromSource, removeChangeListener, removeRootNode, rename, resolveDiskConflict, save, setChanged, toString, unload, updateTimestamp 
- 
Methods inherited from class jetbrains.mps.extapi.model.SModelBase
addAccessListener, addModelListener, assertCanChange, assertCanRead, changeModelReference, createNode, createNode, fireBeforeModelRenamed, fireConflictDetected, fireModelRenamed, fireModelReplaced, fireModelSaved, fireModelStateChanged, fireProblemsDetected, getLoadingState, getModelData, getModelId, getModelName, getModelRoot, getModule, getName, getNode, getNodeEventDispatch, getProblems, getReference, getRepository, getRootNodes, getSource, isLoaded, removeAccessListener, removeModelListener, replaceModelAndFireEvent, setLoadingState, setModelRoot, setModule 
- 
Methods inherited from class jetbrains.mps.extapi.model.SModelDescriptorStub
addDevKit, addEngagedOnGenerationLanguage, addLanguage, addModelImport, addModelListener, clearListeners, createNodeFinder, deleteDevKit, deleteLanguageId, deleteModelImport, fireBeforeModelDisposed, fireBeforeModelFileChanged, fireBeforeModelRenamed, fireModelFileChanged, fireModelRenamed, fireModelStateChanged, getDisposedStacktrace, getLanguageImportVersion, getLanguagesEngagedOnGeneration, getModelDepsManager, getModelImports, getModelListeners, getSModel, importedDevkits, importedLanguageIds, isDisposed, removeEngagedOnGenerationLanguage, removeModelListener, setLanguageImportVersion, updateExternalReferences 
- 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait 
- 
Methods inherited from interface jetbrains.mps.extapi.model.GeneratableSModel
getGenerationHashes 
- 
Methods inherited from interface jetbrains.mps.extapi.model.ModelWithAttributes
getAttribute 
- 
Methods inherited from interface org.jetbrains.mps.openapi.model.SModel
addAccessListener, addChangeListener, addModelListener, addRootNode, createNode, createNode, getModelId, getModelName, getModelRoot, getModule, getName, getNode, getProblems, getReference, getRepository, getRootNodes, getSource, isLoaded, isReadOnly, load, removeAccessListener, removeChangeListener, removeModelListener, removeRootNode, unload 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
DefaultSModelDescriptor
public DefaultSModelDescriptor(@NotNull LazyLoadFacility persistence, @NotNull SModelHeader header)
 
 - 
 
- 
Method Detail
- 
replace
public void replace(SModelData modelData)
 
- 
loadSModel
protected ModelLoadResult loadSModel(ModelLoadingState state)
Description copied from class:LazyEditableSModelBaseloads model from the source, w/o changing state of SModelDescriptor- Specified by:
 loadSModelin classLazyEditableSModelBase
 
- 
shouldCorrectModelRef
protected boolean shouldCorrectModelRef()
 
- 
getPersistenceVersion
public int getPersistenceVersion()
Since we expose persistence aspects of a model from (openapi)SModel, it's reasonable to keep persistence attributes we are not yet ready to expose here in the implementation. These attributes shall not be part of SModelData (smodel.SModel), which is purely about nodes and model structure. To me, persistence shall be completely independent aspect, not exposed from SModel, however, at this moment the best we could do is to keep persistence within SModel descriptor and hope for the future changes (deprecate and remove methods like getDataSource, getProblems)- Specified by:
 getPersistenceVersionin interfacePersistenceVersionAware- Returns:
 - actual persistence version number of loaded/created model, or -1 if persistence versioning is not supported
 
 
- 
setPersistenceVersion
public void setPersistenceVersion(int persistenceVersion)
Description copied from interface:PersistenceVersionAwareIndicated persistence version for model serialization- Specified by:
 setPersistenceVersionin interfacePersistenceVersionAware- Parameters:
 persistenceVersion- persistence version number, or-1for undefined/unknown
 
- 
getModelFactory
@Nullable public ModelFactory getModelFactory()
Description copied from interface:PersistenceVersionAwareActualModelFactorywhich is currently responsible for model load/save, ornullif model knowns nothing about persistence at the moment.- Specified by:
 getModelFactoryin interfacePersistenceVersionAware- Returns:
 - model load/save facility or 
nullif undefined 
 
- 
saveModel
protected boolean saveModel() throws IOExceptionDescription copied from class:EditableSModelBasereturns true if the content should be reloaded from storage after save- Specified by:
 saveModelin classEditableSModelBase- Throws:
 IOException
 
- 
isGeneratable
public boolean isGeneratable()
Description copied from interface:GeneratableSModelGenerally,doNotGenerateis a primary reason to generate (or not) the model. However, if there's more than a simple option, this method gives a chance to control "to generate, or not to generate".- Specified by:
 isGeneratablein interfaceGeneratableSModel- Returns:
 trueif the model can serve as generator input
 
- 
isGenerateIntoModelFolder
public boolean isGenerateIntoModelFolder()
- Specified by:
 isGenerateIntoModelFolderin interfaceGeneratableSModel
 
- 
setGenerateIntoModelFolder
public void setGenerateIntoModelFolder(boolean value)
Description copied from interface:GeneratableSModelPROVISIONAL API. Likely to cease once there's better mechanism to override output directory than #isGenerateIntoModelFolder Update the value of generateIntoModelFolder attribute- Specified by:
 setGenerateIntoModelFolderin interfaceGeneratableSModel
 
- 
getModelHash
public String getModelHash()
- Specified by:
 getModelHashin interfaceGeneratableSModel
 
- 
setDoNotGenerate
public void setDoNotGenerate(boolean value)
- Specified by:
 setDoNotGeneratein interfaceGeneratableSModel
 
- 
isDoNotGenerate
public boolean isDoNotGenerate()
- Specified by:
 isDoNotGeneratein interfaceGeneratableSModel
 
- 
setAttribute
public void setAttribute(@NotNull String key, @Nullable String value)
Description copied from interface:ModelWithAttributesRecord extra data with a model- Specified by:
 setAttributein interfaceModelWithAttributes- Parameters:
 key- attribute identityvalue- attribute value, ornulldo remove an attribute, if any.
 
- 
getAttribute
@Nullable public String getAttribute(@NotNull String key)
Description copied from interface:ModelWithAttributesRetrieve extra model data.- Specified by:
 getAttributein interfaceModelWithAttributes- Parameters:
 key- attribute identity. There's no penalty if the key is unknown/unsupported with this model implementation- Returns:
 nullif there's no value for the key.
 
- 
forEach
public void forEach(@NotNull BiConsumer<String,String> action)
Description copied from interface:ModelWithAttributesIterate over all available attributes. Generally, not present attributes are not reported, however, clients shall expect null values, and implementation may report missing/deleted attributes. For now, the contract isactionshall not modify attributes, we might relax this in future (i.e. iterate over a copy of internal storage), if there are scenarios we find it handy.- Specified by:
 forEachin interfaceModelWithAttributes- Parameters:
 action- action to perform for each key-value attribute pair
 
- 
reloadContents
protected void reloadContents()
- Overrides:
 reloadContentsin classLazyEditableSModelBase
 
- 
getHeaderCopy
public SModelHeader getHeaderCopy()
 
 - 
 
 -