Javascript code completion
Hi ! I'm testing WebStorm because I need a smarter IDE for my Javascript development, I'm working with Netbeans right now, but for some reason it doesn't detects nested object's properties, that is:
var first = {
second: {
third: function(){}
}
}
In Netbeans if I type:
first.second. <- Ctrl+Space here
it doesn't find anything
and also I can't se the full structure in the Navigator.
WebStorm is reading the full structure correctly, the problem (paradoxically) is that it reads too much !
I mean, when I type "first.second." and press Ctrl+Space I get a looot of things.
The same applies to the Structure panel (but at least here if I choose "Group Methods by defining Type" I get a structure of my own objects and properties more readable.
Is possible to get a better code completion in javascript (for example, only show my own object's properties, or show them at the top) ?
Also, do I need to add jQuery somewhere to get code completion and documentation?
In Netbeans this is automatic, it reads all the .js files added to the project.
Thanks !
Please sign in to leave a comment.
I think your first question is discussed here: http://youtrack.jetbrains.net/issue/WI-2222. There have been some imrpovements to that already (in PhpStorm/WebStorm 3.0) and more are coming. And yes, if you add a .js file to your project directory, its symbols automatically get to code completion like in NetBeans. In addition you can also control what items should be in code completion from predefined/global libraries using JavaScript Libraries/Scope settings.You can essentially remove all the items like AJAX, DOM etc. functions if you wish to do so. Completion may also work from libraries not located under your project root. If you still feel that something is missing and not working as expected, you are welcome to submit a feature request at http://youtrack.jetbrains.net.
mmm... nop, it doesn't work to me, please can you test the example of my first post?
This is what is happening:
first. <- click Ctrl+Space here and you will see "second" as the first option this is OK !
first.second. <- click Ctrl+Space here and you will see things like __defineGetter__ and a very long list of unuseful things as the first options (and then after those things there's "third" so WS is reading it OK but not sorting it OK)
There's an option that says "click to sort variants by relevance" and "click to sort variants alphabetically" but it doesn't do anything.
So, the autocompletion is OK in the first level, but not in the second.
Please can someone confirm this or I'm the only with this problem?
If I use this example:
Then WS works ok when you type firs.second. you will get "third" as the first option in the autocoplete.
Thanks !
Here is what I did:
1) Created an empty project with WebStorm 3.0.2,
2) Created a file named a.js with your sample code,
3) Created anothe file b.js and started typing "first.": the completion variant "second" came at the top. Similarly "third" comes at the top after I type "second.".
I believe this is what you expect and frankly don't know why it doesn't work this way for you. There are other completion variants but they are under "second" and "third". I did not set any extra options for it.
:O
If I follow your steps then it works, I'm getting "third" as the first option.
But only if I run it in another file like you (that is, define the object in one file, try to use it in another file)
Please try the example on the same file
Thanks !
PS: also note, how I said, that if you define the object like:
then the code completion works fine even on the same file.
For me both "second" and "third" come at the top no matter whether it's the same file or two different files. As far as I can remember there was an issue with that quite a long time ago but it was fixed. Could it be that we are using different versions? Mine is WebStorm 3.0.2, build 111.296 but even older builds should be Ok.
well that's really weird then, are you sure we are testing the same?
I'm using 3.0.2 too, here you can see the problem:
Having the same on your code example.
yes? so it's not my problem only? should I open a ticket for this?
Yes, I think it makes sense to submit a ticket. My only concern is that it may be closed as not reproducible. I still don't know what may cause the behaviour you have described.
I think it's already there: http://youtrack.jetbrains.com/issue/WI-9882
well that's strange, Andriy has the same problem, so it can't be only mine.
Maybe is pattform dependant? I'm using Windows.