Package jetbrains.mps.smodel.impl
Class StructureAspectChangeTracker
- java.lang.Object
 - 
- org.jetbrains.mps.openapi.module.SRepositoryListenerBase
 - 
- jetbrains.mps.smodel.impl.StructureAspectChangeTracker
 
 
 
- 
- All Implemented Interfaces:
 SModelListener,SNodeChangeListener,SRepositoryAttachListener,SRepositoryListener
public final class StructureAspectChangeTracker extends SRepositoryListenerBase implements SRepositoryAttachListener, SNodeChangeListener, SModelListener
Tracks changes to language concepts throughout whole repository.SModel modelWithInstancesOfSomeConcepts; StructureAspectChangeTracker t = new StructureAspectChangeTracker(null, new ModuleListener() { void structureAspectChanged(...) { revalidateCaches(); } }); t.attachTo(model.getRepository()); ... // code that relies on meta-model, and needs to update once meta-model changes (e.g. caches by concept FQN) SNode n; myCacheMap.put(n.getConcept().getQualifiedName(), ...); ... // much later t.detachFrom(model.getRepository()); 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceStructureAspectChangeTracker.ModelListenerstatic interfaceStructureAspectChangeTracker.ModuleListener 
- 
Constructor Summary
Constructors Constructor Description StructureAspectChangeTracker(StructureAspectChangeTracker.ModelListener l1, StructureAspectChangeTracker.ModuleListener l2) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeforeModuleRemoved(SModule module)voidcommandFinished(SRepository repository)voidconflictDetected(SModel model)This event is fired when the storage-memory conflict is detected (== isChanged() && needsReloading()).voidmodelAttached(SModel model, SRepository repository)Fired when a model becomes visible in a repository.voidmodelDetached(SModel model, SRepository repository)Fired when a model is no longer part of a repository, e.g.voidmodelLoaded(SModel model, boolean partially)voidmodelReplaced(SModel model)voidmodelSaved(SModel model)voidmodelUnloaded(SModel model)voidmoduleAdded(SModule module)voidnodeAdded(SNodeAddEvent event)voidnodeRemoved(SNodeRemoveEvent event)voidproblemsDetected(SModel model, Iterable<SModel.Problem> problems)This method is called each time a new problem, or a set of problems is discovered.voidpropertyChanged(SPropertyChangeEvent event)voidreferenceChanged(SReferenceChangeEvent event)voidstartListening(SRepository repository)voidstopListening(SRepository repository)- 
Methods inherited from class org.jetbrains.mps.openapi.module.SRepositoryListenerBase
commandStarted, moduleRemoved, repositoryCommandFinished, repositoryCommandStarted, updateFinished, updateStarted 
- 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
- 
Methods inherited from interface org.jetbrains.mps.openapi.module.SRepositoryListener
commandStarted, moduleRemoved, repositoryCommandFinished, repositoryCommandStarted, updateFinished, updateStarted 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
StructureAspectChangeTracker
public StructureAspectChangeTracker(StructureAspectChangeTracker.ModelListener l1, StructureAspectChangeTracker.ModuleListener l2)
 
 - 
 
- 
Method Detail
- 
startListening
public void startListening(@NotNull SRepository repository)
- Specified by:
 startListeningin interfaceSRepositoryAttachListener
 
- 
stopListening
public void stopListening(SRepository repository)
- Specified by:
 stopListeningin interfaceSRepositoryAttachListener
 
- 
moduleAdded
public void moduleAdded(@NotNull SModule module)
- Specified by:
 moduleAddedin interfaceSRepositoryListener- Overrides:
 moduleAddedin classSRepositoryListenerBase
 
- 
beforeModuleRemoved
public void beforeModuleRemoved(@NotNull SModule module)
- Specified by:
 beforeModuleRemovedin interfaceSRepositoryListener- Overrides:
 beforeModuleRemovedin classSRepositoryListenerBase
 
