2

I'm facing a problem when trying to solve a method call expression which reference a declaration in a enum statement. Following, I leave a detail of my code.

 public enum EscapeMode {
  ... some code ...

  EscapeMode(String file, int size) {
      load(this, file, size);
  }

  ... some code ...

}

My VoidVisitorAdapter class I've implemented to look for MCEs.

public class MethodCallResolver extends VoidVisitorAdapter<Object>{

public void visit(MethodCallExpr mce, Object arg) {
super.visit(mce, arg);  
try {
JavaParserFacade jpf = JavaParserFacade.get((CombinedTypeSolver) arg);
    SymbolReference<ResolvedMethodDeclaration> reference = jpf.solve(mce);

    if (reference.isSolved()) {
        ResolvedMethodDeclaration md = reference.getCorrespondingDeclaration();
        System.out.println("\t Solved : " + md.getQualifiedSignature());

        solved++;
    }else {
        System.out.println("\t Not solved. Method Call: " + mce + ", line: " + mce.getBegin().get().line);

        unsolved++;
    }

}catch(UnsolvedSymbolException e) {
    System.err.println("\t Error. Method Call: " + mce + ", line: " + mce.getBegin().get().line + ", " + e.getMessage());

    errors++;
}

}

Next, is the line printed for unsolved references. In this case the unsolved reference is relative to the method declaration presented at the beginning.

Not solved. Method Call: Entities.EscapeMode.valueOf(escapeMode.name()), line: 542

Also I've noticed that all of my unsolved references are relative to enum method declaration.

Do you have any ideas of how to solve such MCE references?

Jacopo Terrinoni
  • 173
  • 1
  • 14
  • I am having a hard time reproducing your error. Can you show how you create your `CombinedTypeSolver`? Also, it might fix the problem if you configure the parser beforehand to resolve symbols rather than passing the type solver to the visit method. – Lindstorm Aug 11 '19 at 00:27

0 Answers0