Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » resolveBinding return null
resolveBinding return null [message #808113] Mon, 27 February 2012 07:22 Go to next message
Alireza Missing name is currently offline Alireza Missing name
Messages: 105
Registered: July 2009
Senior Member
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);

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
Re: resolveBinding return null [message #808345 is a reply to message #808113] Mon, 27 February 2012 12:23 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2235
Registered: July 2009
Senior Member
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


--
---
Nitin Dahyabhai
Eclipse WTP Source Editing and JSDT
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: resolveBinding return null [message #808354 is a reply to message #808345] Mon, 27 February 2012 12:40 Go to previous messageGo to next message
Alireza Missing name is currently offline Alireza Missing name
Messages: 105
Registered: July 2009
Senior Member
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
Re: resolveBinding return null [message #808373 is a reply to message #808354] Mon, 27 February 2012 13:09 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2235
Registered: July 2009
Senior Member
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.

--
---
Nitin Dahyabhai
Eclipse WTP Source Editing and JSDT
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: resolveBinding return null [message #808844 is a reply to message #808373] Tue, 28 February 2012 02:59 Go to previous messageGo to next message
Alireza Missing name is currently offline Alireza Missing name
Messages: 105
Registered: July 2009
Senior Member

Actually I sent another post about how to create a IJavaScriptProject and still I did not get a good answer. What would be the easiest way (assume I put all my files in a folder with name "jsfiles")?

Regards,
Alireza
Re: resolveBinding return null [message #809283 is a reply to message #808844] Tue, 28 February 2012 12:25 Go to previous messageGo to next message
Alireza Missing name is currently offline Alireza Missing name
Messages: 105
Registered: July 2009
Senior Member
I added the folder with javascript files to my include path in eclipse but still the bindings are null.

Regards,
Alireza
Re: resolveBinding return null [message #1041471 is a reply to message #808113] Mon, 15 April 2013 02:29 Go to previous message
Elham M is currently offline Elham M
Messages: 1
Registered: April 2013
Junior Member
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 :)
Previous Topic:Creating a new StructuredEditor
Next Topic:How to find links pointing to document
Goto Forum:
  


Current Time: Mon Jul 28 06:33:50 EDT 2014

Powered by FUDForum. Page generated in 0.03245 seconds