IDEA is a autocompleting 'val'

I'm facing a problem. When typing "val" and hitting space, IDEA autocompletes it to "validate" from validate(): Unit from AWT Container.

This doesn't happen all the time, only where the Unit fits, like in foreachs. But it is really annoying. I think there is an option to turn off the autocomplete. Are there any other solutions? How about disabling autocomplete for var and val in the plugin?

0
13 comments

It seems there is no completion variant 'val' in your completion list (or it's not the first one and you type very fast, then completion list doesn't disaapear), so this is a bug. Can you give me full example for this behavior? Which IDEA version are you using? I can't reprodice it with my examples.
As workaround you need to disable autopopup completion, Settings -> Editor -> Code Completion -> Autopopup code completion. This is not turnong off autocomplete, you will be able to invoke completion by Ctrl + Space.

Best rergards,
Alexander Podkhlayuzin.

0
Avatar
Permanently deleted user

I'm seeing this too since (I think) 426.

0
Avatar
Permanently deleted user

I tried to reproduce the bug, which worked inside the original project. But I've actually discovered something worse (maybe that's also the bug for the original autocomplete thing).

Try the following code inside a clean project.

package rapid

import java.awt._

class Test(val data: List[Int]){
  def test() {
    data.
  }
}


And then try CTRL-Space right behind "data.". It gives me a lot of methods that are from awt Component or a similar class. Among those is also validate(). The type hint still gives me the correct List[Int], though.

Also when entering "map", it turns red.

I'll make another post once I can reproduce the instant auto-complete of val, though I suppose it's the same bug.

0
Avatar
Permanently deleted user

I've reproduced the original bug. But now I see that it possibly isn't a bug at all. See the following file:

package test

import java.awt._
import javax.swing.JComponent


class Test() extends JComponent(){

  override def paint(g: Graphics) {
    val points: Array[(Int,Int)] = null


    val ellipses = points.map(p => val)
  }
}


The last "val" gets autocompleted into "validate()". But that's obviously because we're inside a JComponent which has "validate()" as one of its methods. But still it's quite annoying because "val" and maybe "var" will be used so much more often than a call to any member. They should be first inside the list of autocompletions.

My versions are 99.32 and 4.407.

0

it's not a bug, intellij ist just too smart ;)

try this instead of your example:

      val ellipses = points.map(p => {
        val
      }

idea seems to know that in a one-line-function, a val declaration doesn't make sense. or it's a beature. something between bug and feature. i like it, though.

0

I'm not sure what I can do with your examples. I don't see anything bad in this examples, or I'm wrong?
Anyway turning off autopopup completion can be reasonable.

Best regards,
Alexander Podkhalyuzin.

0
Avatar
Permanently deleted user

Well, the first example gave me methods of awt Component on a List[Int]. That can't be correct.

For the second example, it's missing the 'val' as the top-most autocompletion, isn't it?

0

second example: how are you going to declare a val AND return the mapped point in a single line? that are 2 statements. you'll need to surround the block with {...}, and inside the block, val is an completion option.

0
Avatar
Permanently deleted user

Ah, you're right if you can't put semi-colons in parenthesis. Then I distilled the wrong example from my project. I was definitely able to declare some sane vals. I'll post another example later.

0

i tried:
List(1, 2, 3).map(e => val x = 0; x + e)
doesn't work

0

I added an issue about the first example: http://youtrack.jetbrains.net/issue/SCL-2716
Similar requests you can add here as comment.

Best regards,
Alexander Podkhalyuzin.

0

Completion variant `validate` is ok here:)
Because here List is java.awt.List <: java.awt.Component.
Problem is that editor should report that List hasn't type parameters (like compiler does), but it's just not implemented feature.

Best regards,
Alexander Podkhalyuzin.

0
Avatar
Permanently deleted user

Good point. Didn't realize this.

0

Please sign in to leave a comment.