actually, you are incorrectly interpreting the symptom you observed...  The
drop down does not select the "longest possible value", the semantics seem
to be more like "the most recently declared value" (this is, as well, a
purely experimental conclusion -- maybe a definitive description of the
*actual* behavior from someone at IntelliJ would be useful?)  This seems to
me to be the most likely desired behavior, but there are arguments for other
mechanisms.

given:

    private void foo()
    {
        int a = 1;
        int aaa = 2;
        int aa = 3;

        int b = a|
    }

hitting CTRL-Space at | will yield a list containing 'a', 'aa', and 'aaa',
but 'aa' will be recommended, as it is the most recently declared.

interestingly, CTRL-Space doesn't seem to care about "assignability" in
making its suggestions - for example, if you change the above to:

    private void foo()
    {
        int a = 1;
        int aaa = 2;
        int aa = 3;
        Object aaaa = null;

        int b = a|
    }

pressing CTRL-Space at | suggests 'aaaa', even though Object is not
assignable to int...  The same behavior occurs even if we aren't discussing
primitive types:

    private void foo()
    {
        Integer a = new Integer(42);
        Double aa = new Double(42.0);
        String aaa = "aaa";

        Number n = a|
    }

pressing CTRL-Space at | suggests 'aaa', even though it is not assignable,
but 'a' and 'aa' are...

unassignable objects need to be in the list, because we may want to get the
return value from one of its methods, but if the drop-down is going to go to
the trouble of figuring out which of the items is most likely to be the
desired value by looking at declaration order, shouldn't it maybe also give
preference to the items that are actually assignable to the LHS of the
assignment expression?

-Bryon

----- Original Message -----
From: "Kirk Woll" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, March 17, 2002 3:09 PM
Subject: [Eap-list] CTRL-Space selects the longest possible value, rather
than the shortest


> Given:
>
> class A {
>     void a() {
>         int a;
>         int aa;
>         int b = a|
>     }
> }
>
> Hitting CTRL-Space at | will yield a drop down box with two entries: "a"
> and "aa".  However, "aa" is selected rather than "a".  I find this
> behavior confusing as I would expect the more exact match (and the
> shorter match, and the first match) to be selected.
>
> Kirk
>
>
> _______________________________________________
> Eap-list mailing list
> [EMAIL PROTECTED]
> http://www.intellij.com/mailman/listinfo/eap-list
>


_______________________________________________
Eap-list mailing list
[EMAIL PROTECTED]
http://www.intellij.com/mailman/listinfo/eap-list

Reply via email to