IDEA and JavaScript Library Code Hinting

Hi folks, I'm hoping that I'm just doing something incorrectly. I have set up an external JavaScript global library and associated it with a project. In this case it is the Google Closure library. I can see the library in the list of external libraries for the project, and can even expand it to see all of the .js files it contains. If I type code that uses the library, such as "goog.require('goog.dom');", I can mouse over the various parts of this statement and see information about it:

mousing over "goog" shows "base.js : var goog = goog || {}"

mousing over "require" shows "multiple implementations", and clicking that opens a small drop down that would let me pick the function from a list including scriptaculous, dojo, and of course closure

I can even control-click on these to jump to the code in the relevant .js file.

So first, given the above JS statement, if it knows that "goog" is part of Closure, why does it not know that the "require()" funciton must also be part of Closure? Shouldn't that be inferred? I'm not clear on why it is showing me all of these other options, or at least why the Closure version is not the first option.

And second, when I type "goog." and hit control-space, I get a bunch of items in the drop down but none of them are actually for this Closure item. So while IDEA obviously "knows" about this (given the above ability to hover over and link to the source), why does it not provide these options in the code hint drop down?

As I said, I hope I'm just missing some configuration option or something, because this doesn't seem to make any sense. Anyone have any ideas?

Thanks,

Brian

6 comments
Comment actions Permalink

If you type "goog." you get "dom", "require" and other similar items. Isn't it what you would expect? If you don't get them, it may be some kind of misconfiguration. In general completion is controlled separately from symbol resolving to make it possible to narrow down the completion scope.

0
Comment actions Permalink

Right, that's what I'm saying, I don't see require or dom in the option list. Actually I do see a ".require" but it is tagged as Dojo, and there is no ".dom" at all. And again, that's despite the fact that these are colored by the IDE syntax highlighter and that I can mouse over, say, "require", click the "multiple implementations", and see the Closure version of it in the resulting select list.

This is on the just released 11.1 version of IDEA Ultimate. So if it *is* some sort of configuration issue, I can't see what I'm doing wrong. Any other ideas? Should I open a support ticket?

Thanks again,

Brian

0
Comment actions Permalink

Make sure to enable library completion in project scope. In 11.1 you must go to Settings|JavaScript|Libraries, check the box in front of "Closure" library (or whatever you have given to it) and click "OK". By the way, I have added all .js files from Closure distribution package without excluding any.

0
Comment actions Permalink

One more thing: It's not necessary to submit a ticket right now. I hope we can handle it via this thread.

0
Comment actions Permalink

Yes! This was exactly what I was missing. I had read the docs and did find the section "Specify usage scopes", but I didn't think it applied to me because the first sentence is "By default, all the libraries downloaded from within IntelliJ IDEA can be referenced in any file within the project. In other words, their usage scope is the whole project.", which made me assume that if I did nothing else it should "just work". I didn't read any further.

Thanks again! You *may* want to consider revising that section in the docs a bit since you can probably see why I read that and went no further because it makes it sound like the default behavior is all you need.

Regards,

Brian

0
Comment actions Permalink

Cool! I'll take a note that we should make the documentation more clear.

0

Please sign in to leave a comment.