1
1
#![ warn( clippy:: pedantic) ]
2
2
use crate :: errors:: SDKErr ;
3
+ use macro_lib:: ast_node;
3
4
use std:: collections:: HashMap ;
4
5
5
6
fn parse_file ( file_name : & str , content : & mut str ) -> Result < syn:: File , SDKErr > {
@@ -15,6 +16,8 @@ pub struct Codebase {
15
16
ast_map : HashMap < String , syn:: File > ,
16
17
free_functions : Vec < Function > ,
17
18
contracts : Vec < Contract > ,
19
+ structs : Vec < Struct > ,
20
+ enums : Vec < Enum > ,
18
21
}
19
22
20
23
impl Codebase {
@@ -23,6 +26,8 @@ impl Codebase {
23
26
ast_map : HashMap :: new ( ) ,
24
27
free_functions : Vec :: new ( ) ,
25
28
contracts : Vec :: new ( ) ,
29
+ structs : Vec :: new ( ) ,
30
+ enums : Vec :: new ( ) ,
26
31
}
27
32
}
28
33
@@ -52,6 +57,7 @@ impl Codebase {
52
57
}
53
58
}
54
59
60
+ #[ ast_node]
55
61
#[ derive( Clone ) ]
56
62
pub struct Contract {
57
63
name : String ,
@@ -61,39 +67,61 @@ pub struct Contract {
61
67
}
62
68
63
69
impl Contract {
64
- pub fn new ( name : & str ) -> Self {
70
+ pub fn new ( name : & str , start_line : u32 , start_col : u32 , end_line : u32 , end_col : u32 ) -> Self {
65
71
Contract {
66
72
name : name. to_string ( ) ,
67
73
functions : Vec :: new ( ) ,
68
74
structs : Vec :: new ( ) ,
69
75
enums : Vec :: new ( ) ,
76
+ start_line,
77
+ start_col,
78
+ end_line,
79
+ end_col,
70
80
}
71
81
}
72
82
}
73
83
84
+ #[ ast_node]
74
85
#[ derive( Clone ) ]
75
86
pub struct Function { }
76
87
77
88
impl Function {
78
- pub fn new ( ) -> Self {
79
- Function { }
89
+ pub fn new ( start_line : u32 , start_col : u32 , end_line : u32 , end_col : u32 ) -> Self {
90
+ Function {
91
+ start_line,
92
+ start_col,
93
+ end_line,
94
+ end_col,
95
+ }
80
96
}
81
97
}
82
98
99
+ #[ ast_node]
83
100
#[ derive( Clone ) ]
84
101
pub struct Struct { }
85
102
86
103
impl Struct {
87
- pub fn new ( ) -> Self {
88
- Struct { }
104
+ pub fn new ( start_line : u32 , start_col : u32 , end_line : u32 , end_col : u32 ) -> Self {
105
+ Struct {
106
+ start_line,
107
+ start_col,
108
+ end_line,
109
+ end_col,
110
+ }
89
111
}
90
112
}
91
113
114
+ #[ ast_node]
92
115
#[ derive( Clone ) ]
93
116
pub struct Enum { }
94
117
95
118
impl Enum {
96
- pub fn new ( ) -> Self {
97
- Enum { }
119
+ pub fn new ( start_line : u32 , start_col : u32 , end_line : u32 , end_col : u32 ) -> Self {
120
+ Enum {
121
+ start_line,
122
+ start_col,
123
+ end_line,
124
+ end_col,
125
+ }
98
126
}
99
127
}
0 commit comments