@@ -62,6 +62,9 @@ lazy_static! {
62
62
static ref RUST_TYPE : Regex = Regex :: new(
63
63
r"/\^([ ]*)([A-Za-z0-9_.]+)(\t|\s)([A-Za-z0-9_.]+)\s*:(\t|\s)*(?P<datatype>[A-Za-z0-9_.<>]+)"
64
64
) . unwrap( ) ;
65
+ static ref PURE_RUST_TYPE : Regex = Regex :: new(
66
+ r"((Vec|Option|<)*)(?P<datatype>[A-Za-z0-9_]+)>*"
67
+ ) . unwrap( ) ;
65
68
static ref GO_TYPE : Regex =
66
69
Regex :: new( r"(?x)/\^([\s]*)
67
70
([A-Za-z0-9_.]+)
@@ -183,6 +186,7 @@ impl CtagsParser {
183
186
clazz. lang = language. to_string ( ) ;
184
187
185
188
let mut data_type = "" . to_string ( ) ;
189
+ let mut pure_data_type = "" . to_string ( ) ;
186
190
match language {
187
191
"Java" | "C#" | "C++" => {
188
192
let without_keywords = CtagsParser :: remove_keywords ( line. to_string ( ) ) ;
@@ -193,6 +197,10 @@ impl CtagsParser {
193
197
"Rust" => {
194
198
if let Some ( capts) = RUST_TYPE . captures ( line) {
195
199
data_type = ( & capts[ "datatype" ] ) . to_string ( ) ;
200
+
201
+ if let Some ( ty) = PURE_RUST_TYPE . captures ( data_type. as_str ( ) ) {
202
+ pure_data_type = ( & ty[ "datatype" ] ) . to_string ( ) ;
203
+ }
196
204
}
197
205
}
198
206
"Go" => {
@@ -204,10 +212,16 @@ impl CtagsParser {
204
212
}
205
213
206
214
if tag_type. eq ( "member" ) || tag_type. eq ( "field" ) {
207
- let member = MemberInfo :: new ( name, access, data_type) ;
215
+ let mut member = MemberInfo :: new ( name, access, data_type) ;
216
+ if !pure_data_type. is_empty ( ) {
217
+ member. pure_data_type = pure_data_type;
218
+ }
208
219
clazz. members . push ( member) ;
209
220
} else if tag_type. eq ( "method" ) || tag_type. eq ( "function" ) {
210
- let method = MethodInfo :: new ( name, access, data_type) ;
221
+ let mut method = MethodInfo :: new ( name, access, data_type) ;
222
+ if !pure_data_type. is_empty ( ) {
223
+ method. pure_return_type = pure_data_type;
224
+ }
211
225
clazz. methods . push ( method) ;
212
226
}
213
227
}
@@ -365,6 +379,7 @@ name src/coco_struct.rs /^ pub name: String,$/;\" field line:22 language:Rust
365
379
assert_eq ! ( 7 , classes[ 0 ] . members. len( ) ) ;
366
380
assert_eq ! ( "file" , classes[ 0 ] . members[ 0 ] . name) ;
367
381
assert_eq ! ( "parents" , classes[ 0 ] . members[ 6 ] . name) ;
382
+ assert_eq ! ( "String" , classes[ 0 ] . members[ 6 ] . pure_data_type) ;
368
383
}
369
384
370
385
#[ test]
0 commit comments