pub struct ClassEntity {
pub name: String,
pub visibility: String,
pub line_start: usize,
pub line_end: usize,
pub is_abstract: bool,
pub base_classes: Vec<String>,
pub implemented_traits: Vec<String>,
pub methods: Vec<FunctionEntity>,
pub fields: Vec<Field>,
pub doc_comment: Option<String>,
pub attributes: Vec<String>,
}Expand description
Represents a Python class
Fields§
§name: StringClass name
visibility: StringVisibility: “public” or “private”
line_start: usizeStarting line number (1-indexed)
line_end: usizeEnding line number (1-indexed)
is_abstract: boolIs this an abstract class (has ABCMeta or ABC base)?
base_classes: Vec<String>Inherited classes (base classes)
implemented_traits: Vec<String>Protocols/traits implemented
methods: Vec<FunctionEntity>Methods in this class (full FunctionEntity objects)
fields: Vec<Field>Class attributes/fields
doc_comment: Option<String>Documentation string (docstring)
attributes: Vec<String>Decorators applied to the class (e.g., [“@dataclass”])
Implementations§
Source§impl ClassEntity
impl ClassEntity
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 class entity with required fields
Sourcepub fn is_dataclass(&self) -> bool
pub fn is_dataclass(&self) -> bool
Check if this is a dataclass
Sourcepub fn is_abstract(&self) -> bool
pub fn is_abstract(&self) -> bool
Check if this is abstract
Sourcepub fn has_method(&self, method_name: &str) -> bool
pub fn has_method(&self, method_name: &str) -> bool
Check if a method exists
Sourcepub fn set_abstract(self, is_abstract: bool) -> Self
pub fn set_abstract(self, is_abstract: bool) -> Self
Set abstract flag
Sourcepub fn add_base_class(self, base: impl Into<String>) -> Self
pub fn add_base_class(self, base: impl Into<String>) -> Self
Add a base class
Sourcepub fn add_trait(self, trait_name: impl Into<String>) -> Self
pub fn add_trait(self, trait_name: impl Into<String>) -> Self
Add an implemented trait/protocol
Sourcepub fn add_method(self, method: FunctionEntity) -> Self
pub fn add_method(self, method: FunctionEntity) -> Self
Add a method
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 add_attribute(self, attr: impl Into<String>) -> Self
pub fn add_attribute(self, attr: impl Into<String>) -> Self
Add a decorator
Trait Implementations§
Source§impl Clone for ClassEntity
impl Clone for ClassEntity
Source§fn clone(&self) -> ClassEntity
fn clone(&self) -> ClassEntity
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 ClassEntity
impl Debug for ClassEntity
Source§impl<'de> Deserialize<'de> for ClassEntity
impl<'de> Deserialize<'de> for ClassEntity
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 ClassEntity
impl PartialEq for ClassEntity
Source§impl Serialize for ClassEntity
impl Serialize for ClassEntity
impl StructuralPartialEq for ClassEntity
Auto Trait Implementations§
impl Freeze for ClassEntity
impl RefUnwindSafe for ClassEntity
impl Send for ClassEntity
impl Sync for ClassEntity
impl Unpin for ClassEntity
impl UnwindSafe for ClassEntity
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