pub struct FunctionEntity {Show 15 fields
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 is_static: bool,
pub is_abstract: bool,
pub parameters: Vec<Parameter>,
pub return_type: Option<String>,
pub doc_comment: Option<String>,
pub attributes: Vec<String>,
pub parent_class: Option<String>,
pub complexity: Option<ComplexityMetrics>,
}Expand description
Represents a function/method in any language
Fields§
§name: StringFunction name
signature: StringFull signature (including parameters and return type)
visibility: StringVisibility: “public”, “private”, “protected”, “internal”
line_start: usizeStarting line number (1-indexed)
line_end: usizeEnding line number (1-indexed)
is_async: boolIs this an async/coroutine function?
is_test: boolIs this a test function?
is_static: boolIs this a static method?
is_abstract: boolIs this an abstract method?
parameters: Vec<Parameter>Function parameters
return_type: Option<String>Return type annotation (if available)
doc_comment: Option<String>Documentation/docstring
attributes: Vec<String>Decorators/attributes (e.g., @property, @deprecated)
parent_class: Option<String>Parent class (if this is a method)
complexity: Option<ComplexityMetrics>Complexity metrics for this function
Implementations§
Source§impl FunctionEntity
impl FunctionEntity
pub fn new(name: impl Into<String>, line_start: usize, line_end: usize) -> Self
pub fn with_signature(self, sig: impl Into<String>) -> Self
pub fn with_visibility(self, vis: impl Into<String>) -> Self
pub fn async_fn(self) -> Self
pub fn test_fn(self) -> Self
pub fn static_fn(self) -> Self
pub fn abstract_fn(self) -> Self
pub fn with_parameters(self, params: Vec<Parameter>) -> Self
pub fn with_return_type(self, ret: impl Into<String>) -> Self
pub fn with_doc(self, doc: impl Into<String>) -> Self
pub fn with_attributes(self, attrs: Vec<String>) -> Self
pub fn with_parent_class(self, parent: impl Into<String>) -> Self
pub fn with_complexity(self, metrics: ComplexityMetrics) -> Self
Sourcepub fn cyclomatic_complexity(&self) -> u32
pub fn cyclomatic_complexity(&self) -> u32
Get the cyclomatic complexity, returning 1 if not calculated
Sourcepub fn complexity_grade(&self) -> char
pub fn complexity_grade(&self) -> char
Get the complexity grade (A-F), returning ‘A’ if not calculated
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§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§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)