|
Re: How to let JSDT know the variable type? [message #648863 is a reply to message #648732] |
Fri, 14 January 2011 18:45 |
|
Phillip,
JSDT supports the JSDoc standard. I am not an expert on JSDoc but from what I can tell there is no way to specify the type of a variable with JSDoc but all is not lost.
Assuming you have a "myModel" variable you could do something like this:
/**
* @returns Model
*/
function getModel() {
return myModel;
}
var myLocalVar = getModel();
Now JSDT will detect the return type of getModel as Model and then set the correct type on the local variable.
I hope this helps. Let us know if you need any further assistance.
Blue Skies,
~Ian
Ian Tewksbury
WTP JavaScript Tools
IBM Rational
-----
“When once you have tasted flight, you will forever walk the earth with your eyes turned skyward, for there you have been, and there you will always long to return.” ~Leonardo da Vinci
|
|
|
Re: How to let JSDT know the variable type? [message #648866 is a reply to message #648732] |
Fri, 14 January 2011 18:50 |
|
Phillip,
Ignore my last message, there is an easier way, actually just the way you suggested works.
We support both 1.0 and 2.0 JSDoc defined here http://sourceforge.net/projects/jsdoc/ and here http://code.google.com/p/jsdoc-toolkit/ respectively.
In the 2.0 specification there is an @type annotation.
So this works:
/**
* @type Model
*/
var myLocalVar = myModel;
And then you shoudl be able to get the contenet assist just as you would if you did
var myLocalVar = new Model();
Blue Skies,
~Ian
Ian Tewksbury
WTP JavaScript Tools
IBM Rational
-----
“When once you have tasted flight, you will forever walk the earth with your eyes turned skyward, for there you have been, and there you will always long to return.” ~Leonardo da Vinci
|
|
|
Re: How to let JSDT know the variable type? [message #648869 is a reply to message #648732] |
Fri, 14 January 2011 18:58 |
|
Phillip,
As a side note if you ever want to see what type JSDT is inferring any local variables or the return types for functions you can enable the following functionality for the Outline view:
Window -> Preferences -> JavaScript -> Appearance -> Show inferred function return types
Blue Skies,
~Ian
Ian Tewksbury
WTP JavaScript Tools
IBM Rational
-----
“When once you have tasted flight, you will forever walk the earth with your eyes turned skyward, for there you have been, and there you will always long to return.” ~Leonardo da Vinci
|
|
|
|
Powered by
FUDForum. Page generated in 0.04115 seconds