-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextractor.js
More file actions
41 lines (35 loc) · 1.23 KB
/
extractor.js
File metadata and controls
41 lines (35 loc) · 1.23 KB
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
class Extractor {
constructor(){
}
extraer_clase_nombre(text){
const match = text.match(/public class [A-Za-z0-9]*\s*{/)[0]
return match.split(/class /)[1].split(/ {/)[0]
}
extraer_propiedades(text){
const regex = /(public|private) [A-Z]?[a-z]* [a-zA-Z0-9]*;/g;
const lista = text.matchAll(regex);
let listareturn = []
for (let item of lista){
listareturn.push({
nombre: item[0].split(" ")[2].split(";")[0],
label: item[0].split(" ")[2].split(";")[0].replace(/([A-Z])/g, ' $1').trim(),
tipo: item[0].split(" ")[1]
})
}
return listareturn
}
extraer_getters(text){
const regex = /public [A-Z]*[a-z]* get([A-Z][a-z]*)+\(\)/g
const lista = text.matchAll(regex);
let listareturn = []
for (let item of lista){
listareturn.push({
nombre: item[0].split(" ")[2].split("()")[0].split("get")[1],
label: item[0].split(" ")[2].split("()")[0].split("get")[1].replace(/([A-Z])/g, ' $1').trim(),
tipo: item[0].split(" ")[1]
})
}
return listareturn
}
}
module.exports = Extractor