Class PythonCodeBlock
java.lang.Object
net.ssehub.easy.instantiation.python.codeArtifacts.PythonCodeElement
net.ssehub.easy.instantiation.python.codeArtifacts.PythonCodeStmt
net.ssehub.easy.instantiation.python.codeArtifacts.PythonCodeBlock
- All Implemented Interfaces:
net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider,net.ssehub.easy.instantiation.core.model.vilTypes.IVilType,IPythonCodeElement,Storable
- Direct Known Subclasses:
PythonCodeAlternative,PythonCodeForLoop,PythonCodeFunction,PythonCodeMatch.PythonCodeCase,PythonCodeTryBlock,PythonCodeTryBlock.PythonCodeExceptBlock,PythonCodeWhileLoop,PythonCodeWith
Represents a Python code block in VTL.
- Author:
- Kevin Schaperjahn
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider
net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider.StringComparator -
Field Summary
FieldsFields inherited from interface net.ssehub.easy.instantiation.python.codeArtifacts.IPythonCodeElement
KEY_COMPARATOR -
Constructor Summary
ConstructorsConstructorDescriptionPythonCodeBlock(IPythonCodeArtifact artifact) PythonCodeBlock(IPythonCodeElement parent) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddBreak()Adds a "break" statement.addCall(String name, PythonCodeImportScope scope) Adds a class without comment.Adds a class with comment.addComment(String comment) voidAdds a "continue" statement.protected <T extends IPythonCodeElement>
TaddElt(T elt) protected <T extends IPythonCodeElement>
TaddElt(T elt, boolean importToFront) voidAdds an enum without comment.Adds an enum with comment.addNonLocal(String varName) voidaddPass()Adds a "pass" statement.addPrint()Adds a "print" function call.voidvoidaddSelfCall(String name) Adds a call to "self.".addSLComment(String comment) addSLComment(String comment, boolean enclosed) addSuperCall(String name) Adds a call to "super()".Adds a call to "super().__init__(...)".addTry()addTypeAlias(String name, String expr) intprotected PythonCodeClassbooleanisBlock()Returns whether this element is a block element.voidMoves the given import after the last import at the beginning of (this) artifact, or, if there are no imports, to the front.setBlock(PythonCodeBlock block) voidstore(net.ssehub.easy.instantiation.core.model.templateModel.CodeWriter out) Methods inherited from class net.ssehub.easy.instantiation.python.codeArtifacts.PythonCodeElement
getParent, setParentMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.ssehub.easy.instantiation.python.codeArtifacts.IPythonCodeElement
addAll, getSortKey, getStringValue, getTopClass, getTracerStringValue, hasPythondocComment, isAttribute, isClass, isEmptyLine, moveToAttributes
-
Field Details
-
elements
-
artifact
-
-
Constructor Details
-
PythonCodeBlock
-
PythonCodeBlock
-
-
Method Details
-
addElt
-
addElt
-
add
-
addRaw
-
addEmptyLine
public void addEmptyLine() -
addClass
Adds a class without comment.- Parameters:
name- the name of the class- Returns:
- the class for chaining
-
addClass
Adds a class with comment.- Parameters:
name- the name of the classcomment- the comment for the class- Returns:
- the class for chaining
-
addEnum
Adds an enum without comment.- Parameters:
name- the name of the enum- Returns:
- the enum for chaining
-
addEnum
Adds an enum with comment.- Parameters:
name- the name of the enumcomment- the comment for the enum- Returns:
- the enum for chaining
-
addFunc
-
addFunc
-
addTypeAlias
-
addAssign
-
addAssign
-
addCall
-
addSuperCall
Adds a call to "super()".- Parameters:
name- the name of the function- Returns:
- the function call for chaining
-
addSuperConstructorCall
Adds a call to "super().__init__(...)".- Returns:
- the function call for chaining
-
addSelfCall
Adds a call to "self.".- Parameters:
name- the name of the function- Returns:
- the function for chaining
-
addCall
-
addIf
-
addMatch
-
addWhile
-
addFor
-
addFor
-
addFor
public PythonCodeForLoop addFor(String element, String rangeStart, String rangeEnd, String rangeStep) -
addWith
-
addWith
-
addTry
-
addRaise
-
addComment
-
addSLComment
-
addSLComment
-
addDelete
-
addNonLocal
-
addGlobal
-
addAssert
-
addAssert
-
addReturn
-
addContinue
public void addContinue()Adds a "continue" statement. -
addBreak
public void addBreak()Adds a "break" statement. -
addPass
public void addPass()Adds a "pass" statement. -
addPrint
Adds a "print" function call.- Returns:
- the function call
-
setBlock
-
store
public void store(net.ssehub.easy.instantiation.core.model.templateModel.CodeWriter out) -
getElementCount
public int getElementCount() -
getParentClass
-
getArtifact
- Specified by:
getArtifactin interfaceIPythonCodeElement- Overrides:
getArtifactin classPythonCodeElement
-
isBlock
public boolean isBlock()Description copied from interface:IPythonCodeElementReturns whether this element is a block element.- Returns:
truefor block,falseelse
-
moveToImports
Description copied from interface:IPythonCodeElementMoves the given import after the last import at the beginning of (this) artifact, or, if there are no imports, to the front.- Parameters:
imp- the import to move
-