How to extend javascript type inference [message #723531] |
Thu, 08 September 2011 14:30  |
Eclipse User |
|
|
|
Hi folk,
I have asked a similar question on ATF and were suggested to post it here. Javascript type inference has done pretty awesome job on inferring type based on javascript docs annotation.
For example,
/*
* @param {String} a [required]
* @return {myobj}
*/
function foo(a) { return new mynewobj(a); }
function bar() {
var ret = foo ("hello");
var ret1 = ret
ret1 // rec's type is myobj
}
But myobj is a generic object, it is extended based on the parameter passing into mynewobj. In order to make the type inference more useful, I want to augment the inferred type "myobj" with the extra information passed to mynewobj.
I noticed that org.eclipse.wst.jsdt.core.inferrenceSupport is the extension point for type inference. In this case, I don't need to modify how type is populated along the AST, but only need to inject extra info to the initial type that is returned from foo based on its formal parameter. Is this doable with the above extension point or I have to modify the wst.jsdt.core code?
Any suggestion is highly appreciated.
Ning
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.28522 seconds