confusing javascript code completion

After working with PhpStorm for 2 days I´m very impressed about features and speed. But I´m a bit confused about javascript code completion. After reading some posts here and youtrack issues I understand how to use JsDoc hints to solve problems regarding autocomplete.
It works almost fine as long as I use only the "." (dot) after a variable or this inside a method. Code completion shows me the list of members and fields of the correct object as I expected. The confusion starts as soon as I type in the first letter after the dot. Instead of listing the members and fields starting with that letter, I get at least one Item on top of the list that I would not have expected.

cc1.jpg
After the dot fine

cc2.jpg
After first letter confusing

Three questions:

1. Is it a problem of settings or what else I´m doing wrong? Would have expected members and fields of the object first.
2. If I type in lets say 3 letters after the dot the list shows me items with this three letters in obscure combinations.  Is it default behavior to show all elements not realy depending on the letters in the given order? Lets say more a search engine?
3. If I got an object working in another file with help of JsDoc, autocompletion works fine (except above behavior) but the structure view don´t know anything about the object. Why not?

Thank´s in advance

10 comments
Comment actions Permalink

The completion issue mentioned by you is resolved in upcoming WebStorm 5.0.4

As for the Structure View problem, could you clarify what you mean? It normally shows the current file content only. How should this object defined in external file be represented there?

0
Comment actions Permalink

Thank´s for your reply Elena!
You are right, the structure view should show me the structure of the current document, I agree, but also help me to find declarations, objects, classes. It does it when you edit a PHP file, you can double click on a variable name of known class X and the source file will be opened and the declaration is shown.
When you edit a javascript file the editor pane knows about the object of the variable and you are able to right click and goto declaration, but the structure view doesn´t show anything about the type of this variable and, of course, you can.not double click to find the declaration which is done in another file. So I don´t understand why it is handled in a different way on the javascript side. Would be much easier to double click in the structure view to show the declaration, like in a PHP file, and not right click on variable in the editor pane, down to goto and choosing declaration.

Best regards, HaPe

Edit:
Forget about this behavior. Don´t know what I´ve clicked inside the PHP structure view, maybe a inherited member, but it seems equal handling inside javascript structure view and PHP structure view, Except that not even the known variable type is shown in the javascript structure view.

0
Comment actions Permalink

Just updated to 5.04, nothing has changed regarding confusing, inconsistent autocomplete...

0
Comment actions Permalink

Hi Hans-Peter,

completion works fine for me in 5.0.4... Can you elaborate a bit more on your issue? Code samples/screenshots would be very helpful

Best regards,
Elena

0
Comment actions Permalink

We've changed autocompletion behavior, please take a look at IDEA-89279. Middle matching still can occur, but results are ranked in another way.

0
Comment actions Permalink

Thanks for your replies,

yes it´s working fine, no question about it, by far the best i´ve worked with ever. That´s the reason why I don´t understand the, in my opinion, breaks of the good completition approach. My actual project contains lot´s of javascript code, libraries, utilities and I love the approach to define types of variables, members of objects with help of JsDoc. It works fine, for a variable of type X the members are shown first in the completion list, as expected. For example:

cc6.jpg

Lets say I want to use the member variable info of the CsExplorerSelection object. If I type the letter "i"  after the dot, I would expect to get "info" at the first place of the upcoming completion list, because there are 2 members starting with "i" in first position, but

cc5.jpg

what I get are 2 not expected entries at the top of the completition list, followed by my expected members, because, I think, there is a exact match with the given "i" I´ve typed. Why? It´s a break of the policy to show known (defined) members first, in my opinion. Instead of using the expected first item, what should be "info", and continue editing, I´m forced to choose the third item of the list or type in the next letter which would be "n"

cc4.jpg

which shows another "exact" match which has nothing to do with the object I´m working on, which is already known by the completition routine, what´s shown by given the member "info" a bold design. After typing the third letter "f" at least

cc3.jpg

I get my "info" on top of the list, what should be the case after typing the first "i" in my opinion, to fasten editing with help of the code completition.

So I dont´t understand why breaking the policy to list "known" members on top of the list. I dont´t know any reason to change this approach at least if there are matches regarding the known object CsExplorerSelection in this case. Additionaly I don´t realy like the approach of showing middle match items, in this case "indexFromPos" and others, before the exact starting match (case ignored) "Infinity". It´s a nice feature for this who want´s to work with it, but I would prefer to let the user choose what approaches he want to use. I mostly knew what I would like to get when i type in some letters. If I type in for example ".get", I would like to see a list of getter functions, getter members, if available, and nothing else. Why don´t make it configurable?

Best regards, HaPe

0
Comment actions Permalink

Try turning Weaker type guess from completion off in Settings | Javascript.
From what i can see with this option off, if the type of the token is determined, autocomplete suggests only items aplicable to that type and if the type is undetermined any item can be suggested as long as it matches the first letters.


var randomObject = {
 a   : true,
 aa  : true,
 aaa : true
};

Test = function() {};
Test.prototype.aaaa = function() {};

var test = new Test();
test.a // autocomplete aaaa()
var undef;
undef.a // autocomplete a

0
Comment actions Permalink

After turning off the weaker type guess option it seams that it helps as long as I´m working inside a object and it´s members using "this"

cc7.jpg

but outside the file which declares the object, I get the same behavior as before

cc8.jpg

type is determined, but autocomplete doesn´t realy care about this. Exact matches of "i" get higher priority as CsExplorer members.

0
Comment actions Permalink

Hi Hans-Peter,


I've logged this completion issue as http://youtrack.jetbrains.com/issue/IDEA-94771

You can watch it to be notified about updates

0
Comment actions Permalink

Thank´s Elena

0

Please sign in to leave a comment.