On 2/27/2012 7:22 AM, Alireza Mising name wrote:
> I am trying to get method binding from javascript source file. What I do
> is to set up the parser as follow:
>
> ASTParser parser = ASTParser.newParser(AST.JLS3);
> parser.setKind(ASTParser.K_COMPILATION_UNIT);
> parser.setResolveBindings(true);
> parser.setSource(source);

What was "source" here?

> JavaScriptUnit unit = (JavaScriptUnit) parser.createAST(null);
>
> and then I add a visitor to the "unit" to visit FunctionDeclaration.
> Inside FunctionDeclaration I try to get resolveBinding, but I get null.
> Which part is wrong? How can I get method binding?
>
> Thanks in advance,
> Alireza

On 2/27/2012 12:40 PM, Alireza Mising name wrote:
> The source is char[] that I read from js files. I use a visitor class to
> visit FunctionDeclaration and it works perfectly fine. The problem is
> with binding that returns null. Any thought on that?
>
> Regards,
> Alireza

You have to set the project on the ASTParser, or otherwise use a real
file that's in a project's Include Path--otherwise it has no idea where
to look for even the built-in runtime objects.

Hi
I have a same problem!
I can read function using "FunctionDeclaration" but I want to access to variables in my java script code. I use "VariableDeclaration"! It doesn't work, and returns null.
Can you help me.
Thanks :)