Class VariableDeclaration
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.common.VariableDeclaration
-
- net.ssehub.easy.instantiation.core.model.templateModel.VariableDeclaration
-
- All Implemented Interfaces:
IVariable,ILanguageElement,IModifierHolder,IResolvable,ITemplateElement,ITemplateLangElement,IMetaParameterDeclaration
- Direct Known Subclasses:
ImplicitVariableDeclaration
public class VariableDeclaration extends VariableDeclaration implements ITemplateLangElement, ITemplateElement
Represents a variable declaration.- Author:
- Christian Kr�her, Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private ILanguageElementparent
-
Constructor Summary
Constructors Constructor Description VariableDeclaration()Constructor for serialization.VariableDeclaration(java.lang.String name, TypeDescriptor<?> type)Creates a new variable declaration.VariableDeclaration(java.lang.String name, TypeDescriptor<?> type, boolean isConstant, Expression expression)Creates a new variable declaration.
-
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.ILanguageElementgetParent()Returns the parent element.TypeDescriptor<?>inferType()Infers the type of this language element.booleanisBlock()Returns whether this element is a block (opposite is a single statement).booleanisLoop()Returns whether this element is a loop.protected voidsetParent(ILanguageElement parent)Changes the parent.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.common.VariableDeclaration
accept, addModifier, getExpression, getModifier, getModifierCount, getName, getParameter, getRequiredParameterCount, getType, hasExplicitType, hasModifier, isConstant, isImplicit, mapDefaultedParameters, resolveOperation, setHasExplicitType, setIsConstant, toString
-
-
-
-
Field Detail
-
parent
private ILanguageElement parent
-
-
Constructor Detail
-
VariableDeclaration
VariableDeclaration()
Constructor for serialization.
-
VariableDeclaration
public VariableDeclaration(java.lang.String name, TypeDescriptor<?> type)Creates a new variable declaration. Parent must be explicitly adjusted by parent instance.- Parameters:
name- the name of the variabletype- the type of the variable
-
VariableDeclaration
public VariableDeclaration(java.lang.String name, TypeDescriptor<?> type, boolean isConstant, Expression expression)Creates a new variable declaration.- Parameters:
name- the name of the variabletype- the type of the variableisConstant- whether this variable is a constantexpression- an expression denoting the initial value (may be null)
-
-
Method Detail
-
accept
public java.lang.Object accept(IVisitor visitor) throws VilException
Description copied from interface:ITemplateLangElementAccepts the visitor for visiting.- Specified by:
acceptin interfaceITemplateLangElement- 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)
-
isLoop
public boolean isLoop()
Description copied from interface:ITemplateElementReturns whether this element is a loop.- Specified by:
isLoopin interfaceITemplateElement- Returns:
trueif it is a loop,falseelse
-
isBlock
public boolean isBlock()
Description copied from interface:ITemplateElementReturns whether this element is a block (opposite is a single statement).- Specified by:
isBlockin interfaceITemplateElement- Returns:
trueif it is a block,falseelse
-
inferType
public TypeDescriptor<?> inferType() throws VilException
Description copied from interface:ITemplateElementInfers the type of this language element.- Specified by:
inferTypein interfaceITemplateElement- Returns:
- the type of this language element
- Throws:
VilException- in case that type errors occur
-
getParent
public ILanguageElement getParent()
Description copied from interface:ILanguageElementReturns the parent element.- Specified by:
getParentin interfaceILanguageElement- Returns:
- the parent element (may be null if unknown)
-
setParent
protected void setParent(ILanguageElement parent)
Changes the parent. Please override if children must be adjusted according. Shall be called only once per instance, but there is no limitation.- Parameters:
parent- the parent
-
endsWithContentStatement
public boolean endsWithContentStatement()
Description copied from interface:ITemplateElementReturns whether this element ends with a content statement.- Specified by:
endsWithContentStatementin interfaceITemplateElement- Returns:
truefor end with content statement,falseelse
-
-