a/metric-providers/org.ossmeter.metricprovider.rascal/modules/WMC.rsc b/metric-providers/org.ossmeter.metricprovider.rascal/modules/WMC.rsc
...
...
18
18
19
map[str class, int cc] getCC(M3 fileM3) {
19
map[str class, int cc] getCC(M3 fileM3) {
20
  return (replaceAll(replaceFirst(m.path, "/", ""), "/", ".") : getCC(m, fileM3.ast) | <cl,_> <- fileM3.model@declarations, isClass(cl), m <- fileM3.model@containment[cl], isMethod(m));
20
  return (replaceAll(replaceFirst(m.path, "/", ""), "/", ".") : getCC(m, fileM3.ast) | <cl,_> <- fileM3.model@declarations, isClass(cl), m <- fileM3.model@containment[cl], isMethod(m));
21
}
21
}
22
22
23
Declaration getMethodAST(loc methodLoc, Declaration fileAST) {
23
Declaration getASTOfMethod(loc methodLoc, Declaration fileAST) {
24
  visit(fileAST) {
24
  visit(fileAST) {
25
    case Declaration d: {
25
    case Declaration d: {
26
      if ("decl" in getAnnotations(d) && d@decl == methodLoc) {
26
      if ("decl" in getAnnotations(d) && d@decl == methodLoc) {
27
        return d;
27
        return d;
28
      }
28
      }
...
...
31
  throw "ast not found for method: <methodLoc>";
31
  throw "ast not found for method: <methodLoc>";
32
}
32
}
33
33
34
int getCC(loc m, Declaration ast) {
34
int getCC(loc m, Declaration ast) {
35
  int count = 1;
35
  int count = 1;
36
  Declaration methodAST = getMethodAST(m, ast);
36
  Declaration methodAST = getASTOfMethod(m, ast);
37
  
37
  
38
  visit(methodAST) {
38
  visit(methodAST) {
39
    case Statement s: {
39
    case Statement s: {
40
      count += getPaths(s);
40
      count += getPaths(s);
41
    }
41
    }
...
...
47
int getPaths(\for(list[Expression] initializers, Expression condition, list[Expression] updaters, Statement body))  = 1 + getPaths(condition);
47
int getPaths(\for(list[Expression] initializers, Expression condition, list[Expression] updaters, Statement body))  = 1 + getPaths(condition);
48
int getPaths(\for(list[Expression] initializers, list[Expression] updaters, Statement body)) = 1;
48
int getPaths(\for(list[Expression] initializers, list[Expression] updaters, Statement body)) = 1;
49
int getPaths(\if(Expression condition, Statement thenBranch, Statement elseBranch)) = 1 + getPaths(condition);
49
int getPaths(\if(Expression condition, Statement thenBranch, Statement elseBranch)) = 1 + getPaths(condition);
50
int getPaths(\if(Expression condition, Statement thenBranch)) = 1 + getPaths(condition);
50
int getPaths(\if(Expression condition, Statement thenBranch)) = 1 + getPaths(condition);
51
int getPaths(\case(Expression expression)) = 1 + getPaths(expression);
51
int getPaths(\case(Expression expression)) = 1 + getPaths(expression);
52
int getPaths(\defaultCase()) = 1;
53
int getPaths(\while(Expression condition, Statement body)) = 1 + getPaths(condition);
52
int getPaths(\while(Expression condition, Statement body)) = 1 + getPaths(condition);
54
int getPaths(\do(Statement body, Expression condition)) = 1 + getPaths(condition);
53
int getPaths(\do(Statement body, Expression condition)) = getPaths(condition);
54
int getPaths(\catch(Declaration exception, Statement body)) = 1;
55
default int getPaths(Statement s) = 0;
55
default int getPaths(Statement s) = 0;
56
56
57
int getPaths(\infix(Expression lhs, "||", Expression rhs, list[Expression] extendedOperands)) = 1 + size(extendedOperands);
57
int getPaths(\infix(Expression lhs, "||", Expression rhs, list[Expression] extendedOperands)) = 1 + size(extendedOperands);
58
int getPaths(\infix(Expression lhs, "&&", Expression rhs, list[Expression] extendedOperands)) = 1 + size(extendedOperands);
58
int getPaths(\infix(Expression lhs, "&&", Expression rhs, list[Expression] extendedOperands)) = 1 + size(extendedOperands);
59
default int getPaths(Expression e) = 0;
59
default int getPaths(Expression e) = 0;