简体   繁体   English

IntelliJ 在鼠标悬停时显示 JavaDocs 工具提示

[英]IntelliJ show JavaDocs tooltip on mouse over

In Eclipse, when hovering over a method, variable, etc. a tooltip is displayed with the corresponding JavaDocs.在 Eclipse 中,将鼠标悬停在方法、变量等上时,会显示带有相应 JavaDocs 的工具提示。 Is there such a feature in IntelliJ? IntelliJ 有这样的功能吗?

For IntelliJ 13 , there is a checkbox in Editor's page in IDE Settings对于IntelliJ 13 ,在 IDE 设置的编辑器页面中有一个复选框

在此处输入图像描述

EDIT: For IntelliJ 14 , the option has been moved to Editor > General page.编辑:对于IntelliJ 14 ,该选项已移至 Editor > General 页面。 It's the last option in the "Other" group.这是“其他”组中的最后一个选项。 (For Mac the option is under the menu "IntelliJ Idea" > "Preferences"). (对于 Mac,该选项位于菜单“IntelliJ Idea”>“首选项”下)。

EDIT: For IntelliJ 16 , it's the second-to-last option in Editor > General > Other.编辑:对于IntelliJ 16 ,它是 Editor > General > Other 中的倒数第二个选项。

EDIT: For IntelliJ Ultimate 2016.1 , it's been moved to Editor > General > Code Completion.编辑:对于IntelliJ Ultimate 2016.1 ,它已移至 Editor > General > Code Completion。 在此处输入图像描述

EDIT: For IntelliJ Ultimate 2017.2, aka IntelliJ IDEA 2017.2.3 , there are actually two options:编辑:对于IntelliJ Ultimate 2017.2,又名 IntelliJ IDEA 2017.2.3 ,实际上有两个选项:

  1. In Editor > General > Other (section) > Show quick documentation on mouse move - delay 500 ms在 Editor > General > Other (section) > Show quick documentation on mouse move - delay 500 ms
  • Select this check box to show quick documentation for the symbol at caret. Select 此复选框可在插入符号处显示符号的快速文档。 The quick documentation pop-up window appears after the specified delay.在指定延迟后出现快速文档弹出 window。
  1. In Editor > General > Code Completion (sub-item) > Autopopup documention in 1000 ms, for explicitly invoked completion在 Editor > General > Code Completion (sub-item) > Autopopup documention in 1000 ms,显式调用完成
  • Select this check box to have IntelliJ IDEA automatically show a pop-up window with the documentation for the class, method, or field currently highlighted in the lookup list. Select 此复选框可让 IntelliJ IDEA 自动显示弹出窗口 window,其中包含 class、方法或当前在查找列表中突出显示的字段的文档。 If this check box is not selected, use Ctrl + Q to show quick documentation for the element at caret.如果未选中此复选框,请使用Ctrl + Q显示插入符号处元素的快速文档。
  • Quick documentation window will automatically pop up with the specified delay in those cases only, when code completion has been invoked explicitly.快速文档 window 仅在明确调用代码完成的情况下才会自动弹出指定延迟。 For the automatic code completion list, documentation window will only show up on pressing Ctrl + Q .对于自动代码完成列表,文档 window 只会在按下Ctrl + Q时显示。

EDIT : For IntelliJ Ultimate 2020.3 , the first option is now located under Editor > Code Editing > Quick Documentation > Show quick documentation on mouse move编辑:对于IntelliJ Ultimate 2020.3 ,第一个选项现在位于 Editor > Code Editing > Quick Documentation > Show quick documentation on mouse move

Up until IntelliJ version 11, no, not just by hovering over it.直到 IntelliJ 版本 11,不,不仅仅是通过将鼠标悬停在它上面。 If the cursor is inside the method- or attribute name, then CTRL + Q will show the JavaDoc on *nix and Windows.如果 cursor 在方法或属性名称中,则CTRL + Q将在 *nix 和 Windows 上显示 JavaDoc。 On MacOSX, this is CTRL + J .在 MacOSX 上,这是CTRL + J

Quote: "No, the only way to see the full javadoc is to use Quick Doc (Ctrl-Q)."引用: “不,查看完整 javadoc 的唯一方法是使用 Quick Doc (Ctrl-Q)。” -- http://devnet.jetbrains.net/thread/121174 -- http://devnet.jetbrains.net/thread/121174

EDIT编辑

Since IntelliJ 12.1, this is possible.从 IntelliJ 12.1 开始,这可能的。 See @ADNow's answer.请参阅@ADNow 的答案。

It is possible in 12.1.在 12.1 中是可能的。

Find idea.properties in the BIN folder inside of wherever your IDE is installed, eg C:\Program Files (x86)\JetBrains\IntelliJ\bin在安装 IDE 的任何位置的 BIN 文件夹中找到idea.properties ,例如 C:\Program Files (x86)\JetBrains\IntelliJ\bin

Add a new line to the end of that file:在该文件的末尾添加一个新行:

auto.show.quick.doc=true

Start IDEA and just hover your mouse over something:启动 IDEA,然后将鼠标悬停在 hover 上:

在此处输入图像描述

After doing CTRL + Q , you can完成CTRL + Q后,您可以

  1. Pin the tooltip (top right corner)固定工具提示(右上角)
  2. Check Docked Mode (under gear in top right after pinning)检查停靠模式(固定后右上角的齿轮下方)
  3. Size as desired根据需要大小
  4. Click icon for Auto show documentation for selected item单击所选项目的自动显示文档的图标

Then when you move your cursor, the documentation will appear in this box.然后,当您移动 cursor 时,文档将出现在此框中。 It costs you a little screen real estate, but I find it's worth it.它会花费你一点屏幕空间,但我觉得这是值得的。

I'd post a screenshot but SO won't let me post images.我会发布截图,但不会让我发布图片。

In Intellij13, you can use Editor configuration like below:在 Intellij13 中,您可以使用如下编辑器配置:在此处输入图像描述

For Intellij 15, use the checkbox in File > Settings > Editor > General option Show quick documentation on mouse move .对于 Intellij 15,使用File > Settings > Editor > General选项Show quick documentation on mouse move中的复选框。

在此处输入图像描述

You can also get there by typing "quick" or something similar in the search box:您也可以通过在搜索框中输入“快速”或类似内容来到达那里:

在此处输入图像描述

IntelliJ IDEA 14.0.3 Ultimate: IntelliJ IDEA 14.0.3 终极版:

Press Ctrl + Alt + S , then choose Editor\General choose Show quick domentation on mouse moveCtrl + Alt + S ,然后选择Editor\General选择Show quick domentation on mouse move

在此处输入图像描述

Tips: Look at the top right conner (gear icon) at JavaDoc pop-up window, You can choose:提示:查看JavaDoc弹出窗口window的右上角(齿轮图标),您可以选择:
- Show Toolbar - 显示工具栏
- Pinded Mode - 固定模式
- Docked Mode - 停靠模式
- Floatting Mode - 浮动模式
- Split Mode - 拆分模式

在此处输入图像描述

Adding on to what ADNow said.添加到 ADNow 所说的内容。 On the Macintosh:在 Macintosh 上:

  1. Right click on IntelliJ IDEA 12右键单击 IntelliJ IDEA 12
  2. Click on the Show Package Contents menu option单击显示 Package 内容菜单选项
  3. Open the bin folder打开bin文件夹
  4. Open idea.properties打开idea.properties
  5. Add the line:添加行:

    auto.show.quick.doc=true auto.show.quick.doc=true

The easiest way, at least for me, was:至少对我来说,最简单的方法是:

  • Ctrl + Shift + A Ctrl + Shift + A
  • Type: show document类型:显示文件
  • Show quick documentation on mouse move (set it to ON)显示鼠标移动的快速文档(将其设置为 ON)

