Class InPlaceCommand<I extends VariableDeclaration>
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.Expression
-
- net.ssehub.easy.instantiation.core.model.expressions.InPlaceCommand<I>
-
- Type Parameters:
I- the variable declaration type
- Direct Known Subclasses:
InPlaceForCommand,InPlaceIfCommand,InPlaceImportCommand,InPlaceVarDeclCommand
public abstract class InPlaceCommand<I extends VariableDeclaration> extends Expression
Replaces an in-place command/expression within a string/content expression. Implementing classes are intended to incrementally build up an expression or to return all collected sub-expressions in case that the specification in the string/content expression was incomplete. An in-place command is a (temporary) expression so that it can be later replaced in the parent in-place command when the real expression was created through theIStringParserFactory.- Author:
- Holger Eichelberger
-
-
Constructor Summary
Constructors Constructor Description InPlaceCommand()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Objectaccept(IExpressionVisitor visitor)Visits the expression.protected voidadvanceState()Changes among different states of sub-structures, e.g., then-part and else-part.protected abstract voidappend(java.util.List<Expression> exprs)Appends the sub-expressions in parse sequence toexprsleaving out this command as fallback.protected abstract voidappend(Expression ex)Appends a sub-expression.protected abstract Expressionclose(IStringParserFactory<I> factory)Closes this in-place command by creating the real expression.protected booleanholdsResolverLevel()Whether a cleanup of an erroneous parse stack requires cleaning up a resolver level.TypeDescriptor<?>inferType()Infers the type of this expression including the type of the contained sub-expressions.protected booleanreplace(java.util.List<Expression> exprs, InPlaceCommand<I> cmd, Expression expr)Replacescmdbyexprinexprs.protected abstract voidreplace(InPlaceCommand<I> cmd, Expression expr)Replacescmdbyexpr.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.Expression
replaceEmptyLine
-
-
-
-
Method Detail
-
append
protected abstract void append(Expression ex)
Appends a sub-expression. An in-place command can have multiple sub-structures, that are sequentially switched to active viaadvanceState().- Parameters:
ex- the expression to append
-
advanceState
protected void advanceState()
Changes among different states of sub-structures, e.g., then-part and else-part. Override if needed, else the respective call is just ignored.
-
close
protected abstract Expression close(IStringParserFactory<I> factory) throws VilException
Closes this in-place command by creating the real expression.- 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 abstract void append(java.util.List<Expression> exprs)
Appends the sub-expressions in parse sequence toexprsleaving out this command as fallback.- Parameters:
exprs- the expressions to add the sub-expressions to
-
replace
protected abstract void replace(InPlaceCommand<I> cmd, Expression expr)
Replacescmdbyexpr.- Parameters:
cmd- the command to be replacedexpr- the replacing expression
-
replace
protected boolean replace(java.util.List<Expression> exprs, InPlaceCommand<I> cmd, Expression expr)
Replacescmdbyexprinexprs.- Parameters:
exprs- the expressions list to be searched / modifiedcmd- the command to be replacedexpr- the expression to replacecmd- Returns:
trueif replacement was done,falseelse
-
inferType
public TypeDescriptor<?> inferType() throws VilException
Description copied from class:ExpressionInfers the type of this expression including the type of the contained sub-expressions.- Specified by:
inferTypein classExpression- Returns:
- the type of this expression
- Throws:
VilException- in case that inferring the type fails
-
accept
public java.lang.Object accept(IExpressionVisitor visitor) throws VilException
Description copied from class:ExpressionVisits the expression.- Specified by:
acceptin classExpression- Parameters:
visitor- the visitor- Returns:
- the result of visiting this expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
holdsResolverLevel
protected boolean holdsResolverLevel()
Whether a cleanup of an erroneous parse stack requires cleaning up a resolver level.- Returns:
truefor cleanup,falseelse
-
-