-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-uses.awk
46 lines (38 loc) · 938 Bytes
/
get-uses.awk
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
/^\/.*.php$/ {
depCnt = 0
namespace = ""
}
/^use/ { sub(/;$/, ""); deps[depCnt++] = $2};
/^namespace/ { sub(/;$/, ""); namespace = $2 }
match($0, /^#\[Package\(['"].+['"]\)/) {
line = $0;
sub(/#\[Package\(["']/, "", line);
sub(/['"]\).*$/, "", line);
package = line;
}
/^final class/ { classname = $3;}
/^abstract class/ { classname = $3 }
/^class/ { classname = $2 }
/^interface/ { classname = $2 }
/^trait/ { classname = $2 }
length(classname) > 0 {
gsub(/[;{}]/, "", classname);
fqn = namespace "\\" classname;
units[unitCnt++] = fqn;
line = fqn ", " package;
if (depCnt > 0) {
line = line ", ";
}
for (i = 0; i < depCnt; i++) {
line = line ", " deps[i]
}
print line;
depCnt = 0;
classname = "";
}
END {
print "known units: " unitCnt > "/dev/stderr";
for (i = 0; i < unitCnt; i++) {
print units[i] > "/dev/stderr";
}
}