-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from codefuse-ai/lhk_dev
[doc] Fix logic of `UnusedMethod.gdl` & Add example file `CallChain.gdl`
- Loading branch information
Showing
3 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// script | ||
use coref::java::* | ||
|
||
pub fn default_java_db() -> JavaDB { | ||
return JavaDB::load("coref_java_src.db") | ||
} | ||
|
||
pub fn specified_callable_signature(name: string) -> bool { | ||
// give specified callables' signatures here | ||
[ | ||
{"com.alipay.demo.Main.test:void()"}, | ||
{"xxx"}, | ||
{"xxx"} | ||
] | ||
} | ||
|
||
schema SpecifiedCallable extends Callable {} | ||
|
||
impl SpecifiedCallable { | ||
@data_constraint | ||
pub fn __all__(db: JavaDB) -> *Self { | ||
for(c in Callable(db)) { | ||
if (specified_callable_signature(c.getSignature())) { | ||
yield SpecifiedCallable { id: c.id } | ||
} | ||
} | ||
} | ||
} | ||
|
||
pub fn getIndirectEdges(b: Callable, c: Callable) -> bool { | ||
for(a in SpecifiedCallable(default_java_db())) { | ||
if (b in a.getAnAncestorCallee() && c in b.getCallee()) { | ||
return true | ||
} | ||
} | ||
} | ||
|
||
pub fn getDirectEdges(b: Callable, c: Callable) -> bool { | ||
for(a in SpecifiedCallable(default_java_db())) { | ||
if (c in a.getCallee() && b.key_eq(a)) { | ||
return true | ||
} | ||
} | ||
} | ||
|
||
pub fn output_signature(caller: string, callee: string) -> bool { | ||
for(b in Callable(default_java_db()), c in Callable(default_java_db())) { | ||
if (getIndirectEdges(b, c) || getDirectEdges(b, c)) { | ||
return caller = b.getSignature() && callee = c.getSignature() | ||
} | ||
} | ||
} | ||
|
||
pub fn main() { | ||
output(output_signature()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters