is this by design?

If I press Ctrl-Space in the following code IDEA appends "Foo" to the indentifier "bar". Pressing Ctrl-Space again, appends it again, and so on. I think this a bit strange as Foo cannot be resolved so why use it for completion? And why append it again and again? Is this by design or should I file a bugreport?

( | is cursor)

Bas

0
4 comments
Avatar
Permanently deleted user

This is by design and very convenient. It allows you to construct a
composite variable name based on the type of the variable...

e.g.

Component selected|

I want to call my field selectedComponent, so all I have to do here is
ctrl-space. Works the same way with methods:
Component getSelected|

Just out of interest, what is the problem you have with this feature?

Bas Leijdekkers wrote:

If I press Ctrl-Space in the following code IDEA appends "Foo" to the indentifier "bar". Pressing Ctrl-Space again, appends it again, and so on. I think this a bit strange as Foo cannot be resolved so why use it for completion? And why append it again and again? Is this by design or should I file a bugreport?

( | is cursor)

 class CompletionTest {
> 	Foo bar|
> }
> ]]>

Bas


0

Nathan Brown wrote:

Just out of interest, what is the problem you have with this feature?


I was typing in some new code and I ended up with something like this:


I did two things wrong here of course, but I was surprised with the result. The first thing I did wrong was to type Sring instead of String. Easy to fix, but after I fix the type, the identifier still has the typing error. Also I accidentaly hit Ctrl-Space twice, thank god for CamelPlugin to fix that.
Had IDEA not completed the variable name with a non-existant type I would have noticed my mistake sooner (but I can live with the current behaviour).

0
Avatar
Permanently deleted user

Its also useful to complete using a non existent type if you're using
the field to create a class by intention.

e.g.

private Widget selectedWidget;

Widget doesn't exist and I can create it by intention action, but I
don't necessarily want to create Widget until I have fully declared the
field as that would involve leaving the current unit uncompilable... all
Idea needs to know to help me is the name of the class of the field even
if it doesn't yet exist.

Bas Leijdekkers wrote:

Nathan Brown wrote:

>>Just out of interest, what is the problem you have with this feature?


I was typing in some new code and I ended up with something like this:

 public class MyClass {
> Sring blaSringSring
> }
> ]]>


I did two things wrong here of course, but I was surprised with the result. The first thing I did wrong was to type Sring instead of String. Easy to fix, but after I fix the type, the identifier still has the typing error. Also I accidentaly hit Ctrl-Space twice, thank god for CamelPlugin to fix that.
Had IDEA not completed the variable name with a non-existant type I would have noticed my mistake sooner (but I can live with the current behaviour).


0
Avatar
Permanently deleted user


Which is sometimes what you want (my class has only one field of type DependencyGraph, and I want it's name to be m_dependencyGraph), and occasionally stupid (if someone comes to me with a variable name ending in Boolean or Int, they are not likely to pass code-read). The first case is common enough that this is a worthwhile feature. The second case happens commonly enough to make me annoyed everytime it happens.

--Dave Griffith

0

Please sign in to leave a comment.