Class InPlaceForCommand<I extends VariableDeclaration>
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.Expression
-
- net.ssehub.easy.instantiation.core.model.expressions.InPlaceCommand<I>
-
- net.ssehub.easy.instantiation.core.model.expressions.InPlaceForCommand<I>
-
- Type Parameters:
I- the variable declaration type
public class InPlaceForCommand<I extends VariableDeclaration> extends InPlaceCommand<I>
Replaces an in-place for-command/expression within a string/content expression.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Expression>bodyprivate ExpressionendSeparatorprivate Expressioninitprivate Iiteratorprivate Expressionseparator
-
Constructor Summary
Constructors Constructor Description InPlaceForCommand(I iterator, Expression init, Expression separator, Expression endSeparator)Creates an in-place loop command.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappend(java.util.List<Expression> exprs)Appends the sub-expressions in parse sequence toexprsleaving out this command as fallback.protected voidappend(Expression ex)Appends a sub-expression.protected Expressionclose(IStringParserFactory<I> factory)Closes this in-place command by creating the real expression.java.util.List<Expression>getBody()Returns the body expressions.ExpressiongetEndSeparator()Returns the optional end separator.ExpressiongetInit()Returns the initialization expression.IgetIterator()Returns the iterator variable.ExpressiongetSeparator()Returns the element separator.protected booleanholdsResolverLevel()Whether a cleanup of an erroneous parse stack requires cleaning up a resolver level.protected voidreplace(InPlaceCommand<I> cmd, Expression expr)Replacescmdbyexpr.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.InPlaceCommand
accept, advanceState, inferType, replace
-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.Expression
replaceEmptyLine
-
-
-
-
Field Detail
-
iterator
private I extends VariableDeclaration iterator
-
init
private Expression init
-
separator
private Expression separator
-
endSeparator
private Expression endSeparator
-
body
private java.util.List<Expression> body
-
-
Constructor Detail
-
InPlaceForCommand
public InPlaceForCommand(I iterator, Expression init, Expression separator, Expression endSeparator)
Creates an in-place loop command.- Parameters:
iterator- the iterator variableinit- the initialization expression (collection over iterator)separator- the optional element separatorendSeparator- the optional end separator
-
-
Method Detail
-
getIterator
public I getIterator()
Returns the iterator variable.- Returns:
- the iterator variable
-
getInit
public Expression getInit()
Returns the initialization expression.- Returns:
- the initialization expression
-
getSeparator
public Expression getSeparator()
Returns the element separator.- Returns:
- the element separator
-
getEndSeparator
public Expression getEndSeparator()
Returns the optional end separator.- Returns:
- the end separator expression (may be null)
-
getBody
public java.util.List<Expression> getBody()
Returns the body expressions.- Returns:
- the body expressions
-
append
protected void append(Expression ex)
Description copied from class:InPlaceCommandAppends a sub-expression. An in-place command can have multiple sub-structures, that are sequentially switched to active viaInPlaceCommand.advanceState().- Specified by:
appendin classInPlaceCommand<I extends VariableDeclaration>- Parameters:
ex- the expression to append
-
close
protected Expression close(IStringParserFactory<I> factory) throws VilException
Description copied from class:InPlaceCommandCloses this in-place command by creating the real expression.- Specified by:
closein classInPlaceCommand<I extends VariableDeclaration>- Parameters:
factory- the factory used to create the real expression- Returns:
- the real expression, may be null if optional / none shall be created
- Throws:
VilException- if the provided information is not sufficient for creating an expression
-
append
protected void append(java.util.List<Expression> exprs)
Description copied from class:InPlaceCommandAppends the sub-expressions in parse sequence toexprsleaving out this command as fallback.- Specified by:
appendin classInPlaceCommand<I extends VariableDeclaration>- Parameters:
exprs- the expressions to add the sub-expressions to
-
replace
protected void replace(InPlaceCommand<I> cmd, Expression expr)
Description copied from class:InPlaceCommandReplacescmdbyexpr.- Specified by:
replacein classInPlaceCommand<I extends VariableDeclaration>- Parameters:
cmd- the command to be replacedexpr- the replacing expression
-
holdsResolverLevel
protected boolean holdsResolverLevel()
Description copied from class:InPlaceCommandWhether a cleanup of an erroneous parse stack requires cleaning up a resolver level.- Overrides:
holdsResolverLevelin classInPlaceCommand<I extends VariableDeclaration>- Returns:
truefor cleanup,falseelse
-
-