Package jetbrains.mps.generator
Class GenerationFacade
- java.lang.Object
 - 
- jetbrains.mps.generator.GenerationFacade
 
 
- 
public final class GenerationFacade extends Object
Entry point to model transformation (aka generation) process. Populate with relevant context information:messages(IMessageHandler)to receive generator messages (optional);transients(TransientModelsProvider)where to keep transient models (mandatory);taskHandler(GeneratorTaskListener)get notified about progress (optional);trace(TraceFacility)to get trace events (optional); then fire off withprocess(ProgressMonitor, List)IMPLEMENTATION NOTE: transformation requires model read lock for a repository of transformed model. At certain moments, it also requires write lock on a repository with transient modules. Although I can (and would like to) hide appropriate locks inside TransientModelsProvider, now these are explicit and are outside of the class to avoid accidental 'can't write from read'. Shall investigate if there's true need to expose transient modules in a repository right from the very beginning. If yes, shall double efforts to get distinct repository for transient modules (so that only transient repo is write-locked, while input model's repo is read-locked). 
- 
- 
Constructor Summary
Constructors Constructor Description GenerationFacade(SRepository repository, GenerationOptions generationOptions) 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleancanGenerate(SModel sm)GenerationFacademessages(IMessageHandler messages)Optional destination of all messages reported by generator, if none specified (ornull), messages get discarded.voidprocess(ProgressMonitor monitor, List<? extends GeneratorTask> tasks)Feed transformation process with sequence of task.GenerationStatusprocess(ProgressMonitor monitor, SModel model)Generate single model.GenerationFacadetaskHandler(GeneratorTaskListener<GeneratorTask> taskHandler)Optional handler to get notified about generation processGenerationFacadetrace(TraceFacility traceSession)PROVISIONAL API, PLEASE DON'T USE OUTSIDE OF MPSGenerationFacadetransients(TransientModelsProvider transientModelsProvider)Register facility responsible for transient model handling, mandatory. 
 - 
 
- 
- 
Constructor Detail
- 
GenerationFacade
public GenerationFacade(@NotNull SRepository repository, @NotNull GenerationOptions generationOptions)
 
 - 
 
- 
Method Detail
- 
canGenerate
public static boolean canGenerate(SModel sm)
 
- 
taskHandler
public GenerationFacade taskHandler(@Nullable GeneratorTaskListener<GeneratorTask> taskHandler)
Optional handler to get notified about generation process- Parameters:
 taskHandler- receives notifications- Returns:
 thisfor convenience
 
- 
transients
public GenerationFacade transients(@NotNull TransientModelsProvider transientModelsProvider)
Register facility responsible for transient model handling, mandatory.- Parameters:
 transientModelsProvider- transient model facility- Returns:
 thisfor convenience
 
- 
messages
public GenerationFacade messages(@Nullable IMessageHandler messages)
Optional destination of all messages reported by generator, if none specified (ornull), messages get discarded.- Parameters:
 messages- destination of generator messages, ornull- Returns:
 thisfor convenience
 
- 
trace
public GenerationFacade trace(@Nullable TraceFacility traceSession)
PROVISIONAL API, PLEASE DON'T USE OUTSIDE OF MPS 
- 
process
public GenerationStatus process(@NotNull ProgressMonitor monitor, @NotNull SModel model)
Generate single model.GenerationFacadeinstance can be reused then for other generation activities. IMPORTANT: unlikeprocess(ProgressMonitor, List), requires model write lock (on a repository of TransientModelsProvider) as it needs to create and publish module with transient models.- Parameters:
 monitor- report progress/cancellationmodel- input- Returns:
 - status object that describes generation outcome
 
 
- 
process
public void process(@NotNull ProgressMonitor monitor, @NotNull List<? extends GeneratorTask> tasks)
Feed transformation process with sequence of task. Tasks are processed in the order given. If a task deals with a model from a repository, calling code shall ensure respective read lock.- Parameters:
 monitor- report progress/cancellationtasks- models to generate
 
 - 
 
 -