Skip to content

Instantly share code, notes, and snippets.

@xdrop
Last active April 5, 2017 18:02
Show Gist options
  • Save xdrop/29fb2f010eed8612512a336bd120762f to your computer and use it in GitHub Desktop.
Save xdrop/29fb2f010eed8612512a336bd120762f to your computer and use it in GitHub Desktop.
CompilationUnit cu = parseSample("Issue174");
ClassOrInterfaceDeclaration clazz = Navigator.demandClass(cu, "PragmaInstr");
MethodCallExpr fileChanged = Navigator.findMethodCall(clazz, "fileChanged");
Expression argument = fileChanged.getArgument(0);
TypeSolver typeSolver = new ReflectionTypeSolver();
JavaParserFacade javaParserFacade = JavaParserFacade.get(typeSolver);
assertEquals(true, javaParserFacade.solve(fileChanged, false).isSolved());
assertEquals("java.lang.String", javaParserFacade.getType(argument).describe());
/* Issue174
class PragmaInstr {
int placement;
String idPragma;
void process() {
switch (placement) {
case 3:
String a = idPragma;
fileChanged(idPragma);
}
}
static void fileChanged( String msg) {
}
}
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment