Ivan
Ivan

Reputation: 64207

How to see an object's full type name in IntelliJ Idea?

For example, having the following code:

// This is hidden from my eyes
String str = "abc";

// I can see this
System.out.println(str);

i'd like to point to str in the last line and see that it's type is indeed java.lang.String (not just String). Where can I find this information (I am sure Idea knows it, as it can show the object's members correctly)?

Upvotes: 25

Views: 15345

Answers (7)

kladderradatsch
kladderradatsch

Reputation: 818

In intelliJ you can directly jump to the type/class by pressing the keys CTRL+SHIFT and clicking with the mouse on the variable. That has the same effect as if you would ordinarily click with the mouse on the type along with key CTRL.

Upvotes: 0

Andrew Mackenzie
Andrew Mackenzie

Reputation: 5737

In CLion variant you can see a variable's definition in a pop-up with Command + Shift + I (Command uppercase letter 'i') ("Inspect" in my head to help me remember it).

Upvotes: 0

unknownerror
unknownerror

Reputation: 2515

F1 key has worked for my Mac's community version: 2018.1.6

Upvotes: 1

LCE
LCE

Reputation: 934

If you place the caret inside the variable you want to identify and press

CTRL + SHIFT + P

a small popup will show the type like so:

enter image description here

If you place the caret inside an expression, Idea will first ask what part of the expression you want to identify.

Upvotes: 31

James Moore
James Moore

Reputation: 9027

The control-[hover over the identifier] thing works for Scala, but I don't use it very often. Most of the time I want to know the type of an expression, not just a symbol. [select an expression] followed by control-shift-P is the way to get that.

The command is called "expression type", so if those keyboard shortcuts aren't working for you, hit ⌘-shift-A and type in "expression type". It'll tell you your current shortcut for that command.

Closely related: I'll often tell Intellij to add type annotation to a binding. If your cursor is on fnord in a line like this:

var fnord = Monoid[Flurbish].sharky.shark.shark(!snowball)

Hit option-return, and one of the things you can do is add type annotation. If type annotation is already there, you can remove it, or if you've changed the type of the expression you can then have Intellij update the type annotation to the new one. (The command is called "Add type annotation to value definition")

Upvotes: 1

ziggystar
ziggystar

Reputation: 28670

[Ctrl]+[Alt]+T when the curser is inside the identifier. Also works for the return types of method invocations.

Upvotes: 0

Ricky Clarkson
Ricky Clarkson

Reputation: 2939

Hover the mouse over the identifier with the ctrl key held down, and you will see a tooltip containing the full type name.

Upvotes: 32

Related Questions