Hi Mans, Russell, Scott,
Yeah, but my real point was that I forget to do that when I start to type
the expression. It's a pain to have to move back in the code to fix an
error like that when it could be fixed automatically. The usual process is
to type the expression, see the red line, think 'uh, right' and just press
Alt+Enter to accept the suggested fix. Having to click, type a "(" and
press a key combination, then click again to move back to where I was
disrupts my work unacceptably. Especially since 'Add Import' works so
well.
This is one of IDEA's great strengths -- it helps you with syntax so that
you can get on with the business of thinking about what the code actually
does. I accept that the Ctrl+Space fix is easy, but it involves several
steps that I have to consciously make, rather than a simple acceptance that
'that's what I meant'.
Of course, generics would solve this problem properly... Roll on JDK1.5!
Cheers,
Ben.
To: <[EMAIL PROTECTED]>
cc:
From: "Mans af Klercker" <[EMAIL PROTECTED]>
Subject: RE: [Eap-features] "Cast Expression" feature
Hi Ben!
Have you tried
VeryLongClassNameIndeed val = (<caret> v.lastElement();
and press ctrl-shift-space? That seems to do the trick (if I don't
misunderstand you...)
cheers,
/Mans
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> [EMAIL PROTECTED]
> Sent: den 5 februari 2002 12:35
> To: [EMAIL PROTECTED]
> Subject: [Eap-features] "Cast Expression" feature
>
>
> This may have already been suggested, but never mind.
>
> Suppose I have code:
>
> Vector v = new Vector();
> v.add(new VeryLongClassNameIndeed(foo, bar));
> VeryLongClassNameIndeed val = v.lastElement();
>
> Then the last line is an error, underlined with a wiggly line,
> because I've
> forgotten to cast the result of v.lastElement(). I'd like a feature to
> automatically add the appropriate cast. Maybe an 'Cast Expression To X?'
> Alt-Enter pop-up in the manner of 'delare final?' or 'add import?'. The
> list that appears could suggest all compatible types.
>
> Cheers,
> Ben.
>
>
>
>
> _______________________________________________
> Eap-features mailing list
> [EMAIL PROTECTED]
> http://www.intellij.com/mailman/listinfo/eap-features
>
_______________________________________________
Eap-features mailing list
[EMAIL PROTECTED]
http://www.intellij.com/mailman/listinfo/eap-features
_______________________________________________
Eap-features mailing list
[EMAIL PROTECTED]
http://www.intellij.com/mailman/listinfo/eap-features