1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
pub mod model {
    //! Module that contains all necessary data stuctures for parsing javadocs and generating docs
    #[derive(Debug)]
    /// Struct representing method parameter data contained in javadoc and method declaration
    pub struct Param {
        pub desc: String,
        pub name: String,
        pub var_type: String,
    }

    /// Struct representing all the project data
    pub struct Project {
        pub classes: Vec<Class>,
        pub interfaces: Vec<Interface>,
    }

    #[derive(Debug)]
    /// Struct representing method parameter data contained in javadoc and method declaration
    pub struct Exception {
        pub exception_type: String,
        pub desc: String,
    }

    /// Struct representing data contained in javadoc comments
    pub struct Doc {
        pub params: Vec<Param>,
        pub description: String,
        pub author: String,
        pub version: String,
        pub exception: Exception,
        pub deprecated: String,
        pub return_desc: String,
    }

    #[derive(Debug)]
    /// Struct containing method data from the javadoc and method declaration
    pub struct Method {
        pub line_num: String,
        pub parameters: Vec<Param>,
        pub is_static: bool,
        pub name: String,
        pub static_meth: bool,
        pub privacy: String,
        pub description: String,
        pub exception: Exception,
        pub return_type: String,
    }

    #[derive(Debug)]
    /// Struct containing class documentation information
    /// Includes package name, imports, methods, and other data
    pub struct Class {
        pub is_class: bool,
        pub file_path: String,
        pub package_name: String,
        pub deprecation: String,
        pub license: String,
        pub parent: String,
        pub access: String,
        pub version: String,
        pub author: String,
        pub class_name: String,
        pub description: String,
        pub exception: Exception,
        pub interfaces: Vec<String>,
        pub dependencies: Vec<String>,
        pub methods: Vec<Method>,
    }

    #[derive(Debug)]
    /// Struct containing interface documentation information
    /// Includes package name, imports, method templates, and other data
    pub struct Interface {
        pub package_name: String,
        pub deprecation: String,
        pub access: String,
        pub file_path: String,
        pub version: String,
        pub author: String,
        pub name: String,
        pub description: String,
        pub dependencies: Vec<String>,
        pub methods: Vec<Method>,
    }

    /// Struct that represents the parsing state
    pub struct ParseState {
        pub class: bool,
        pub interface: bool,
        pub method: bool,
        pub doc: bool,
        pub comment: bool,
        pub doc_ready: bool,
        pub block_depth: i32,
    }

    impl Exception {
        pub fn new() -> Exception {
            Exception {
                exception_type: String::new(),
                desc: String::new(),
            }
        }
        pub fn is_empty(&self) -> bool {
            if self.exception_type != "" && self.desc != "" {
                false
            } else {
                true
            }
        }
        pub fn clone(&self) -> Exception {
            Exception {
                exception_type: self.exception_type.clone(),
                desc: self.desc.clone(),
            }
        }
    }

    impl Class {
        pub fn new() -> Class {
            Class {
                is_class: true,
                package_name: String::new(),
                file_path: String::new(),
                dependencies: Vec::new(),
                deprecation: String::new(),
                license: String::new(),
                parent: String::new(),
                interfaces: Vec::new(),
                access: String::new(),
                version: String::new(),
                author: String::new(),
                class_name: String::new(),
                exception: Exception::new(),
                description: String::new(),
                methods: Vec::new(),
            }
        }
        pub fn clone(&mut self) -> Class {
            let mut new_methods = Vec::new();

            for i in 0..self.methods.len() {
                new_methods.push(self.methods[i].clone());
            }

            Class {
                is_class: self.is_class.clone(),
                parent: self.parent.clone(),
                file_path: self.file_path.clone(),
                package_name: self.package_name.clone(),
                license: self.license.clone(),
                dependencies: self.dependencies.clone(),
                deprecation: self.deprecation.clone(),
                access: self.access.clone(),
                version: self.version.clone(),
                author: self.author.clone(),
                class_name: self.class_name.clone(),
                description: self.description.clone(),
                exception: self.exception.clone(),
                interfaces: self.interfaces.clone(),
                methods: new_methods,
            }
        }
        pub fn to_interface(&mut self) -> Interface {
            let mut new_methods = Vec::new();

            for i in 0..self.methods.len() {
                new_methods.push(self.methods[i].clone());
            }

            Interface {
                package_name: self.package_name.clone(),
                dependencies: self.dependencies.clone(),
                deprecation: self.deprecation.clone(),
                access: self.access.clone(),
                file_path: self.file_path.clone(),
                version: self.version.clone(),
                author: self.author.clone(),
                name: self.class_name.clone(),
                description: self.description.clone(),
                methods: new_methods,
            }
        }
        pub fn ch_access(&mut self, value: String) {
            self.access = value;
        }
        pub fn ch_license(&mut self, value: String) {
            self.file_path = value;
        }
        pub fn ch_file_path(&mut self, value: String) {
            self.file_path = value;
        }
        pub fn ch_is_class(&mut self, value: bool) {
            self.is_class = value;
        }
        pub fn ch_package_name(&mut self, value: String) {
            self.package_name = value;
        }
        pub fn ch_class_name(&mut self, value: String) {
            self.class_name = value;
        }
        pub fn ch_description(&mut self, value: String) {
            self.description = value;
        }
        pub fn ch_deprecation(&mut self, value: String) {
            self.deprecation = value;
        }
        pub fn ch_parent(&mut self, value: String) {
            self.parent = value;
        }
        pub fn ch_version(&mut self, value: String) {
            self.deprecation = value;
        }
        pub fn ch_author(&mut self, value: String) {
            self.author = value;
        }
        pub fn add_method(&mut self, value: Method) {
            self.methods.push(value);
        }
        pub fn add_dependency(&mut self, value: String) {
            self.dependencies.push(value);
        }
        pub fn add_interface(&mut self, value: String) {
            self.interfaces.push(value);
        }
        pub fn ch_exception(&mut self, value: Exception) {
            self.exception = value;
        }
    }

