hi,
I want to count the number of inherited methods per project and number of total methods per project. I have written this script, but there are errors, kindly see if i have misused any of the language construct or something
Regards Nawaz
p: Project = input;
MIF: output collection[string][int][int] of int;
TPP := 0;
IMPP := 0;
getTotalMPP:= function():int{
count := 0;
visitor(p,visitor{
before node: Declaration ->{
if(node.kind == TypeKind.CLASS){
count = len(node.Methods);
}
}
}); # end of visitor
return count;
};
visit(p, visitor {
before node: CodeRepository -> {
snapshot := getsnapshot(node,"SOURCE_JAVA_JLS");
foreach (i: int; def(snapshot[i]))
visit(snapshot[i]);
# getTotal Methods for the Project
TPP := getTotalMPP();
res += IMPP/TMPP;
MIF[
p.id][temp][IMPP] << res;
stop;
}
before node: Declaration ->{
if(node.kind == TypeKind.CLASS){
foreach(i:int; def(node.parents[i])){
if(node.parents[i].kind == TypeKind.CLASS){
foreach(j: int; (has_modifier_public(node.parents[i].methods[j]) || has_modifier_protected(node.parents[i].methods[j])){
IMPP++;
}
}
}
stop;
}
});