How to teach WebStorm a custom library?

Hi everyone,

in my project, I am using the qooxdoo library, which allows defining classes via "qx.Class.define('example.package.Class', { ... });"
WebStorm has library support for this and it works fine, but for various reasons I needed to wrap this method, so that I have something like this:

function defineClass(className, properties) {
    qx.Class.define(className, properties);
    doSomethingElseToo();
}

This breaks the library support, i.e. if I now use "defineClass('example.package.Class', {});" and then do "new example.package.Class();" in my code, WebStorm doesn't recognize this object anymore.

So my question would be: How can I teach WebStorm to recognize this? I tried adding the file declaring defineClass as a library, but it didn't help.
Thanks in advance!


Ingo

5 comments
Comment actions Permalink

Hello!

you can try using JSDoc for this, for example:

function defineClass(className, properties) {
qx.Class.define(className,  properties);
}

/**
* @typedef {Object} qx.test.Dog
* @property  {function} printName
*/
defineClass("qx.test.Dog", {
members:  {
printName: function(){}
}
}
});
/**
*
* @type  {qx.test.Dog}
*/
var myDog = new qx.test.Dog;

Or, try renaming 'defineClass()' to 'define()' (just a hack :))

0
Comment actions Permalink

Hi,

thanks your your reply Unfortunately, this doesn't help me. I tried all kinds of documentation that I could think of, but nothing seems to work. Renaming defineClass to define doesn't work either, but also wouldn't be possible (there is also a qx.Interface.define -> defineInterface wrapper).

Edit: Actually, right now it seems like a @class annotation before defineClass/defineInterface works (not exactly pretty to call interfaces @class, too, but oh well). I'll try it on my entire project now and see how it plays out. I swear I've tried this before, though…

0
Comment actions Permalink

I replaced it everywhere now – by hand; WebStorm should support multiline regular expression replacing when replacing in entire folders, too. ;)
It seems to work just fine now. Thanks – while your suggestion didn't work directly, it at least made me try again :)

0
Comment actions Permalink

For multi-line replacing in path, please vote for http://youtrack.jetbrains.com/issue/IDEA-79401

0

Please sign in to leave a comment.