1

I'm using JavaParser.

For example, I'm having below method

void checkCall()
{
    Blabla.test();
}

Blabla.test(); is a static call. I want to change Blabla.test() to ABCD.test() without changing any other. I got Blabla from methodCall.getScope().get(). But how to use methodCall.setScope()? It's expecting Expression as a parameter.

gre_gor
  • 6,669
  • 9
  • 47
  • 52
RAM NATHAN
  • 19
  • 3

1 Answers1

1

To understand what is going on you have to consider that JavaParser is a parser. So it means that it builds an Abstract Syntax Tree, it does not resolve symbols (this is done by JavaSymbolSolver). Therefore the scope here is not a class, from the point of view of JavaParser. It is instead a name, that someone later will resolve and figure out is a class.

All of this to say that you should use a NameExpr as your scope to be passed to setScope.

Source: I am a contributor to JavaParser

Federico Tomassetti
  • 2,100
  • 1
  • 19
  • 26