Record Class FunctionDef
java.lang.Object
java.lang.Record
io.micronaut.python.processing.model.FunctionDef
- Record Components:
name- The name of the function.arguments- The function arguments.decorators- The decorators.returnType- The parsed return type information.typeComment- The type comment.typeParams- The type parameters.documentation- The function documentation string.isAbstract- Whether the function is abstract: decorated with@abstractmethod, a member of aProtocol, or a placeholder body in anABC.isStatic- Whether the function is static (decorated with @staticmethod or @classmethod).isAsync- Whether the function was declared withasync def.hasReturnValue- Whether the function body contains a return statement with a non-None value.hasPlaceholderBody- Whether the function body is only the...placeholder. Such a function is abstract in an introduction type, whose methods are implemented by the introduction advice, and a method returningNonein a concrete class.declaringClass- Declaring class, can be null if there is nonesuperArguments- The arguments of thesuper().__init__(...)call of a constructor, orisGenerator- Whether the function body contains a yield of its own; withisAsyncthe function is an async generator, bridged as a Publisher of its elements.nullwhen the function is not a constructor or does not call the super constructor
- All Implemented Interfaces:
ElementDef, MemberDef
public record FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync, boolean hasReturnValue, boolean hasPlaceholderBody, ClassDef declaringClass, @Nullable List<SuperArgumentDef> superArguments, boolean isGenerator)
extends Record
implements ElementDef, MemberDef
A FunctionDef node represents a function definition.
FunctionDef(identifier name, arguments args, list[stmt] body, list[expr] decorator_list, expr | None returns, string | None type_comment, list[type_param] type_params)
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFunctionDef(String name) FunctionDef(String name, ArgumentsDef arguments, ReturnDef returnType) FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType) FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract) FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic) FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync) FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync, boolean hasReturnValue) FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync, boolean hasReturnValue, boolean hasPlaceholderBody, boolean isGenerator) Creates a function as the processor parses it: no declaring class and no super constructor call yet.FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync, boolean hasReturnValue, boolean hasPlaceholderBody, ClassDef declaringClass) Creates a function without a recorded super constructor call.FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync, boolean hasReturnValue, boolean hasPlaceholderBody, ClassDef declaringClass, @Nullable List<SuperArgumentDef> superArguments) Creates a function that is not a generator.FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync, boolean hasReturnValue, boolean hasPlaceholderBody, ClassDef declaringClass, @Nullable List<SuperArgumentDef> superArguments, boolean isGenerator) Creates an instance of aFunctionDefrecord class.FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync, boolean hasReturnValue, ClassDef declaringClass) Creates a function with a regular body and without a recorded super constructor call.FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, ClassDef declaringClass) FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, String returnTypeAnnotation, List<DecoratorDef> returnTypeDecorators) FunctionDef(String name, List<DecoratorDef> decoratorList) FunctionDef(String name, List<String> argumentNames, List<String> argumentTypes, String returnTypeAnnotation) FunctionDef(String name, List<String> argumentNames, List<String> argumentTypes, List<DecoratorDef> decorators, String returnTypeAnnotation) -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theargumentsrecord component.Returns the value of thedeclaringClassrecord component.Returns the value of thedecoratorsrecord component.Returns the value of thedocumentationrecord component.booleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for this object.booleanReturns the value of thehasPlaceholderBodyrecord component.booleanReturns the value of thehasReturnValuerecord component.booleanReturns the value of theisAbstractrecord component.booleanisAsync()Returns the value of theisAsyncrecord component.booleanReturns the value of theisGeneratorrecord component.booleanisStatic()Returns the value of theisStaticrecord component.name()Returns the value of thenamerecord component.Get the parsed return type as ReturnDef.Returns the value of thesuperArgumentsrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thetypeCommentrecord component.Returns the value of thetypeParamsrecord component.withClassDef(ClassDef classDef) withSuperArguments(@Nullable List<SuperArgumentDef> superArguments) Records the arguments of thesuper().__init__(...)call of this constructor.
-
Field Details
-
CONSTRUCTOR_NAME
- See Also:
-
-
Constructor Details
-
FunctionDef
public FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync, boolean hasReturnValue, boolean hasPlaceholderBody, ClassDef declaringClass, @Nullable @Nullable List<SuperArgumentDef> superArguments, boolean isGenerator) Creates an instance of aFunctionDefrecord class.- Parameters:
name- the value for thenamerecord componentarguments- the value for theargumentsrecord componentdecorators- the value for thedecoratorsrecord componentreturnType- the value for thereturnTyperecord componenttypeComment- the value for thetypeCommentrecord componenttypeParams- the value for thetypeParamsrecord componentdocumentation- the value for thedocumentationrecord componentisAbstract- the value for theisAbstractrecord componentisStatic- the value for theisStaticrecord componentisAsync- the value for theisAsyncrecord componenthasReturnValue- the value for thehasReturnValuerecord componenthasPlaceholderBody- the value for thehasPlaceholderBodyrecord componentdeclaringClass- the value for thedeclaringClassrecord componentsuperArguments- the value for thesuperArgumentsrecord componentisGenerator- the value for theisGeneratorrecord component
-
FunctionDef
public FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync, boolean hasReturnValue, boolean hasPlaceholderBody, ClassDef declaringClass, @Nullable @Nullable List<SuperArgumentDef> superArguments) Creates a function that is not a generator. -
FunctionDef
public FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync, boolean hasReturnValue, boolean hasPlaceholderBody, boolean isGenerator) Creates a function as the processor parses it: no declaring class and no super constructor call yet. -
FunctionDef
public FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync, boolean hasReturnValue, boolean hasPlaceholderBody, ClassDef declaringClass) Creates a function without a recorded super constructor call. -
FunctionDef
public FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync, boolean hasReturnValue, ClassDef declaringClass) Creates a function with a regular body and without a recorded super constructor call. -
FunctionDef
public FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType) -
FunctionDef
-
FunctionDef
-
FunctionDef
-
FunctionDef
-
FunctionDef
-
FunctionDef
public FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, String returnTypeAnnotation, List<DecoratorDef> returnTypeDecorators) -
FunctionDef
public FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract) -
FunctionDef
public FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic) -
FunctionDef
public FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync) -
FunctionDef
public FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, boolean isAsync, boolean hasReturnValue) -
FunctionDef
public FunctionDef(String name, ArgumentsDef arguments, List<DecoratorDef> decorators, ReturnDef returnType, String typeComment, List<TypeVar> typeParams, String documentation, boolean isAbstract, boolean isStatic, ClassDef declaringClass)
-
-
Method Details
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
hashCode
-
returnType
Get the parsed return type as ReturnDef. -
withClassDef
-
withSuperArguments
Records the arguments of thesuper().__init__(...)call of this constructor.- Parameters:
superArguments- The arguments, ornullwhen the constructor does not call the super constructor- Returns:
- The function with the super constructor call recorded
-
toString
-
name
Returns the value of thenamerecord component.- Specified by:
namein interfaceElementDef- Returns:
- the value of the
namerecord component
-
arguments
-
decorators
Returns the value of thedecoratorsrecord component.- Specified by:
decoratorsin interfaceElementDef- Returns:
- the value of the
decoratorsrecord component
-
typeComment
Returns the value of thetypeCommentrecord component.- Returns:
- the value of the
typeCommentrecord component
-
typeParams
Returns the value of thetypeParamsrecord component.- Returns:
- the value of the
typeParamsrecord component
-
documentation
Returns the value of thedocumentationrecord component.- Returns:
- the value of the
documentationrecord component
-
isAbstract
public boolean isAbstract()Returns the value of theisAbstractrecord component.- Returns:
- the value of the
isAbstractrecord component
-
isStatic
-
isAsync
-
hasReturnValue
public boolean hasReturnValue()Returns the value of thehasReturnValuerecord component.- Returns:
- the value of the
hasReturnValuerecord component
-
hasPlaceholderBody
public boolean hasPlaceholderBody()Returns the value of thehasPlaceholderBodyrecord component.- Returns:
- the value of the
hasPlaceholderBodyrecord component
-
declaringClass
Returns the value of thedeclaringClassrecord component.- Specified by:
declaringClassin interfaceMemberDef- Returns:
- the value of the
declaringClassrecord component
-
superArguments
Returns the value of thesuperArgumentsrecord component.- Returns:
- the value of the
superArgumentsrecord component
-
isGenerator
public boolean isGenerator()Returns the value of theisGeneratorrecord component.- Returns:
- the value of the
isGeneratorrecord component
-