codegraph_parser_api/entities/
module.rs

1use serde::{Deserialize, Serialize};
2
3/// Represents a file/module
4#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
5pub struct ModuleEntity {
6    /// Module name (usually filename without extension)
7    pub name: String,
8
9    /// Full path to the file
10    pub path: String,
11
12    /// Language identifier
13    pub language: String,
14
15    /// Number of lines
16    pub line_count: usize,
17
18    /// Documentation/module docstring
19    pub doc_comment: Option<String>,
20
21    /// Module-level attributes/pragmas
22    pub attributes: Vec<String>,
23}
24
25impl ModuleEntity {
26    pub fn new(
27        name: impl Into<String>,
28        path: impl Into<String>,
29        language: impl Into<String>,
30    ) -> Self {
31        Self {
32            name: name.into(),
33            path: path.into(),
34            language: language.into(),
35            line_count: 0,
36            doc_comment: None,
37            attributes: Vec::new(),
38        }
39    }
40
41    pub fn with_line_count(mut self, count: usize) -> Self {
42        self.line_count = count;
43        self
44    }
45
46    pub fn with_doc(mut self, doc: impl Into<String>) -> Self {
47        self.doc_comment = Some(doc.into());
48        self
49    }
50
51    pub fn with_attributes(mut self, attrs: Vec<String>) -> Self {
52        self.attributes = attrs;
53        self
54    }
55}