Package jetbrains.mps.generator.impl
Class DefaultTemplateContext
- java.lang.Object
 - 
- jetbrains.mps.generator.impl.DefaultTemplateContext
 
 
- 
- All Implemented Interfaces:
 TemplateContext
public class DefaultTemplateContext extends Object implements TemplateContext
 
- 
- 
Constructor Summary
Constructors Constructor Description DefaultTemplateContext(TemplateExecutionEnvironment env, SNode inputNode, String inputName) 
- 
Method Summary
 
 - 
 
- 
- 
Method Detail
- 
getEnvironment
@NotNull public TemplateExecutionEnvironment getEnvironment()
- Specified by:
 getEnvironmentin interfaceTemplateContext
 
- 
getParent
public DefaultTemplateContext getParent()
 
- 
getInput
public SNode getInput()
- Specified by:
 getInputin interfaceTemplateContext
 
- 
getInputName
public String getInputName()
- Specified by:
 getInputNamein interfaceTemplateContext
 
- 
getPatternVariable
public Object getPatternVariable(String id)
- Specified by:
 getPatternVariablein interfaceTemplateContext
 
- 
getVariable
public Object getVariable(String name)
- Specified by:
 getVariablein interfaceTemplateContext
 
- 
hasVariable
public boolean hasVariable(String name)
- Specified by:
 hasVariablein interfaceTemplateContext
 
- 
getNamedInput
public SNode getNamedInput(String name)
- Specified by:
 getNamedInputin interfaceTemplateContext
 
- 
getInputHistory
public Iterable<SNode> getInputHistory()
- Specified by:
 getInputHistoryin interfaceTemplateContext
 
- 
subContext
public TemplateContext subContext(String inputName, SNode inputNode)
- Specified by:
 subContextin interfaceTemplateContext- 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
public TemplateContext subContext(String inputName)
- Specified by:
 subContextin interfaceTemplateContext- Parameters:
 inputName- new name for input, ornullto keep the old one- Returns:
 - new context that preserves input and gives it a new name
 
 
- 
subContext
public TemplateContext subContext(Map<String,Object> variables)
- Specified by:
 subContextin interfaceTemplateContext- Returns:
 - new context that preserves input, but discards 
mapping label 
 
- 
withVariable
public TemplateContext withVariable(String name, Object value)
Description copied from interface:TemplateContextAlternative toTemplateContext.subContext(Map)as it's rarely required to inject more than 1 variable at once, and to get a new contract, which preservesmapping label.- Specified by:
 withVariablein interfaceTemplateContext- Parameters:
 name- variable name,TemplateContext.getVariable(String), notnullvalue- varaible value, can benull- Returns:
 - new context that preserves input and 
mapping label, with new value for named variable. 
 
- 
subContext
public TemplateContext subContext(GeneratedMatchingPattern pattern)
- Specified by:
 subContextin interfaceTemplateContext- Returns:
 - new context that preserves input, but discards 
mapping label 
 
- 
subContext
public TemplateContext subContext()
Description copied from interface:TemplateContextReset input name, unlikeTemplateContext.subContext(String)andTemplateContext.subContext(String, org.jetbrains.mps.openapi.model.SNode)that treatnullinput name as indicator to keep the old one.- Specified by:
 subContextin interfaceTemplateContext- Returns:
 - context with un-named input (same as current context), with hierarchy of contexts preserved (i.e. #getInputHistory() would provide one)
 
 
- 
subContext
public TemplateContext subContext(SNode newInputNode)
Description copied from interface:TemplateContextShorthand forctx.subContext(ctx.getInputName(), newInputNode), to update input node while preserving current input name- Specified by:
 subContextin interfaceTemplateContext- Parameters:
 newInputNode- new input- Returns:
 - context with desired input and present input name
 
 
 - 
 
 -