31

I been giving IntelliJ a spin, and loving it so far. But, I got a question, is there any way of quickly getting the fully qualified name of a class from within the editor?

So, if I have some code like

Element element = new Element();

I could quickly get the fully qualifed name of Element, for example, com.whatever.Element

2
  • 2
    Yes I have been looking for a shortcut for copy fully name of a class, including its package name, like "right click then Y" in eclipse. Sadly here seems no way to do this. Mar 7, 2017 at 8:15
  • @ShedomWei see the answer with most upvotes, it's there for at least 6 years...
    – Betlista
    Jan 21, 2020 at 21:12

3 Answers 3

51

Press Ctrl+Alt+Shift+C (Edit | Copy Reference) on "Editor" in the code and you'll have the fully-qualified name in your clipboard.

Or alternatively just right-click on the code and select "Copy Reference".

9
  • 1
    @Ray: in Eclipse you can always right click on the method or class and it will offer you an option to copy the fully qualified name.
    – Chris
    Apr 14, 2015 at 8:48
  • 2
    How can I get the dots instead of slash?
    – Hamedz
    Jan 31, 2018 at 22:43
  • 1
    On Ubuntu, these simply copy the name of the class for me, not the FQDN
    – Totem
    Nov 20, 2020 at 12:11
  • 2
    When people are talking about a fully qualified name, do they mean something likeVendor\Module\SomeClass? I am getting app/code/Vendor/Module/Model/GetObjByEntityId.php:13, which is not what I want, I want the former example Jan 12, 2021 at 11:14
  • 1
    Seriously in 2021 I don't want to be filling bugs to be able to easily get a class FQN instead of slashes Apr 1, 2021 at 14:34
25

Ctrl and hover (or and hover)

If I hold Ctrl and hover over the class name Element with my mouse, I get a popup with the following information (assuming Element extends AbstractElement and implements IElement):

[intellij-module-name] com.whatever
public class Element extends AbstractElement
implements IElement

The package name after the module name on the first line, plus the name of the class itself, would give you the fully-qualified name in your head. You can also Ctrl+Left Click on the Element class name to jump to its definition, where you could copy out the package declaration from the file if you need the actual text in the editor for whatever reason.

For macOS, hold while hovering mouse pointer.

2
  • 2
    If you Ctrl+Right click on the element and choose Copy Reference the fully qualified name will be copied to clipboard
    – NickSoft
    Aug 3, 2016 at 7:54
  • Too bad you can't copy from that popup. Also it inserts a space between package name and class name. Idea sucks so much :( Apr 1, 2021 at 14:34
11

Pressing Ctrl+Q when the cursor is inside the class name, will show you the class's package name and the Javadoc for that class. Esc will then close the window.

2
  • 1
    Cool shortcut, it keeps a dialog up instead of being an ephemeral popup too if you need it to stick around. Although it technically shows the package name, not the fully qualified name, but that's a minor detail.
    – ajp15243
    Aug 16, 2013 at 13:41
  • @ajp15243 You are right about the package name - I've edited my answer. Aug 16, 2013 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.