For my research I am trying to find user defined exception classes including the file name containing those classes:
Please see the following code:
p: Project = input;
myout: output collection [string][string][string] of int;
file_name: string;
code_repo: string;
class_name:string;
visit(p, visitor {
before node: CodeRepository -> {
code_repo = node.url;
snapshot := getsnapshot(node, "SOURCE_JAVA_JLS");
foreach (i: int; def(snapshot[i])){
file_name = snapshot[i].name;
visit(snapshot[i]);
}
}
before n: Declaration ->{
#I am looking those classes that are extend from Exception class
if(n.kind == TypeKind.CLASS && def(n.parents) && len(n.parents) > 0 && match(`Exception`, n.parents[0].name)) {
myout[code_repo][file_name][
n.name] << 1;
}
}
});