Interface IPythonCodeElement
- All Superinterfaces:
net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider,net.ssehub.easy.instantiation.core.model.vilTypes.IVilType,Storable
- All Known Subinterfaces:
IPythonCodeImport
- All Known Implementing Classes:
PythonCodeAlternative,PythonCodeAssert,PythonCodeAssign,PythonCodeBlock,PythonCodeClass,PythonCodeConstructorCall,PythonCodeDecorator,PythonCodeDecoratorArg,PythonCodeDelete,PythonCodeDocComment,PythonCodeElement,PythonCodeEnum,PythonCodeEnum.PythonCodeEnumLiteral,PythonCodeExpr,PythonCodeFnCall,PythonCodeFnCall.NamedArgument,PythonCodeForLoop,PythonCodeFunction,PythonCodeGlobal,PythonCodeImport,PythonCodeLambdaExpr,PythonCodeMatch,PythonCodeMatch.PythonCodeCase,PythonCodeNonLocal,PythonCodeParamSpec,PythonCodeRaise,PythonCodeSingleLineComment,PythonCodeStmt,PythonCodeText,PythonCodeTryBlock,PythonCodeTryBlock.PythonCodeExceptBlock,PythonCodeTypeAlias,PythonCodeTypeSpec,PythonCodeWhileLoop,PythonCodeWith,PythonCodeWith.PythonCodeWithItem
public interface IPythonCodeElement
extends net.ssehub.easy.instantiation.core.model.vilTypes.IVilType, net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider, Storable
Declares a generic Python code element.
- 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
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <L,E extends L>
Estatic <L,E extends L>
Edefault voidaddAll(List<IPythonCodeElement> list) static StringappendSeparator(String text, String separator) static StringappendWhitespace(String text) static <T extends Enum<T>>
TgetFormattingArgument(Class<T> cls, String key, T dflt) default Stringdefault StringgetStringValue(net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider.StringComparator comparator) default IPythonCodeElementdefault StringgetTracerStringValue(net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider.StringComparator comparator) default booleandefault booleanReturns whether this element is a (class) property/attribute.default booleanisBlock()Returns whether this element is a block element.default booleanisClass()Returns whether this element is a class(-like) element.default booleanReturns whether this element is an empty line.static voidmoveTo(List<IPythonCodeElement> elts, IPythonCodeElement elt, Class<?> cls) Moveseltafter the last instance ofcls.static voidmoveTo(List<IPythonCodeElement> elts, IPythonCodeElement elt, Predicate<IPythonCodeElement> cond) Moveseltafter the last acceptance ofcond.default voidmoveToAttributes(IPythonCodeElement element) Moves the given code element after the last attribute at the beginning of (this) class, or, if there are no attributes, to the front.default voidMoves the given import after the last import at the beginning of (this) artifact, or, if there are no imports, to the front.voidsetParent(IPythonCodeElement parent) static <T extends IPythonCodeElement>
voidsetParent(IPythonCodeElement parent, Class<T> cls, Consumer<T> setter) static voidsort(List<IPythonCodeElement> list, Comparator<IPythonCodeElement> comparator) static voidstoreList(String prefix, List<? extends IPythonCodeElement> elements, String separator, net.ssehub.easy.instantiation.core.model.templateModel.CodeWriter out) static voidstoreList(List<? extends IPythonCodeElement> elements, String separator, net.ssehub.easy.instantiation.core.model.templateModel.CodeWriter out) static StringMethods inherited from interface net.ssehub.easy.instantiation.python.codeArtifacts.Storable
getElementCount, store, toCode
-
Field Details
-
KEY_COMPARATOR
-
-
Method Details
-
getArtifact
IPythonCodeArtifact getArtifact() -
getTopClass
-
getParent
IPythonCodeElement getParent() -
setParent
-
addAll
-
hasPythondocComment
default boolean hasPythondocComment() -
getSortKey
-
isAttribute
default boolean isAttribute()Returns whether this element is a (class) property/attribute.- Returns:
truefor attribute,falseelse
-
isClass
default boolean isClass()Returns whether this element is a class(-like) element.- Returns:
truefor class,falseelse
-
isBlock
default boolean isBlock()Returns whether this element is a block element.- Returns:
truefor block,falseelse
-
isEmptyLine
default boolean isEmptyLine()Returns whether this element is an empty line.- Returns:
truefor empty line,falseelse
-
getTracerStringValue
default String getTracerStringValue(net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider.StringComparator comparator) -
getStringValue
default String getStringValue(net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider.StringComparator comparator) - Specified by:
getStringValuein interfacenet.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider
-
add
-
add
-
appendWhitespace
-
appendSeparator
-
storeList
static void storeList(List<? extends IPythonCodeElement> elements, String separator, net.ssehub.easy.instantiation.core.model.templateModel.CodeWriter out) -
storeList
static void storeList(String prefix, List<? extends IPythonCodeElement> elements, String separator, net.ssehub.easy.instantiation.core.model.templateModel.CodeWriter out) -
toList
-
setParent
static <T extends IPythonCodeElement> void setParent(IPythonCodeElement parent, Class<T> cls, Consumer<T> setter) -
getFormattingArgument
-
sort
-
moveTo
Moveseltafter the last instance ofcls. If there is no such instance, moveeltto the front.- Parameters:
elts- the elements to manipulateelt- the element to move/insertcls- the class to look for
-
moveTo
static void moveTo(List<IPythonCodeElement> elts, IPythonCodeElement elt, Predicate<IPythonCodeElement> cond) Moveseltafter the last acceptance ofcond. If there is no such acceptance, moveeltto the front.- Parameters:
elts- the elements to manipulateelt- the element to move/insertcond- the condition
-
moveToAttributes
Moves the given code element after the last attribute at the beginning of (this) class, or, if there are no attributes, to the front.- Parameters:
element- the element to move
-
moveToImports
Moves 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
-