Can't fold comments in Eclipse 3.5.2 - java

Aren't i supposed to be able to do this? Folding is enabled in the Java preferences, but no +/- button appears next to comments. I can fold imports and classes and methods, but not comments. Also, checking the Comments box in "Initially fold these elements" does nothing.

It could be a side-effect of another option setting the code folding for a plugin you don't have.
See bug 153449 for an example (written at the time when Mylyn was called Mylar):
I can enable and disable folding, and I see my editor margin increase/decrease
in size providing a gutter for the code folding markers to appear in, but they
simply aren't there. Also, all of the menu options to expand all and collapse
all are there and enabled but they do nothing.
Actually, I just saw this in my exported preferences:
/instance/org.eclipse.jdt.ui/editor_folding_provider=org.eclipse.mylar.java.ui.editor.foldingprovider
And I don't have Mylar installed. I'm betting this is the problem. I'll try
to get rid of it and see what happens.

Related

disable Cannot Resolve Method highlighting in intellij

I'm using IDEA 13.1.4, and I'm making some calls to aspectj-woven ITD methods that intellij doesn't recognize but that compile and run just fine. My only problem is that I hate red squiggly lines, and because I have quite a few classes making these calls, I'm being bombarded with them.
I certainly don't want to disable all highlighting, but I am comfortable disabling it for all unresolvable method calls. However, I've gone through the inspections menu and cannot find an option to disable this particular warning. Is it there and I'm just not finding it?
The quickest way is to type Alt + Enter on one of your unused methods. An option like Safe delete ... should appear. Expand this menu item with the right arrow and select Edit inspection profile setting. This should directly show the inspection rule, which you can disable. This should be either Unused declaration or Unused symbol. After clicking on the inspection options more options for enabling/disabling appear on the right side of the dialog.

IntelliJ editor customisation: javadoc popup to behave like in NetBeans?

Yesterday I installed IntelliJ IDEA IDE and so far I like it (I used to use NetBeans which I like and Eclipse which I avoid).
When it comes to code editor I would like to change javadoc popup behavior in 2 ways:
I set javadoc popup to show after one second (Settings -> Editor -> Code completion -> Autopopup documentation in). However it only works when I press Ctrl + Space for code completion. When code completion pops up automatically javadoc window does not show. And I want it to. Simply, it is the same issue as the one addressed here: http://youtrack.jetbrains.com/issue/IDEABKL-6124
The javadoc popup window hides current line (it pops just over code completion window). It would be better if it popped over actual line (with caret) without hiding it.
Is there any plugin that allows such a customisation? Or any setting that I missed?
EDIT 1:
Here is the picture explaining situation 2:
As you can see because of javadoc popup I cannot see what I am currently writing - part of the word "System."
The problem with JavaDoc hiding the code is caused by the low horizontal resolution when the popup cannot fit on the right. Normally displays have enough horizontal pixels to fit it. In any case it's still a bug that can be fixed by displaying the popup above the current line of code.
I've submitted this bug to YouTrack, feel free to vote.

Can Eclipse's Java editor do soft line wrapping?

I like to use Eclipse's Java editor feature that allows the me to split the editor window into several panes so I can look at multiple files at once (See below). When I do this, the editors usually can't display the longest lines, and I have to use the horizontal scroll bar.
I don't want to reformat the source itself because the window widths change depending upon what I'm looking at. So what I'm looking for is a soft line wrap, like many editors support (See below). Can I do this in Eclipse?
Nope. Not that is hasn't been asked for.
There's a plugin but I've never used it.
This bug has been finally fixed in Eclipse 4.6 Neon:
https://www.eclipse.org/eclipse/news/4.6/platform.php#word-wrap
EDIT: Here's a screenshot of a Java editor with the feature active.
February 2014: the new repo de.cdhq.eclipse.wordwrap from Florian Weßling (ColdDevil) does provide good wrapping.
It just got updated to support Auto-Wrapping on Startup:
When it's activated in the preferences word wrap will be automatically enabled in all open editors when Eclipse is started.
See the project page:
It seems that this is not possible in Eclipse at this time; this feature has been requested and unimplemented since 2003 with 103 users on the CC list.
There is now a plugin allowing soft wrapping. It is experimental and will break the line numbering.
http://ahtik.com/blog/projects/eclipse-word-wrap/

How to make Eclipse align the ?: ternary operator?

I need the exact same effect as in this question but in Eclipse.
It should only do the alignment if I explcitly insert a new line before the ":" or if the second operand (the "true" expression) is too long.
Example:
a = cond ? "a veeeeeeeeeeeeeeeery loooooooooooooooooooooooooooong string"
: "";
// ^ put the colon here
This original answer was for Galileo which is well over a decade ago, so I'm updating it to be a little more current. Original answer remains below.
For Eclipse 2021-12 (under Window though I hope it would be the same across platforms):
Go into Project, Properties on the menu.
Under Java Code Style, choose Formatter.
For the current project only, enable project-specific settings. For workspace settings, simply click on the Configure workspace settings. Then click the edit button.
In the selection pane, under Line Wrapping, Wrapping settings, Other expressions, there is a Conditionals item that you can edit.
The options you want are:
wrap before operators;
wrap where necessary;
no force split; and
indent on column.
They give this as an example:
This is the dated answer for Galileo:
Go into Project, Properties.
Under Java Code Style, choose Formatter.
For the current project only, enable project-specific settings. For workspace settings, simply click on the Configure workspace settings. Then click the edit button.
On the line-wrapping tab, choose Expressions, Conditionals.
Choose the relevant line wrapping policy and indentation policy.
I have "wrap only when necessary" and "indent on column" which appears to be close to what you want.
If you're not running Galileo, other versions of Eclipse should at least be close to that process. If my settings aren't quite what you want, you may need to fiddle with them a bit, but that Formatter section is pretty well the entire exposed interface so, if it can't be done with that, it can't be done (short of writing your own plug-in or finding a more configurable third-party one).

