Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » JavaDoc parser(How to parse the given JS file to obtain JavaDoc corresponding to every node?)
JavaDoc parser [message #512994] Mon, 08 February 2010 14:14 Go to next message
Keya is currently offline KeyaFriend
Messages: 13
Registered: July 2009
Junior Member
Hi,

I want to obtain the JavaScript documentation associated with every element/node in the given JS File.

I have tried ASTParser and couple of mode available with WebTools but apparently I get just a chink of JavaScipt in the whole JS file. There is no further information about it's mapping to the corresponding element.

Please let me know if the feature is supported in WebTools and if so what is the correct way to obtain the required information.

Thanks & Regards,
Keya
Re: JavaDoc parser [message #513133 is a reply to message #512994] Mon, 08 February 2010 21:18 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 2333
Registered: July 2009
Senior Member
On 2/8/2010 9:14 AM, Keya wrote:
> Hi,
>
> I want to obtain the JavaScript documentation associated with every
> element/node in the given JS File.
>
> I have tried ASTParser and couple of mode available with WebTools but
> apparently I get just a chink of JavaScipt in the whole JS file. There
> is no further information about it's mapping to the corresponding element.
>
> Please let me know if the feature is supported in WebTools and if so
> what is the correct way to obtain the required information.

Usually you would do this by calling on the
org.eclipse.wst.jsdt.ui.JSdocContentAccess class on a file in a
JavaScript project's Include Path. You can get a model for the entire
file using
org.eclipse.wst.jsdt.core.JavaScriptCore#createCompilationUn itFrom(IFile) and
then iterate through its children as you wish.

--

Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: JavaDoc parser [message #513159 is a reply to message #513133] Tue, 09 February 2010 06:58 Go to previous messageGo to next message
Keya is currently offline KeyaFriend
Messages: 13
Registered: July 2009
Junior Member
Hi Nitin,

Thanks for the information. I will try to use the JSDocContentAccess and let you know if I can get the desired information.

Regards,
Keya
Re: JavaDoc parser [message #513203 is a reply to message #513159] Tue, 09 February 2010 11:14 Go to previous messageGo to next message
Keya is currently offline KeyaFriend
Messages: 13
Registered: July 2009
Junior Member
Hi Nitin,

The parser you have mentioned is fine and works for the JS file sitting in a project.

I have an additional requirement to parse a non-workspace file for the JavaDoc. These are basically the user libraries that I can attach with the JS Project. Can you please tell me what's the correct way of obtaining the 'org.eclipse.wst.jsdt.core.IJavaScriptUnit' instance from 'org.eclipse.wst.jsdt.internal.compiler.batch.CompilationUni t'?

Thanks & Regards,
Keya
Re: JavaDoc parser [message #513394 is a reply to message #513203] Tue, 09 February 2010 19:16 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 2333
Registered: July 2009
Senior Member
On 2/9/2010 6:14 AM, Keya wrote:
> Hi Nitin,
>
> The parser you have mentioned is fine and works for the JS file sitting
> in a project.
> I have an additional requirement to parse a non-workspace file for the
> JavaDoc. These are basically the user libraries that I can attach with
> the JS Project. Can you please tell me what's the correct way of
> obtaining the 'org.eclipse.wst.jsdt.core.IJavaScriptUnit' instance from
> 'org.eclipse.wst.jsdt.internal.compiler.batch.CompilationUni t'?

The closest thing we have for that kind of task is
org.eclipse.wst.jsdt.internal.core.util.CodeSnippetParsingUt il#parseCompilationUnit(char[],
Map, boolean), which is very much internal. You can, however, then use
a org.eclipse.wst.jsdt.core.ast.ASTVisitor to walk the AST for comments.
It's not nearly as easy to use, but then arbitrary standalone files
aren't a use case in which we're heavily vested.

--

Nitin Dahyabhai
Eclipse WTP Source Editing
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: JavaDoc parser [message #513522 is a reply to message #513394] Wed, 10 February 2010 13:29 Go to previous messageGo to next message
Keya is currently offline KeyaFriend
Messages: 13
Registered: July 2009
Junior Member
Hi Nitin,

Thanks for your help.

But as you have mentioned, it's not really easy to find the JavaDoc attached with the nodes/elements in a given JS file.

Actually, I also wanted to know why I can't see the JavaDoc when I hover over any 'Objects' or any 'Properties' in the JS file in the JavaScript editor.

Only 'methods' in the Java Script file show the attached Java Doc.

Can you tell me what's the problem there?

Also, I would appreciate if you can guide me to the problem and see if I can do something about it.

Thanks & Regards,
Keya
Re: JavaDoc parser [message #513740 is a reply to message #513522] Thu, 11 February 2010 03:00 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 2333
Registered: July 2009
Senior Member
Actually, many of the AST nodes your visitor will come across offer to return their JSDoc ranges; it's then up to you to either cast the IJSDoc object into something you can use, or read the documentation content from the buffer yourself. As for the issues with hover information, I'd need more reproducable steps--preferably in a bug report--to investigate. It's possible that the code responsible for converting your text selection into a resolvable element ran into trouble, as there may be some issues dealing with working copies in editors.

---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: JavaDoc parser [message #514418 is a reply to message #513740] Mon, 15 February 2010 09:29 Go to previous message
Keya is currently offline KeyaFriend
Messages: 13
Registered: July 2009
Junior Member
Hi Nitin,

I am very sorry for a late response.

For the problem that I mentioned with Hover information, I had took the Classic Eclipse SDK 3.5 from the eclipse site and installed WTP plug-ins using the Update Manager.

I create a JavaScript project and add a JS file to it. Basic, ECMA APIs like Document etc are not showing the JavaDoc attached. I get JavaDoc information on functions only like alert("") etc.

Is there something that I am missing in my installation?

Thanks & Regards,
Keya
Previous Topic:Java EE development
Next Topic:cannot find project specific referenced taglibs
Goto Forum:
  


Current Time: Mon Nov 24 01:27:17 GMT 2014

Powered by FUDForum. Page generated in 0.03113 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software