Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dd2cfb5

Browse files
add example gdl script for filter path in call chain.
1 parent 0bd81a0 commit dd2cfb5

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// script
2+
use coref::java::*
3+
4+
pub fn default_java_db() -> JavaDB {
5+
return JavaDB::load("coref_java_src.db")
6+
}
7+
8+
//过滤用文件夹名,可修改
9+
pub fn FOLDERNAMES(n: string) -> bool {
10+
[
11+
{"/ibatis/"},
12+
{"/dao/"},
13+
{"/test/"}
14+
]
15+
}
16+
17+
//用文件夹名进行过滤
18+
pub fn filterByFolderNames(d: File) -> bool {
19+
for (m in string::__undetermined_all__(),
20+
n in string::__undetermined_all__()) {
21+
if (n = d.getRelativePath() && FOLDERNAMES(m) && n.contains(m)) {
22+
return true
23+
}
24+
}
25+
}
26+
27+
pub fn getIndirectEdges(b: Callable, c: Callable) -> bool {
28+
if (b in c.getAnAncestorCaller()) {
29+
return true
30+
}
31+
}
32+
33+
pub fn getDirectEdges(b: Callable, c: Callable) -> bool {
34+
if (c in b.getCallee()) {
35+
return true
36+
}
37+
}
38+
39+
// 基于路径过滤的调用关系输出
40+
pub fn output_signature(caller: string, callee: string) -> bool {
41+
for(b in Callable(default_java_db()), c in Callable(default_java_db())) {
42+
let (b_file = b.getLocation().getFile(), c_file = c.getLocation().getFile()) {
43+
if (!filterByFolderNames(b_file) && !filterByFolderNames(c_file)) {
44+
if (getIndirectEdges(b, c) || getDirectEdges(b, c)) {
45+
return caller = b.getSignature() && callee = c.getSignature()
46+
}
47+
}
48+
}
49+
}
50+
}
51+
52+
pub fn main() {
53+
// 输出按路径过滤后的调用链
54+
output(output_signature())
55+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /