pub struct FunctionEntity {
pub name: String,
pub signature: String,
pub visibility: String,
pub line_start: usize,
pub line_end: usize,
pub is_async: bool,
pub is_test: bool,
pub parameters: Vec<Parameter>,
pub return_type: Option<String>,
pub doc_comment: Option<String>,
pub parent: Option<String>,
pub attributes: Vec<String>,
}Expand description
Represents a function or method in Python source code
Fields§
§name: StringFunction name
signature: StringFull signature (including parameters and return type)
visibility: StringVisibility: “public” (no underscore) or “private” (starts with _)
line_start: usizeStarting line number (1-indexed)
line_end: usizeEnding line number (1-indexed)
is_async: boolIs this an async def function?
is_test: boolIs this a test function? (name starts with “test_” or “Test”)
parameters: Vec<Parameter>Function parameters
return_type: Option<String>Return type annotation (if present)
doc_comment: Option<String>Documentation string (docstring)
parent: Option<String>Parent class name (for methods)
attributes: Vec<String>Decorators applied to the function (e.g., [“@staticmethod”, “@cache”])
Implementations§
Source§impl FunctionEntity
impl FunctionEntity
Sourcepub fn new(name: impl Into<String>, line_start: usize, line_end: usize) -> Self
pub fn new(name: impl Into<String>, line_start: usize, line_end: usize) -> Self
Create a new function entity with required fields
Sourcepub fn is_classmethod(&self) -> bool
pub fn is_classmethod(&self) -> bool
Check if this is a class method
Sourcepub fn is_property(&self) -> bool
pub fn is_property(&self) -> bool
Check if this is a property
Sourcepub fn set_return_type(self, return_type: Option<String>) -> Self
pub fn set_return_type(self, return_type: Option<String>) -> Self
Set the return type
Sourcepub fn set_doc_comment(self, doc: Option<String>) -> Self
pub fn set_doc_comment(self, doc: Option<String>) -> Self
Set the docstring
Sourcepub fn set_parent(self, parent: Option<String>) -> Self
pub fn set_parent(self, parent: Option<String>) -> Self
Set the parent class (for methods)
Sourcepub fn add_attribute(self, attr: impl Into<String>) -> Self
pub fn add_attribute(self, attr: impl Into<String>) -> Self
Add a decorator
Sourcepub fn add_parameter(self, param: Parameter) -> Self
pub fn add_parameter(self, param: Parameter) -> Self
Add a parameter
Sourcepub fn set_signature(self, sig: impl Into<String>) -> Self
pub fn set_signature(self, sig: impl Into<String>) -> Self
Set the signature
Trait Implementations§
Source§impl Clone for FunctionEntity
impl Clone for FunctionEntity
Source§fn clone(&self) -> FunctionEntity
fn clone(&self) -> FunctionEntity
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FunctionEntity
impl Debug for FunctionEntity
Source§impl<'de> Deserialize<'de> for FunctionEntity
impl<'de> Deserialize<'de> for FunctionEntity
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for FunctionEntity
impl PartialEq for FunctionEntity
Source§impl Serialize for FunctionEntity
impl Serialize for FunctionEntity
impl StructuralPartialEq for FunctionEntity
Auto Trait Implementations§
impl Freeze for FunctionEntity
impl RefUnwindSafe for FunctionEntity
impl Send for FunctionEntity
impl Sync for FunctionEntity
impl Unpin for FunctionEntity
impl UnwindSafe for FunctionEntity
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more