Class ContentStatement
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.templateModel.AbstractTemplateElement
-
- net.ssehub.easy.instantiation.core.model.templateModel.ContentStatement
-
- All Implemented Interfaces:
ILanguageElement,ITemplateElement,ITemplateLangElement
public class ContentStatement extends AbstractTemplateElement
Implements a statement which contains content.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classContentStatement.LineEndTypeDefines the line end types.
-
Field Summary
Fields Modifier and Type Field Description private CompositeExpressioncontentprivate ExpressionindentExpressionprivate ContentStatement.LineEndTypelineEndTypeprivate java.lang.Stringterminal
-
Constructor Summary
Constructors Constructor Description ContentStatement()Constructor for serialization.ContentStatement(CompositeExpression content, java.lang.String terminal, Expression indentExpression, ContentStatement.LineEndType lineEndType, ILanguageElement parent)Creates a new content statement.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectaccept(IVisitor visitor)Accepts the visitor for visiting.booleanendsWithContentStatement()Returns whether this element ends with a content statement.CompositeExpressiongetContent()Returns the content.ExpressiongetIndentExpression()Returns the integer expression specifying the additional indentation.ContentStatement.LineEndTypegetLineEndType()Returns the line end type.java.lang.StringgetTerminal()Returns the terminal to encapsulate the content in the underlying template.TypeDescriptor<?>inferType()Infers the type of this language element.booleanisBlock()Returns whether this element is a block (opposite is a single statement).booleanneedsLineEnd(boolean deflt)Returns whether a line end shall be emitted.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.templateModel.AbstractTemplateElement
getParent, isLoop, setParent
-
-
-
-
Field Detail
-
content
private CompositeExpression content
-
terminal
private java.lang.String terminal
-
indentExpression
private Expression indentExpression
-
lineEndType
private ContentStatement.LineEndType lineEndType
-
-
Constructor Detail
-
ContentStatement
ContentStatement()
Constructor for serialization.
-
ContentStatement
public ContentStatement(CompositeExpression content, java.lang.String terminal, Expression indentExpression, ContentStatement.LineEndType lineEndType, ILanguageElement parent) throws VilException
Creates a new content statement.- Parameters:
content- the contentterminal- the limiting terminal (at start and end)indentExpression- an optional integer expression determining the additional indentation, e.g., in loops or recursionslineEndType- the line end typeparent- the parent language element- Throws:
VilException- in case that the expression cannot be resolved or does not evaluate to an integer
-
-
Method Detail
-
needsLineEnd
public boolean needsLineEnd(boolean deflt)
Returns whether a line end shall be emitted.- Parameters:
deflt- the value to be taken forContentStatement.LineEndType.DEFAULT- Returns:
trueif a line end shall be emitted,falseelse
-
getLineEndType
public ContentStatement.LineEndType getLineEndType()
Returns the line end type.- Returns:
- the line end type
-
getContent
public CompositeExpression getContent()
Returns the content.- Returns:
- the content
-
getTerminal
public java.lang.String getTerminal()
Returns the terminal to encapsulate the content in the underlying template.- Returns:
- the terminal
-
accept
public java.lang.Object accept(IVisitor visitor) throws VilException
Description copied from interface:ITemplateLangElementAccepts the visitor for visiting.- Parameters:
visitor- the visitor to be used- Returns:
- the result of visiting this instance (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
isBlock
public boolean isBlock()
Description copied from interface:ITemplateElementReturns whether this element is a block (opposite is a single statement).- Returns:
trueif it is a block,falseelse
-
inferType
public TypeDescriptor<?> inferType() throws VilException
Description copied from interface:ITemplateElementInfers the type of this language element.- Returns:
- the type of this language element
- Throws:
VilException- in case that type errors occur
-
getIndentExpression
public Expression getIndentExpression()
Returns the integer expression specifying the additional indentation.- Returns:
- the indent expression (may be null)
-
endsWithContentStatement
public boolean endsWithContentStatement()
Description copied from interface:ITemplateElementReturns whether this element ends with a content statement.- Returns:
truefor end with content statement,falseelse
-
-