method type inference -- jsdoc @type annotation is not used? [message #530630] |
Fri, 30 April 2010 11:28 |
domcap 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 #531232 is a reply to message #531006] |
Tue, 04 May 2010 09:21 |
domcap 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03724 seconds