| [news.eclipse.tools.jdt] Re: Using the ASTParser for parsing an expression... |
The problem is that typeBinding is null. How can I get the return type then?The bindings are only available if you parse a compilation unit. You don't get bindings for an expression.
2nd question: If I have got a more complex expression (like expr2) how do I add the declaration of those variables to the expression?
AST ast = astNode.getAST();
SingleVariableDeclaration varDecl = ast.newSingleVariableDeclaration();
varDecl.setType(ast.newSimpleType(ast.newSimpleName("MyType")));
varDecl.setName(ast.newSimpleName("myVar"));
Are you trying to build this expression "String expr2 = "myVar.myMethod(myParam)" ? -- Olivier