I'm trying to get the Declaration of methods using AST, so I can traverse it, looking for certain statements. It worked before, but I can't get it to work anymore, the Declaration I'm getting looks to me like there's some kind of parsing error. I cannot find information on how to fix this:
{<|java+method:///MetricsTest/testMethod()|,compilationUnit([],[],src=|java+method:///MetricsTest/testMethod()|(0,30,<1,0>,<2,2>),decl=|java+compilationUnit:///MetricsTest/testMethod()|,messages=[error("Syntax error on token \"void\", @ expected",|java+method:///MetricsTest/testMethod()|(7,4,<1,0>,<1,0>)),error("Syntax error, insert \"enum Identifier\" to complete EnumHeader",|java+method:///MetricsTest/testMethod()|(23,1,<1,0>,<1,0>))])>}
My (partial) code is as follows:
public rel[loc, loc] getMethods(M3 model) {
return { <x,y> | <x,y> <- model.containment
, x.scheme=="java+class"
, y.scheme=="java+method" || y.scheme=="java+constructor"
};
}
public rel[loc, Declaration] getMethodLocWithDeclaration(M3 model) {
rel[loc, loc] methods = getMethods(model);
rel[loc, Declaration] methodsWithAST = {};
for(<loc c, loc m> <- methods) {
methodsWithAST += <m, createAstFromFile(m, false)>;
}
return methodsWithAST;
}
Does anyone have a clue on how I can fix this?