Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » method type inference -- jsdoc @type annotation is not used?
method type inference -- jsdoc @type annotation is not used? [message #530630] Fri, 30 April 2010 11:28 Go to next message
domcap  is currently offline domcap Friend
Messages: 6
Registered: April 2010
Junior Member
The javascript Content Assist feature mostly seems very impressive, and I'm really hoping to be able to make it standard for use within our company, and an option for use by clients of our APIs. However, there seems to be one major failing:

Quote:

The inferred type returned by a method does not seem to make use the of @type jsdoc annotation, which tells it precisely what it is!



So, far, I've only been able to get the return value of a method to have type information if it looks like this:

package.Foo.prototype.getX = function()
{
	return new package.Bar();
}


or even this:

package.Foo.prototype.getX = function()
{
	return this;
}


but it never works when it looks more like this:

/**
 * @type package.Bar
 */
package.Foo.prototype.getX = function()
{
	return this.m_oX;
}


is there some other notation used for indicating a methods return type?

Or, if this is by intention, can anybody point to the right class or package within org.eclipse.wst.jsdt where I should go looking to add this feature?

Thanks in advance, Dominic.
Re: method type inference -- jsdoc @type annotation is not used? [message #531006 is a reply to message #530630] Mon, 03 May 2010 10:29 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4435
Registered: July 2009
Senior Member

Hopefully we'll get to spend some time in the next release deciding
which flavor of "JSDoc" we're actually trying to comply with. Between
http://jsdoc.sourceforge.net/#tagref and
http://code.google.com/p/jsdoc-toolkit/wiki/TagReturns, and we seem to
be leaning toward the latter. The parser is something I want to spend
some time on in the next release, and that includes cleaning up the
JSDoc handling.

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


_
Nitin Dahyabhai
Eclipse Web Tools Platform
Re: method type inference -- jsdoc @type annotation is not used? [message #531232 is a reply to message #531006] Tue, 04 May 2010 09:21 Go to previous messageGo to next message
domcap  is currently offline domcap Friend
Messages: 6
Registered: April 2010
Junior Member
Hi Nitin,

Thanks for the response on this, it's much appreciated. Okay, so instead I tried the jsdoc-toolkit usage, as follows:

/**
 * @returns {package.Bar} the X you are looking for.
 */
package.Foo.prototype.getX = function()
{
	return this.m_oX;
}


but this too failed to make code completion work for the returned type -- I'm using Eclipse Galileo (20100218-1602) BTW. You seem to be indicating that this functionality is in the current codebase. Is it worth me trying the latest Eclipse 3.6M7 milestone to get this functionality?

Also, we've been using jsdoc for at least 5 years at the company I'm currently working at, and have in the region of 100Klocs of Javascript. Until your message I was actually even unaware of the existence of the jsdoc-toolkit implementation, and I'm not sure we'd be able to move easily since we already have lot's of modifications to the original version (very hacky perl code to boot). So ideally, from our perspective, it would be far better if both usages were supported. There doesn't seem to be any particular complications to doing this, except considering which to prefer if (strangely) both ways are used to return the actual type.

Anyway, thanks for your help, Dominic.

[Updated on: Tue, 04 May 2010 09:24]

Report message to a moderator

Re: method type inference -- jsdoc @type annotation is not used? [message #532550 is a reply to message #531232] Mon, 10 May 2010 12:52 Go to previous messageGo to next message
domcap  is currently offline domcap Friend
Messages: 6
Registered: April 2010
Junior Member
Ok, I just took the plunge and installed Eclipse Helios M7 to see if this functionality now works, and it does ... but there's also a serious regression too!

Both '@returns {type} desc' and '@type type' now work, but class inheritance using @base and @extends has stopped working since Eclipse Galileo!

This is critical for people using libraries where inheritance is performed using a library method. In my tests, the only jsdoc tag support we need to allow decent javascript code completion are '@returns/@type' & '@extends/@base'.

Can this regression be fixed before the final release of Hellios? Should I report it somewhere?
Re: method type inference -- jsdoc @type annotation is not used? [message #532593 is a reply to message #531006] Mon, 10 May 2010 14:28 Go to previous message
sNop is currently offline sNopFriend
Messages: 281
Registered: July 2009
Senior Member
Hi Nitin Dahyabhai,

> Hopefully we'll get to spend some time in the next release deciding
> which flavor of "JSDoc" we're actually trying to comply with. Between
> http://jsdoc.sourceforge.net/#tagref and
> http://code.google.com/p/jsdoc-toolkit/wiki/TagReturns, and we seem to
> be leaning toward the latter. The parser is something I want to spend
> some time on in the next release, and that includes cleaning up the
> JSDoc handling.
>

http://www.eclipse.org/forums/index.php?t=msg&th=167646& amp;start=0&#msg_532587
Previous Topic:Icon in Editor
Next Topic:jsDoc vs jsdoc-toolkit
Goto Forum:
  


Current Time: Tue Apr 23 11:58:48 GMT 2024

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

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

Back to the top