WebStorm completion, JSDocs and module pattern

I commonly create code like this:
function(){
     var self = this;
     /**
      * Does stuff
      * @param param1 xxxxx
      */
     function dostuff(param1){}

     self.dostuff=dostuff;
     return self;
}

However code completion will show 'dostuff' as having multiple implementations a method (the actual function) and a function (the assignment of the function to the variable this.dostuff, which doesnt actually have a jsdoc annotation)

How to get WS to ignore the assignment version for completion


Also how to document Object.defineProperties so that WS recognises them.

Thanks
Rob

3 comments
Comment actions Permalink

Not sure I follow you... When does the completion shows several doStuff implementations?

As for defineProperties(), try using @memberOf annotation, as it's suggested in https://github.com/jsdoc3/jsdoc/issues/449

Like:

var o = {}; // Creates a new object

/**
*
* @name a
* @memberOf o
*/
Object.defineProperty(o, "a", {value : 37,
                               writable : true,
                               enumerable : true,
                               configurable : true});

0
Comment actions Permalink

For example:
I type....

ds.doStu

it shows [doStuff    (several definitions)]

then I hit enter

ds.dostuff()

if I then "ctrl+mouse over"  'dostuff'  instead of showing me the params it shows a tooltip "multiple declarations"

when I then click a popup appear "choose declaration" with two items
"m" doStuff
"f"   doStuff

clicking on "m" takes me to the actual function declaration, clicking "f" takes me to the assignment "self.doStuff=doStuff"

0
Comment actions Permalink

can't recreate in 8.0.4 using the following code:

function g (){

     var self = this;

     /**
      * Does stuff
      * @param param1 xxxxx
      */
     function dostuff(param1){}
     self.dostuff=dostuff;
     return self;
}

var gg = new g();
gg.dostuff("") // shows a single doStuff(param1) in completion and on ctrl+click/ctrl+mouse hover

0

Please sign in to leave a comment.