Package jetbrains.mps.generator.runtime
Interface TemplateContext
- 
- All Known Implementing Classes:
 DefaultTemplateContext
public interface TemplateContextHolds input and accompanying parameters (including mapping label) as we walk through template. Analogous to stack frames that keep method parameters; hierarchical with implicit access to outer scope (getVariable(String)looks up variable in super contexts) and explicit access to history of input nodes (getInputHistory())TemplateContextrepresents the lowest-level context of generation, with Generator at the top, supervising model transformation, andTemplateExecutionEnvironmentin the middle, responsible for thread/root generation and providing interaction with generation facilities. 
- 
- 
Method Summary
 
 - 
 
- 
- 
Method Detail
- 
getEnvironment
@NotNull TemplateExecutionEnvironment getEnvironment()
 
- 
getInput
SNode getInput()
 
- 
getInputName
String getInputName()
 
- 
hasVariable
boolean hasVariable(String name)
 
- 
subContext
TemplateContext subContext(String inputName, SNode inputNode)
- Parameters:
 inputName- new name for input, ornullto keep the old oneinputNode- new input node- Returns:
 - new context that updates both input and 
mapping label 
 
- 
subContext
TemplateContext subContext(String inputName)
- Parameters:
 inputName- new name for input, ornullto keep the old one- Returns:
 - new context that preserves input and gives it a new name
 
 
- 
subContext
TemplateContext subContext(Map<String,Object> variables)
- Returns:
 - new context that preserves input, but discards 
mapping label 
 
- 
withVariable
TemplateContext withVariable(String name, Object value)
Alternative tosubContext(Map)as it's rarely required to inject more than 1 variable at once, and to get a new contract, which preservesmapping label.- Parameters:
 name- variable name,getVariable(String), notnullvalue- varaible value, can benull- Returns:
 - new context that preserves input and 
mapping label, with new value for named variable. - Since:
 - 3.3
 
 
- 
subContext
TemplateContext subContext(GeneratedMatchingPattern pattern)
- Returns:
 - new context that preserves input, but discards 
mapping label 
 
- 
subContext
TemplateContext subContext()
Reset input name, unlikesubContext(String)andsubContext(String, org.jetbrains.mps.openapi.model.SNode)that treatnullinput name as indicator to keep the old one.- Returns:
 - context with un-named input (same as current context), with hierarchy of contexts preserved (i.e. #getInputHistory() would provide one)
 
 
- 
subContext
TemplateContext subContext(SNode newInputNode)
Shorthand forctx.subContext(ctx.getInputName(), newInputNode), to update input node while preserving current input name- Parameters:
 newInputNode- new input- Returns:
 - context with desired input and present input name
 
 
 - 
 
 -