From IntelliJ Ultimate 2018.1.5, aka IntelliJ IDEA 2018.1.5, till 2019.3 , there are actually two options under File -> Preferences:IntelliJ Ultimate 2018.1.5,又名 IntelliJ IDEA 2018.1.5,到 2019.3, File -> Preferences 下实际上有两个选项:

  1. In Editor > General > Other (section) > Show quick documentation on mouse move - delay 500 ms在 Editor > General > Other (section) > Show quick documentation on mouse move - delay 500 ms
    • Select this check box to show quick documentation for the symbol at caret. Select 此复选框可在插入符号处显示符号的快速文档。 The quick documentation pop-up window appears after the specified delay.在指定延迟后出现快速文档弹出 window。
  2. In Editor > General > Code Completion (sub-item) > Auto-display documentation in 1000 ms在 Editor > General > Code Completion (sub-item) > Auto-display documentation in 1000 ms
    • Select this check box to have IntelliJ IDEA automatically show a pop-up window with the documentation for the class, method, or field currently highlighted in the lookup list. Select 此复选框可让 IntelliJ IDEA 自动显示弹出窗口 window,其中包含 class、方法或当前在查找列表中突出显示的字段的文档。 If this check box is not selected, use Ctrl + Q to show quick documentation for the element at caret.如果未选中此复选框,请使用Ctrl + Q显示插入符号处元素的快速文档。
    • Quick documentation window will automatically pop up with the specified delay in those cases only, when code completion has been invoked explicitly.快速文档 window 仅在明确调用代码完成的情况下才会自动弹出指定延迟。 For the automatic code completion list, documentation window will only show up on pressing Ctrl + Q .对于自动代码完成列表,文档 window 只会在按下Ctrl + Q时显示。

In IntelliJ IDEA 14, it has moved to: File -> Settings -> Editor -> General -> "Show quick doc on mouse move"在 IntelliJ IDEA 14 中,它已移至:文件 -> 设置 -> 编辑器 -> 常规 -> “在鼠标移动时显示快速文档”

In Intellij 2019, I did: File > Settings > Editor > General option Show quick documentation on mouse move.在 Intellij 2019 中,我做了:文件 > 设置 > 编辑器 > 常规选项显示鼠标移动的快速文档。

File-->Settings-->Editor文件-->设置-->编辑器

Check " Show quick doc on mouse "勾选“在鼠标上显示快速文档

Now when you put the mouse over a method a tooltip with the documentation will appear.现在,当您将鼠标放在方法上时,将出现带有文档的工具提示。 Sometimes the tooltip size is too small and you will have to resize it moving the mouse down to the bottom of the tooltip.有时工具提示的大小太小,您必须将鼠标向下移动到工具提示的底部来调整它的大小。

IDEA has " find action ": IDEA 有“查找动作”:

Open "Help" menu, type "doc", move cursor to " Quick Documentation " it will be highlighted.打开“帮助”菜单,键入“doc”,将 cursor 移动到“快速文档”,它将突出显示。

Also "find action" can be called from hot key (you can find it in settings->hotkeys)也可以从热键调用“查找操作”(您可以在设置->热键中找到它)

On mac in IntelliJ Ultimate (trial) 14 I have mine under Settings > Editor > General > Code completion .在 IntelliJ Ultimate (trial) 14 的 mac 上,我在Settings > Editor > General > Code completion下有我的。 The tooltip short is F1 on my laptop.我的笔记本电脑上的工具提示短是 F1。

It's called "Autopopup documentation in (ms):"它被称为“(毫秒)中的自动弹出文档:”

在此处输入图像描述

A note for Android Studio (2.3.3 at least) users, because this page came up for my google search "android studio hover javadoc", and android studio is based on Intellij: Android Studio(至少 2.3.3)用户的注释,因为这个页面出现在我的谷歌搜索“android studio hover javadoc”中,android studio 是基于 Intel

See File->Settings->Editor->General: "show quick documentation on mouse moves", rather than File->Settings->Editor->General->Code Completion "Autopopup documentation in (ms) for explicitly invoked completion" and "Autopopup in (ms)", which has been previously talked about.请参阅 File->Settings->Editor->General:“显示鼠标移动的快速文档”,而不是 File->Settings->Editor->General->Code Completion “Autopopup documentation in (ms) for显式调用完成”和“Autopopup in (ms)”,之前已经讲过。

I tried many ways mentioned here, especially the preference - editor - general - code completion - show documentation popup in.. isn't working in version 2019.2.2我尝试了这里提到的许多方法,尤其是首选项 - 编辑器 - 常规 - 代码完成 - 显示文档弹出...在版本 2019.2.2中不起作用

Finally, i am just using F1 while caret is on the type/method and it displays the documentation nicely.最后,我只是在插入符号位于类型/方法上时使用F1 ,它很好地显示了文档。 This is not ideal but helpful.这并不理想但很有帮助。

