-
Notifications
You must be signed in to change notification settings - Fork 1
/
testParser.js
47 lines (34 loc) · 1.77 KB
/
testParser.js
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
const {AnnotationParser} = require("nodeannotations");
try {
let annotatedElements = AnnotationParser.parse(__dirname+"/annotatedFile.js", __dirname+"/myannotations/");
console.log("Example to Loop through all the annotated Elements :");
// Loop through all elements (Class, Method, Variable) that are annotated
annotatedElements.forEach((annotatedElement) => {
console.log("\t"+annotatedElement.getName()+" : "+annotatedElement.getType());
// Loop and Print All annotations of the current Element
annotatedElement.getAnnotations().forEach((annotation) => {
console.log("\t\t"+JSON.stringify(annotation));
});
console.log();
});
console.log("\n\nExample to Loop through the elements which are annotated with @Path() :");
// Loop through the elements which are annotated with @Request()
annotatedElements.filterBy("Request").forEach((annotatedElement) => {
console.log("\t"+annotatedElement.getName()+" : "+annotatedElement.getType());
// Loop and Print All annotations of the current Element
annotatedElement.getAnnotations().forEach((annotation) => {
console.log("\t\t"+JSON.stringify(annotation));
});
console.log();
});
console.log("\n\nExample to Loop through the elements which are annotated with @Path():");
// Loop through the elements which are annotated with @Path()
annotatedElements.filterBy("Path").forEach((annotatedElement) => {
console.log("\t"+annotatedElement.getName()+" : "+annotatedElement.getType());
// Loop and Print the "dir" value of the @Path annotation
console.log("\t\tdir: "+annotatedElement.getAnnotation("Path").dir);
console.log();
});
} catch (err) {
console.log(err);
}