Class WriterVisitor<V extends VariableDeclaration>
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.AbstractWriter
-
- net.ssehub.easy.instantiation.core.model.expressions.ExpressionWriter
-
- net.ssehub.easy.instantiation.core.model.common.WriterVisitor<V>
-
- Type Parameters:
V- the actual type of variable declaration
- All Implemented Interfaces:
IVisitor,IExpressionVisitor
- Direct Known Subclasses:
BuildlangWriter,TemplateLangWriter
public class WriterVisitor<V extends VariableDeclaration> extends ExpressionWriter implements IVisitor
A writer for VIL languages.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private booleanprintExpressionStatementIndentationprivate booleanprintExpressionStatementNewLine
-
Constructor Summary
Constructors Constructor Description WriterVisitor(java.io.Writer out)Creates a build language writer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanendsWithSemicolon(ExpressionStatement statement)Returns whether the given statement ends with a semicolon.protected booleanisPrintExpressionStatementIndentation()Returns whether indentations at expression statements shall be printed.protected booleanisPrintExpressionStatementNewLine()Returns whether a new line after expression statements shall be printed ifendsWithSemicolon(ExpressionStatement)istrue.protected static into2i(java.lang.Object object)Returns0of object is null else1.protected <R extends IMetaParameterDeclaration,M extends IModel>
voidprintCompounds(AbstractResolvableModel<R,M> model)Prints the typedefs ofmodel.protected voidprintModifiers(IModifierHolder holder)Prints the modifiers of the given modifierholder.protected voidprintParameterList(IParameterizable<V> parameterizable)Prints the parameter list ofparameterizable.protected <R extends IMetaParameterDeclaration,M extends IModel>
voidprintTypedefs(AbstractResolvableModel<R,M> model)Prints the typedefs ofmodel.protected voidprintVersion(Version ver)Prints the version.protected voidprintVersionRestrictions(IVersionRestriction restriction, boolean capitalize)Prints the version restriction.protected voidsetPrintExpressionStatementIndentation(boolean printExpressionStatementIndentation)Changes whether indentations at expression statements shall be printed.protected voidsetPrintExpressionStatementNewLine(boolean printExpressionStatementNewLine)Changes whether a new line after an expression statement shall be printed ifendsWithSemicolon(ExpressionStatement)istrue.java.lang.ObjectvisitAdvice(Advice advice)Visits an advice.java.lang.ObjectvisitCompound(Compound compound)Visits a compound.java.lang.ObjectvisitExpressionStatement(ExpressionStatement statement)Visits a statement.java.lang.ObjectvisitTypedef(Typedef typedef)Visits a typedef.java.lang.ObjectvisitVariableDeclaration(VariableDeclaration var)Visits a variable declaration.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.ExpressionWriter
considerOclCompliance, isInComposite, isInContent, printArgumentList, printArguments, printContentExpressions, printType, quoteExpression, setInContent, setOclCompliance, visitCallExpression, visitCompositeExpression, visitConstantExpression, visitContainerInitializerExpression, visitExpression, visitExpressionEvaluator, visitFieldAccessExpression, visitMultiAndExpression, visitParenthesisExpression, visitResolvableOperationCallExpression, visitResolvableOperationExpression, visitStringExpression, visitValueAssignmentExpression, visitVariableExpression, visitVarModelIdentifierExpression, visitVilTypeExpression
-
Methods inherited from class net.ssehub.easy.instantiation.core.model.expressions.AbstractWriter
decreaseIndentation, flush, getOut, increaseIndentation, print, print, print, print, printIndentation, printJavaEscaped, println, println, println, println, println, printWhitespace, setIndentation
-
-
-
-
Method Detail
-
isPrintExpressionStatementIndentation
protected boolean isPrintExpressionStatementIndentation()
Returns whether indentations at expression statements shall be printed.- Returns:
- whether indentations at expression statements shall be printed
-
setPrintExpressionStatementIndentation
protected void setPrintExpressionStatementIndentation(boolean printExpressionStatementIndentation)
Changes whether indentations at expression statements shall be printed.- Parameters:
printExpressionStatementIndentation- if indentations shall be printed or not
-
isPrintExpressionStatementNewLine
protected boolean isPrintExpressionStatementNewLine()
Returns whether a new line after expression statements shall be printed ifendsWithSemicolon(ExpressionStatement)istrue.- Returns:
- whether a new line after expression statements shall be printed
-
setPrintExpressionStatementNewLine
protected void setPrintExpressionStatementNewLine(boolean printExpressionStatementNewLine)
Changes whether a new line after an expression statement shall be printed ifendsWithSemicolon(ExpressionStatement)istrue.- Parameters:
printExpressionStatementNewLine- if a new line shall be printed or not
-
printModifiers
protected void printModifiers(IModifierHolder holder)
Prints the modifiers of the given modifierholder.- Parameters:
holder- the modifier holder
-
visitVariableDeclaration
public java.lang.Object visitVariableDeclaration(VariableDeclaration var) throws VilException
Description copied from interface:IVisitorVisits a variable declaration.- Specified by:
visitVariableDeclarationin interfaceIVisitor- Parameters:
var- the variable declaration- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
visitAdvice
public java.lang.Object visitAdvice(Advice advice) throws VilException
Description copied from interface:IVisitorVisits an advice.- Specified by:
visitAdvicein interfaceIVisitor- Parameters:
advice- the advice to be visited- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
printVersionRestrictions
protected void printVersionRestrictions(IVersionRestriction restriction, boolean capitalize)
Prints the version restriction.- Parameters:
restriction- the version restriction (may be null)capitalize- whether the "with" shall be stated in capital letters
-
printParameterList
protected void printParameterList(IParameterizable<V> parameterizable) throws VilException
Prints the parameter list ofparameterizable.- Parameters:
parameterizable- the element to print the parameter list- Throws:
VilException- in case that visiting fails
-
visitExpressionStatement
public java.lang.Object visitExpressionStatement(ExpressionStatement statement) throws VilException
Description copied from interface:IVisitorVisits a statement.- Specified by:
visitExpressionStatementin interfaceIVisitor- Parameters:
statement- the statement- Returns:
- the result of visiting the given statement (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
endsWithSemicolon
protected boolean endsWithSemicolon(ExpressionStatement statement)
Returns whether the given statement ends with a semicolon.- Parameters:
statement- the statement to check- Returns:
trueif it ends with a semicolon,falseelse
-
printVersion
protected void printVersion(Version ver)
Prints the version.- Parameters:
ver- the version to be printed
-
o2i
protected static final int o2i(java.lang.Object object)
Returns0of object is null else1.- Parameters:
object- the object to be tested- Returns:
0of object is null else1
-
visitTypedef
public java.lang.Object visitTypedef(Typedef typedef) throws VilException
Description copied from interface:IVisitorVisits a typedef.- Specified by:
visitTypedefin interfaceIVisitor- Parameters:
typedef- the typedef- Returns:
- the result of visiting (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
printTypedefs
protected <R extends IMetaParameterDeclaration,M extends IModel> void printTypedefs(AbstractResolvableModel<R,M> model) throws VilException
Prints the typedefs ofmodel.- Type Parameters:
R- the parameter typeM- the model type- Parameters:
model- the model to print the typedefs for- Throws:
VilException- in case of printing problems
-
printCompounds
protected <R extends IMetaParameterDeclaration,M extends IModel> void printCompounds(AbstractResolvableModel<R,M> model) throws VilException
Prints the typedefs ofmodel.- Type Parameters:
R- the parameter typeM- the model type- Parameters:
model- the model to print the typedefs for- Throws:
VilException- in case of printing problems
-
visitCompound
public java.lang.Object visitCompound(Compound compound) throws VilException
Description copied from interface:IVisitorVisits a compound.- Specified by:
visitCompoundin interfaceIVisitor- Parameters:
compound- the compound- Returns:
- the result of visiting (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
-