- 
nodeAdded
public void nodeAdded(@NotNull SNodeAddEvent event)
- Specified by:
 nodeAddedin interfaceSNodeChangeListener
 
- 
nodeRemoved
public void nodeRemoved(@NotNull SNodeRemoveEvent event)
- Specified by:
 nodeRemovedin interfaceSNodeChangeListener
 
- 
propertyChanged
public void propertyChanged(@NotNull SPropertyChangeEvent event)
- Specified by:
 propertyChangedin interfaceSNodeChangeListener
 
- 
referenceChanged
public void referenceChanged(@NotNull SReferenceChangeEvent event)
- Specified by:
 referenceChangedin interfaceSNodeChangeListener
 
- 
commandFinished
public void commandFinished(SRepository repository)
- Specified by:
 commandFinishedin interfaceSRepositoryListener- Overrides:
 commandFinishedin classSRepositoryListenerBase- See Also:
 CommandListener.commandFinished()
 
- 
modelLoaded
public void modelLoaded(SModel model, boolean partially)
- Specified by:
 modelLoadedin interfaceSModelListener
 
- 
modelReplaced
public void modelReplaced(SModel model)
- Specified by:
 modelReplacedin interfaceSModelListener
 
- 
modelUnloaded
public void modelUnloaded(SModel model)
- Specified by:
 modelUnloadedin interfaceSModelListener
 
- 
modelSaved
public void modelSaved(SModel model)
- Specified by:
 modelSavedin interfaceSModelListener
 
- 
conflictDetected
public void conflictDetected(SModel model)
Description copied from interface:SModelListenerThis event is fired when the storage-memory conflict is detected (== isChanged() && needsReloading()). An IDE can listen to it and give user a way to resolve the conflict by invoking either updateTimestamp(), or reloadFromSource().- Specified by:
 conflictDetectedin interfaceSModelListener
 
- 
problemsDetected
public void problemsDetected(SModel model, Iterable<SModel.Problem> problems)
Description copied from interface:SModelListenerThis method is called each time a new problem, or a set of problems is discovered.- Specified by:
 problemsDetectedin interfaceSModelListener
 
- 
modelAttached
public void modelAttached(SModel model, SRepository repository)
Description copied from interface:SModelListenerFired when a model becomes visible in a repository. IMPORTANT: it's unspecified whether the model is part of a module the moment this event is fired or not. Do not expectSModel.getModule()to give meaningful value. This contract may change (i.e. become stricter) in future. NOTE: This is not an event most clients could make use of, as it's technically tricky to attach a listener to a model not yet visible inside a repository, and thus it's more of internal mechanism (i.e. code that instantiates a model may attach a listener to not yet published model and thus get notified). Besides, detached models do not get their listeners automatically discarded, and the listeners get a chance to react to model detach/re-attach sequence with this event.- Specified by:
 modelAttachedin interfaceSModelListener- Parameters:
 model- affected model, nevernullrepository- repository the model become available at, nevernull
 
- 
modelDetached
public void modelDetached(SModel model, SRepository repository)
Description copied from interface:SModelListenerFired when a model is no longer part of a repository, e.g. due to removal from module. This event is intended to clean-up listener caches associated with the model and to gracefully unregister other listeners. IMPORTANT: it's unspecified whether the model is part of a module the moment this event is fired or not. Do not expectSModel.getModule()to give meaningful value. This contract may change (i.e. become stricter) in future. Primary drive force for this event is desire to add model listener only, without a need to listen to module events to find out when the model is no longer available. Note, listeners not unregistered from the model would get notified withSModelListener.modelAttached(SModel, SRepository)in case detached model is brought back (perhaps, in completely different module and repository).- Specified by:
 modelDetachedin interfaceSModelListener- Parameters:
 model- affected model, nevernullrepository- repository the model become available at, nevernull
 
 - 
 
 -