    impl Interface {
        pub fn new() -> Interface {
            Interface {
                package_name: String::new(),
                dependencies: Vec::new(),
                deprecation: String::new(),
                access: String::new(),
                file_path: String::new(),
                version: String::new(),
                author: String::new(),
                name: String::new(),
                description: String::new(),
                methods: Vec::new(),
            }
        }
        pub fn clone(&mut self) -> Interface {
            let mut new_methods = Vec::new();

            for i in 0..self.methods.len() {
                new_methods.push(self.methods[i].clone());
            }

            Interface {
                package_name: self.package_name.clone(),
                dependencies: self.dependencies.clone(),
                deprecation: self.deprecation.clone(),
                access: self.access.clone(),
                file_path: self.access.clone(),
                version: self.version.clone(),
                author: self.author.clone(),
                name: self.name.clone(),
                description: self.description.clone(),
                methods: new_methods,
            }
        }
        pub fn ch_access(&mut self, value: String) {
            self.access = value;
        }
        pub fn ch_file_path(&mut self, value: String) {
            self.file_path = value;
        }
        pub fn ch_package_name(&mut self, value: String) {
            self.package_name = value;
        }
        pub fn ch_inter_name(&mut self, value: String) {
            self.name = value;
        }
        pub fn ch_description(&mut self, value: String) {
            self.description = value;
        }
        pub fn ch_deprecation(&mut self, value: String) {
            self.deprecation = value;
        }
        pub fn ch_version(&mut self, value: String) {
            self.deprecation = value;
        }
        pub fn ch_author(&mut self, value: String) {
            self.author = value;
        }
        pub fn add_method(&mut self, value: Method) {
            self.methods.push(value);
        }
        pub fn add_dependency(&mut self, value: String) {
            self.dependencies.push(value);
        }
    }

    impl Method {
        pub fn new() -> Method {
            Method {
                parameters: Vec::new(),
                is_static: false,
                exception: Exception::new(),
                line_num: String::new(),
                name: String::new(),
                static_meth: false,
                privacy: String::new(),
                description: String::new(),
                return_type: String::new(),
            }
        }
        pub fn clone(&mut self) -> Method {
            let mut new_params = Vec::new();

            for i in 0..self.parameters.len() {
                new_params.push(self.parameters[i].clone());
            }

            Method {
                line_num: self.line_num.clone(),
                parameters: new_params,
                is_static: self.is_static,
                exception: self.exception.clone(),
                name: self.name.clone(),
                static_meth: self.static_meth.clone(),
                privacy: self.privacy.clone(),
                description: self.description.clone(),
                return_type: self.return_type.clone(),
            }
        }
        pub fn ch_line_num(&mut self, value: String) {
            self.line_num = value;
        }
        pub fn ch_privacy(&mut self, value: String) {
            self.privacy = value;
        }
        pub fn ch_is_static(&mut self, value: bool) {
            self.is_static = value;
        }
        pub fn ch_method_name(&mut self, value: String) {
            self.name = value;
        }
        pub fn ch_description(&mut self, value: String) {
            self.description = value;
        }
        pub fn ch_exception(&mut self, value: Exception) {
            self.exception = value;
        }
        pub fn add_param(&mut self, value: Param) {
            self.parameters.push(value);
        }
        pub fn ch_params(&mut self, value: Vec<Param>) {
            self.parameters = value;
        }
        pub fn ch_return_type(&mut self, value: String) {
            self.return_type = value;
        }
    }

    impl ParseState {
        pub fn new() -> ParseState {
            ParseState {
                class: false,
                interface: false,
                method: false,
                doc: false,
                comment: false,
                doc_ready: false,
                block_depth: 0,
            }
        }
        pub fn ch_class(&mut self, value: bool) {
            self.class = value;
        }
        pub fn ch_doc(&mut self, value: bool) {
            self.doc = value;
        }
        pub fn ch_doc_ready(&mut self, value: bool) {
            self.doc_ready = value;
        }
    }

    impl Param {
        pub fn clone(&mut self) -> Param {
            let new_desc = self.desc.clone();
            let new_name = self.name.clone();
            let new_type = self.var_type.clone();

            Param {
                desc: new_desc,
                name: new_name,
                var_type: new_type,
            }
        }
        pub fn ch_desc(&mut self, value: String) {
            self.desc = value;
        }
    }

    impl Doc {
        pub fn new() -> Doc {
            Doc {
                params: Vec::new(),
                description: String::new(),
                return_desc: String::new(),
                author: String::new(),
                version: String::new(),
                exception: Exception::new(),
                deprecated: String::new(),
            }
        }
        pub fn clear(&mut self) {
            self.params = Vec::new();
            self.description = String::new();
            self.return_desc = String::new();
            self.author = String::new();
            self.version = String::new();
            self.exception = Exception::new();
            self.deprecated = String::new();
        }
    }

    impl Project {
        pub fn new() -> Project {
            Project {
                classes: Vec::new(),
                interfaces: Vec::new(),
            }
        }
        pub fn add_class(&mut self, value: Class) {
            self.classes.push(value);
        }
        pub fn add_interface(&mut self, value: Interface) {
            self.interfaces.push(value);
        }
    }

    /// Enum that is used to determine the line type for each line
    pub enum LineType {
        IsPackage,
        IsImport,
        IsClass,
        IsInterface,
        IsMethod,
        IsComment,
        IsStartdoc,
        IsEnddoc,
        IsOther,
    }
}