Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » JS Library stubs, JSDoc, and libraries
JS Library stubs, JSDoc, and libraries [message #538481] Mon, 07 June 2010 17:36 Go to next message
Mark Storer is currently offline Mark Storer
Messages: 46
Registered: May 2010
Location: Vista, CA
Member

In a project with the JS nature, I've created a demo stub library with some JSDoc comments for testing purposes. I'm having two issues.

1)

When I define a function as
foo.prototype.bar = function( param ) {
 ...
};


it appears in the code completion as a member variable rather than a method. What is the Correct Way to stub out class functions so that they'll appear in code completion correctly.

2)
The JSDoc does not appear from the JS comments. Do I need to generate the HTML?

3)
A fierce dedication to the Pope.

4)
How can I convince the JS editor that a particular function will always return a given type? If foo.bar() always returns a "baz", how do I let the world know so that code completion will work on the returned "baz"?

5)
There is no problem number five.

6)
Is there a way to associate a library files programmatically? Our ultimate goal is to create our own project type that will always have the JS nature with our own object model already "attached".


--Mark Storer
Senior Software Engineer
Autonomy Cardiff

import legalese.disclaimer;
Disclaimer<Cardiff> disCard = null;

Google Code Search
Re: JS Library stubs, JSDoc, and libraries [message #629951 is a reply to message #538481] Thu, 30 September 2010 06:09 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2308
Registered: July 2009
Senior Member
On 6/7/2010 1:36 PM, Mark Storer wrote:
> In a project with the JS nature, I've created a demo stub library with
> some JSDoc comments for testing purposes. I'm having two issues.
>
> 1)
>
> When I define a function as
> foo.prototype.bar = function( param ) {
> ...
> };
>
>
> it appears in the code completion as a member variable rather than a
> method. What is the Correct Way to stub out class functions so that
> they'll appear in code completion correctly.

I get a correct proposal when I first define what the prototype is in
Helios SR1:
foo.prototype = new Object();
foo.prototype.bar = function( param ) {

};
new foo().|

Do you not?

> 2)
> The JSDoc does not appear from the JS comments. Do I need to generate
> the HTML?
>
Appear where? Which comments do you mean?

> 3)
> A fierce dedication to the Pope.
>
Not sure I can help there.

> 4)
> How can I convince the JS editor that a particular function will always
> return a given type? If foo.bar() always returns a "baz", how do I let
> the world know so that code completion will work on the returned "baz"?

Write your function in a way that it actually *does* return that type, e.g:
foo.prototype = new Object();
foo.prototype.bar = function( param ) {
return 5; // yes, it's a silly example
};

....or document it with the return/returns tag:
/**
* @returns {Number}
*/
foo.prototype.bar = function( param ) {};

Documentation generally wins if the two mechanisms disagree.

> 5)
> There is no problem number five.
Not sure I can help with that, either.

> 6)
> Is there a way to associate a library files programmatically? Our
> ultimate goal is to create our own project type that will always have
> the JS nature with our own object model already "attached".

It sounds like you want to make use of the
org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer extension
point, which will let you create a reusable container in a plug-in of
your own for placing your files onto the Include Path. The
org.eclipse.wst.jsdt.support.firefox plug-in does nothing *but*
contribute such a container, making it a very good example.

http://help.eclipse.org/helios/topic/org.eclipse.wst.jsdt.do c/reference/extension-points/org_eclipse_wst_jsdt_core_JsGlo balScopeContainerInitializer.html


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


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: JS Library stubs, JSDoc, and libraries [message #630172 is a reply to message #538481] Thu, 30 September 2010 21:17 Go to previous message
Mark Storer is currently offline Mark Storer
Messages: 46
Registered: May 2010
Location: Vista, CA
Member

Thanks for your help, but I've already got most of it worked out, as you can see from my last posts here.

As to the "fierce dedication to the pope" and "there is no problem number six", they're both Monty Python references... to two different skits.

I'm still having issues here and there, but I've logged bugs for them already, and was a bit disappointed to find that they didn't make it into 3.6.1.



--Mark Storer
Senior Software Engineer
Autonomy Cardiff

import legalese.disclaimer;
Disclaimer<Cardiff> disCard = null;

Google Code Search
Previous Topic:custom JSdoc: indexable Object
Next Topic:Easily viewing schema for a given referenced schema
Goto Forum:
  


Current Time: Tue Oct 21 07:14:33 GMT 2014

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

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