public class ChainContext
extends java.lang.Object
Allows to: 1. register newly allocated variables' names 2. add before / after steps that can be added after transformation is complete 3. create different elements using PsiElementFactory
Modifier and Type | Field and Description |
---|---|
PsiElement |
myChainExpression |
Constructor and Description |
---|
ChainContext(ChainContext parentContext)
Constructs chain context using parent's context chain call, factory and registered names.
|
ChainContext(PsiElement chainExpression) |
Modifier and Type | Method and Description |
---|---|
void |
addAfterStep(java.lang.String afterStatement)
Add step that will be added after transformation result.
|
void |
addBeforeStep(java.lang.String beforeStatement)
Add step that will be added before transformation result.
|
PsiExpression |
createExpression(java.lang.String text)
Create expression from text in context of chain call.
|
PsiStatement |
createStatement(java.lang.String text)
Create statement from text in context of chain call.
|
PsiType |
createType(java.lang.String text)
Create type from text in context of chain call.
|
java.lang.String |
declare(java.lang.String desiredName,
java.lang.String type,
java.lang.String initializer)
Add variable declaration to beforeSteps.
|
java.lang.String |
drainAfterSteps()
Get all after steps and remove them from context.
|
java.lang.String |
drainBeforeSteps()
Get all before steps and remove them from context.
|
Project |
getProject()
Get chain call project.
|
java.lang.String |
registerVarName(java.util.Collection<java.lang.String> variants)
Choose name from variants for newly allocated variable and register it in context.
|
public PsiElement myChainExpression
public ChainContext(PsiElement chainExpression)
public ChainContext(ChainContext parentContext)
public java.lang.String registerVarName(java.util.Collection<java.lang.String> variants)
variants
- possible variable namespublic java.lang.String declare(java.lang.String desiredName, java.lang.String type, java.lang.String initializer)
desiredName
- desired name that is registered in contexttype
- variable typeinitializer
- variable initializerpublic void addBeforeStep(java.lang.String beforeStatement)
beforeStatement
- statement to addpublic java.lang.String drainBeforeSteps()
public void addAfterStep(java.lang.String afterStatement)
afterStatement
- statement to addpublic java.lang.String drainAfterSteps()
public PsiExpression createExpression(java.lang.String text)
public PsiStatement createStatement(java.lang.String text)
public PsiType createType(java.lang.String text)
public Project getProject()