I just upgraded to phpStorm 4 and javascript code complete has gotten worse
I have built dynamic javascript object hierachy, which phpStorm 4 does not understand (hard to blame the storm - objects are built with a function call that takes a prototype object as a parameter). v3 just listed all functions/properties defined in a project, from which I could pick the one I want. However, v4 presents only a few options (don't kow what the algorithm is) and code complete becomes useless. Is there an option where I can turn v3 code complete for javascript?
Regards
gary
Please sign in to leave a comment.
Hello, Gary,
Sorry for the late response.
Currently there is no such option in configuration, but you can explicitly annotate your factory function with return type Object, something like this:
/**
* @param proto
* @return {Object}
*/
function buildObject(proto) { /**/ }
If this doesn't work for you, please provide your use case more specifically, we'll try to come to the desicion:)
Sorry, Konstantin, for the delay. Here is the file - I narrowed it - the problem is with this keyword. See the comment at the end: - try to code complete this.m - only meth3 is prompted. I cannot move to 4 if this is not fixed (I'm still on 3, probably too late to ask for money back for upgrade :) ).
c )= {
Prototype_CONSTR:function() {},
/**
* @param proto, props
* @return {Object}
*/
nowp:function (proto, props) {
this.Prototype_CONSTR.prototype = proto;
var o = new this.Prototype_CONSTR();
if (props) {
$.extend(o, props);
}
o.proto = proto;
return o;
}
}
t = {};
t.prot1 = {};
t.obj1 = c.nowp(t.prot1,{
prop1:'aaa',
meth1:function() {
}
})
t.obj2 = c.nowp(t.obj1,{
prop2:'bbbb',
meth2:function() {
}
})
t.obj3 = c.nowp(t.obj2, {
meth3:function() {
/// if you press ctrl + space, only meth3 is prompted, however, meth2 and meth1 are in the hierachy
this.m;
}
})
Javascript completion tried to become smarter in 4.0 and it suggests only relevant options. But eventually it is not smart enough is some complex cases, i.e in yours. I don't know how to workaround this in 4.0, but in 5th version you'll be able to help completion processor with @extends annotations:
Please try 5.0 EAP (which will be very soon) and let me know how this works for you.