IntelliJ show JavaDocs tooltip on mouse over

In Eclipse, when hovering over a method, variable, etc. a tooltip is displayed with the corresponding JavaDocs. Is there such a feature in IntelliJ?
For IntelliJ 13, there is a checkbox in Editor's page in IDE Settings
EDIT: For IntelliJ 14, the option has been moved to Editor > General page. It's the last option in the "Other" group. (For Mac the option is under the menu "IntelliJ Idea" > "Preferences").
EDIT: For IntelliJ 16, it's the second-to-last option in Editor > General > Other.
EDIT: For IntelliJ Ultimate 2016.1, it's been moved to Editor > General > Code Completion.
EDIT: For IntelliJ Ultimate 2017.2, aka IntelliJ IDEA 2017.2.3, there are actually two options:
In 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. The quick documentation pop-up window appears after the specified delay.
In Editor > General > Code Completion (sub-item) > Autopopup documention in 1000 ms, for explicitly invoked completion
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. If this check box is not selected, use Ctrl+Q to show quick documentation for the element at caret.
Quick documentation window will automatically pop up with the specified delay in those cases only, when code completion has been invoked explicitly. For the automatic code completion list, documentation window will only show up on pressing 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
Up until IntelliJ version 11, no, not just by hovering over it. If the cursor is inside the method- or attribute name, then CTRL+Q will show the JavaDoc on *nix and Windows. On MacOSX, this is CTRL+J.
Quote: "No, the only way to see the full javadoc is to use Quick Doc (Ctrl-Q)." -- http://devnet.jetbrains.net/thread/121174
EDIT
Since IntelliJ 12.1, this is possible. See #ADNow's answer.
It is possible in 12.1.
Find idea.properties in the BIN folder inside of wherever your IDE is installed, e.g. 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:
After doing CTRL+Q, you can
Pin the tooltip (top right corner)
Check Docked Mode (under gear in top right after pinning)
Size as desired
Click icon for Auto show documentation for selected item
Then when you move your cursor, the documentation will appear in this box. 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.
For Intellij 15, use the checkbox in File > Settings > Editor > General option Show quick documentation on mouse move.
You can also get there by typing "quick" or something similar in the search box:
In Intellij13, you can use Editor configuration like below:
IntelliJ IDEA 14.0.3 Ultimate: Press Ctrl+Alt+S, then choose Editor\General choose Show quick domentation on mouse move
Tips: Look at the top right conner (gear icon) at JavaDoc pop-up window, You can choose:
- Show Toolbar
- Pinded Mode
- Docked Mode
- Floatting Mode
- Split Mode
Adding on to what ADNow said. On the Macintosh:
Right click on IntelliJ IDEA 12
Click on the Show Package Contents menu option
Open the bin folder
Open idea.properties
Add the line:
auto.show.quick.doc=true
The easiest way, at least for me, was:
Ctrl+Shift+A
Type: show document
Show quick documentation on mouse move (set it to ON)
From IntelliJ Ultimate 2018.1.5, aka IntelliJ IDEA 2018.1.5, till 2019.3 , there are actually two options under File -> Preferences:
In 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. The quick documentation pop-up window appears after the specified delay.
In 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. If this check box is not selected, use Ctrl+Q to show quick documentation for the element at caret.
Quick documentation window will automatically pop up with the specified delay in those cases only, when code completion has been invoked explicitly. For the automatic code completion list, documentation window will only show up on pressing Ctrl+Q.
In IntelliJ IDEA 14, it has moved to: File -> Settings -> Editor -> General -> "Show quick doc on mouse move"
In Intellij 2019, I did: File > Settings > Editor > General option Show quick documentation on mouse move.
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":
Open "Help" menu, type "doc", move cursor to "Quick Documentation" it will be highlighted.
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. The tooltip short is F1 on my laptop.
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:
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.
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
Finally, i am just using F1 while caret is on the type/method and it displays the documentation nicely. This is not ideal but helpful.
In 2020.1 there is in editor javadocs rendering has been added. Screen shots borrowed from intellij documentation.
On my IntelliJ U on Mac I need to point with cursor on some method, variable etc. and press [cntrl] or [cmd] key. Then click on the link inside popup window which appeared to see 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). 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.
The answer is CTRL + P (NOT CTRL + Q)
Someone else posted this answer on JetBrains forum:
The idea is a different 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).
Javadoc: Ctrl-Q
A quick view of the implementation: Ctrl-Shift-I
Show context: Alt-Q
Show parameters (in a method call): Ctrl-P
Show error description. 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.
Also very useful is the "Goto Action" feature, invoked by Ctrl-Shift-A. In the popup, you can enter a keyword (e.g. "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).

Categories

Resources