In 2020.1 there is in editor javadocs rendering has been added.在 2020.1 中,编辑器中添加了 javadocs渲染。 Screen shots borrowed from intellij documentation.从 intellij 文档中借用的屏幕截图。

在此处输入图像描述

在此处输入图像描述 在此处输入图像描述

在此处输入图像描述

On my IntelliJ U on Mac I need to point with cursor on some method, variable etc. and press [cntrl] or [cmd] key.在 Mac 上的 IntelliJ U 上,我需要在某些方法、变量等上指向 cursor,然后按 [cntrl] 或 [cmd] 键。 Then click on the link inside popup window which appeared to see JavaDocs然后点击弹出窗口 window 里面的链接,它似乎看到了 JavaDocs

All of the above methods are useful but one basic thing missing you need to have src.zip in your JDK (C:\Program Files\Java\jdk1.8.0_171).上述所有方法都很有用,但缺少一个基本的东西,您需要在 JDK (C:\Program Files\Java\jdk1.8.0_171) 中有src.zip I assumed it comes preinstalled but for some reason, it was not present in my installation.我认为它是预先安装的,但由于某种原因,它在我的安装中不存在。 Another thing to check is if your project is using the specified (1.8.0_171 in this case) JDK.要检查的另一件事是您的项目是否使用指定的(在本例中为 1.8.0_171)JDK。

The answer is CTRL + P (NOT CTRL + Q )答案是CTRL + P (不是CTRL + Q

Someone else posted this answer on JetBrains forum: The idea is a different IDE.其他人在 JetBrains 论坛上发布了这个答案:想法是不同的 IDE。 Try to discover its features and try to make the best of it, rather than trying to emulate whatever you used before.尝试发现它的功能并尝试充分利用它,而不是试图模仿你以前使用的任何东西。 For the most part, Idea has very high usability (much better than Eclipse IMHO) and is streamlined for supporting code editing as best as possible (rather than relying on wizards too much for example).在大多数情况下,Idea 具有非常高的可用性(比 Eclipse 恕我直言要好得多),并且经过简化以尽可能最好地支持代码编辑(例如,而不是过度依赖向导)。

  • Javadoc: Ctrl - Q Javadoc: Ctrl - Q
  • A quick view of the implementation: Ctrl - Shift - I实现的快速视图: Ctrl - Shift - I
  • Show context: Alt - Q显示上下文: Alt - Q
  • Show parameters (in a method call): Ctrl - P显示参数(在方法调用中): Ctrl - P
  • Show error description.显示错误描述。 Ctrl - F1 Ctrl - F1

... plus many more shortcuts to navigate in code and different idea views. ...加上更多在代码和不同想法视图中导航的快捷方式。

I think it rather nice that you can see just the specific bit of information you are interested in with a simple keystroke.我认为通过简单的击键就可以看到您感兴趣的特定信息是相当不错的。 Have a look at the menus which will also show the possibly modified shortcuts for your keymap.查看菜单,其中还将显示您的键盘映射可能修改的快捷方式。

0 Avatar Jens Voß Created June 12, 2008, 09:26 And, elsandros, in addition to what Stephen writes: Since you seem to be interested in IDEA's keyboard shortcuts, I highly recommend the "Key Promoter" plugin which helps you memorize the relevant shortcuts quickly. 0 Avatar Jens Voß 创建于 2008 年 6 月 12 日 09:26 并且,elsandros,除了 Stephen 写的:由于您似乎对 IDEA 的键盘快捷键感兴趣,我强烈推荐“Key Promoter”插件,它可以帮助您记住相关的快捷方式。

Also very useful is the "Goto Action" feature, invoked by Ctrl - Shift - A .Ctrl - Shift - A调用的“Goto Action”功能也非常有用。 In the popup, you can enter a keyword (eg "Javadoc"), and the IDE tells you the available actions matching your search, along with keyboard shortcuts and the containing action groups (which often also give you a clue about how to navigate to the action using the menu).在弹出窗口中,您可以输入关键字(例如“Javadoc”),IDE 会告诉您与您的搜索相匹配的可用操作,以及键盘快捷键和包含的操作组(通常还会为您提供有关如何导航到使用菜单的操作)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM