Display return type of function?

Is there a way to quickly display the return type of an un-annotated function?

e.g. (simple example) for `def isPalindrome (n: Int) = n.toString == n.toString.reverse` is there a quick way to get IDEA to tell me that this is a Boolean?

If I can find a usage of a function I can hover over it and hold Ctrl, but not so on the definition. If I hover and hold Shift it tells me it's a Function1 that extends Object (not very useful). Ideally I'd like just to hover the mouse over the function name to see the type like you get in Eclipse.

6 comments
Comment actions Permalink

Hi Rhys,

Try "View->Type Info" (default keyboard shortcut is Ctrl-Alt-Shift-T).

-tt

0
Comment actions Permalink

Another way to do it:
If you want to see return type of method, then possibly this method is too complex to left it without explicit return type. You can use Alt+Enter on method identifier and choose intention to add return type.

Best regards,
Alexander Podkhalyuzin.

0
Comment actions Permalink

If the cursor is on the function name you can just hit ctrl-q and you get the return type.

Thanks, Nick.

0
Comment actions Permalink

Thanks for suggestions.

Taras - this does the trick. But I have to click on the method identifier first and reposition the cursor. Then move the cursor back to the place where I was typing. It would be nice if just hovering and pressing Ctrl worked for method identifers as it dues for usages. (And even nicer if there were the option not to have to presss Ctrl!)

0
Comment actions Permalink

i would prefer an "explicit type view mode"
the first time i read code, i want to see the variable and return types - everywhere. once i know the types, i don't want to see them at all.
"soft type annotations" would do that, similar to "soft wraps" or ideas anonymous-class-as-closure-view. just render the type annotations even if they are not in the code, and the other way round.

0
Comment actions Permalink

Anyway such feature should be blazing fast to do it in editor. Otherwise we will have big problems with performance (actually we have them, so it would be worse). I mean it's unlikely that such feature can be implemented (same like I thought about explicit implicits in editor).
But it's possible to do in read-only mode (however I'm not sure about IDEA platform API for it, but I think it's possible) and maybe I'll do it (but not soon).

Best regards,
Alexander Podkhalyuzin.

0

Please sign in to leave a comment.