| How to let JSDT know the variable type? [message #648732] |
Fri, 14 January 2011 05:06  |
Phillip Gussow Messages: 2 Registered: January 2011 |
Junior Member |
|
|
Hi,
I'm working with a tool called Cordys and they have a concept called XForms.
In this Xform I can create a 'Model' and give that a name. Let's call that myModel.
In that XForm I can attach a JS file to do custom scripting. This means that in my .js file I can do something like:
or
What I have done is for all those Model options create a separate js file and add all functions to that JS.
So if I do:
var myModel = new Model();
myModel.re //Code completion works like a charm!
Then it works perfectly and code completion kicks in as it should.
Now my actual problem is that the var myModel = newModel() is NOT present in the JS file.
So what I'm looking for is an easy way to tell the JSDT what type it should assume for the variable.
In Pseudo Code this is what I would like to do:
/**
* @type Model
*/
var myLocalVar = myModel;
I know i.e. Zend does it like this for PHP:
<?php /**
* @param int myInt The integer parameter for the method
*/
function something($myInt)
{
...
} ?>
So the bottom line:
Can I let the code assistant explicitly know which type a variable is?
Thanks in advance!
|
|
|
|
| Re: How to let JSDT know the variable type? [message #648866 is a reply to message #648732] |
Fri, 14 January 2011 13:50   |
 |
Ian Tewksbury Messages: 48 Registered: July 2009 Location: RTP, NC, USA |
Member |
|
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02595 seconds