Simple Problem: Ever since I switched to Idea 10.5, it has this auto import feature enabled. For a Java developer, this is surely nice, but every time I type thing like var x: Float it automatically adds import java.lang.Float on the beginning of the file. Very often, it even adds imports I did not even want, from unknown packages deep in my jar jungle, and prefers Java over Scala packages.
Played around with the switches in Code completion tab, but it keeps on doing this. How can I get rid of this?
That is plugin bug. This should be fixed soon.
It's impossible to turn off in settings. Sorry for inconveniences.
In 2016.2.3 (Community Edition), this seems to have moved to the SBT pane:
Check "Code style" -> "Scala" -> "Imports" and "Editor" -> "Auto import" under Settings
On related note, to turn off auto import popup suggestion when the cursor is moved to line in intellij for mac:
Preferences -> Editor(Under IDE Settings) -> Auto Import -> Show Import Popup
Related
I just installed a new Eclipse version (2020-12 with Wild Web Dev), and now Java compilation errors, in addition to being highlighted, also show up as text in the source file. That makes the lines to jump around, and is pretty annoying. I cannot figure out how to switch that feature off in Preferences.
Thank you very much for help.
It turned out to be a Code Mining setting. This particular one is in General -> Editors -> Text Editors -> 'Show code minings for problem annotations.' Changing it to 'None' removed the problem.
We recently upgraded to JUnit 4.13 and my project was painted warning yellow because Assert.assertThat has now been deprecated in favour of MatcherAssert.assertThat.
Bulk changing my static imports is no big deal but I was hoping that going forward I could configure Eclipse to do the right thing in new code. But no matter what I do, the auto importer continues to pull in the deprecated Assert.assertThat instead of the MatcherAssert one.
Some things I've tried:
Add org.hamcrest.MatcherAssert.* to Preferences -> Java -> Editor -> Content Assist -> Favorites. Now I see MatcherAssert.assertThat as a quick fix suggestion when there is no import and I mouse over the code. But this doesn't affect the automatic imports at all.
Add org.junit.Assert.assertThat to Preferences -> Java -> Appearance -> Type Filters. (I've also tried org.junit.Assert.* and even org.junit.*) This seems to have no effect on static imports. I can see the setting taking effect on regular imports when I experimented with org.junit.* but nothing on static imports.
So no matter what I do, when I hit save without explicitly pulling in MatcherAssert.assertThat, the auto import pulls Assert.assertThat instead.
Do you know if there is some way around this?
A colleague of mine did some super sleuthing and discovered that as of Eclipse 2020-09, the Content Assist Favorites now influences automatic static imports:
Bug 283287 - [organize imports] Could use favorites for static imports
And since the Favorites configuration lets you specify specific class members, I was able to get around this problem by adding org.hamcrest.MatcherAssert.* and then changing my previous org.junit.Assert.* to a more specific set including all of the public members of that class except for assertThat.
In the end, I have something like this, which does the right thing both in the automatic imports and in the content assist quick-fix suggestions.
In my IntelliJ, auto import pop-up is not displaying although "show import pop-up" is ticked in the settings so I always have to manually type import java.util..... at the top.
I found some similar questions and tried out their solutions, but none of them worked.
I'm new to Java and started using IntelliJ just a week ago, but if I remember correctly the pop-up was displayed at first.
I didn't update any settings and have no clue how I can make it back.
Also, unlike many screenshots of other people's intelliJ, the color of code in my intelliJ are all white except for some keywords which are orange and string which is green.
Not sure if it has something to do with this issue tho.
Could anyone help me find out what could be a problem?
Please follow below instruction, by that you can fix your issues.
1) Go to setting and in the Settings/Preferences dialog (Ctrl+Alt+S), click Editor | General | Auto Import.
2) Select the Add unambiguous imports on the fly checkbox, and apply the changes.
3) After apply the changes , restart the Intellij idea.
It turned out "Power Save Mode" was on, which caused this problem.
I turned it on now and the issue was solved.
When I type the name of a class which will need to be imported, IntelliJ lovingly pops up with a list of suggestions. However, most of the time those suggestions are things I'd never want to import, especially by accident -- like java.awt.*.
Is there a way to prevent the packages I'll never import from appearing in the completion list?
I've scoured the options but I haven't found anything.
Depending on the IDEA version: Yes.
In 7.0.5 use menu File -> Settings choose Code Completion and then Exclude from Import and Completion and add the package or class that you don't want to have in your suggestions.
In version 8 and version 9 use menu File -> Settings type "Auto import" into the search box and use the Exclude from Import and Completion box there.
In version 9 you also have the option of adding Classes and Packages to the exclude-list directly from the import suggestions context-menu:
I'm not sure since when this feature exists. It certainly in the upcoming version 9.0:
When the import-popup shows you can navigate from there to two ignore-option. For example when you type List it could be 'ignore java.awt.List from auto-import' and 'ignore java.awt from auto import'
Or you can configure it in the settings: Editor->Auto-Import: There you can add and remove ignored packages and classes.
in IntelliJ version 13.* and 14.* to Excluding Classes from Auto-Import
Steps:
1) Open the Settings dialog box, and under the Editor node, click Auto-Import.
2) On the Editor | Auto-Import page, click +
3) In the dialog box that opens, type the name of the class or a whole package to be excluded [ in your case write java.awt.* ], and click OK.
Use + and - to manage the list of classes and packages that IntelliJ IDEA shouldn't place to the suggestion list.
4) Apply changes and close the Settings dialog.
For More information about Excluding Classes from Auto-Import See helping Doc for IntelliJ
I have to use both IDEs and I would like to use the Eclipse style of syntax highlighting in Netbeans. Does any one know how to import it (or change any configuration file)? I've already set Netbeans to use the Eclipse key bindings.
Is there any better way than manually changing the colors of every keyword for the Java editor?
Thanks,
Luís
You can change the style of syntax highlighting in NetBeans by going to Tools > Options and selecting the Fonts & Colors tab.
In order to import a syntax highlighting profile use the Import button from the above mentioned Options window.
A ready-to-use Eclipse-like syntax highlighting profile for NetBeans can be found here: https://github.com/Boris-de/eclipsecolors_for_netbeans/downloads.
In addition to what cristiantolnai said, for mac users, go to NetBeans -> Preferences -> Fonts & Colors and the import button on the bottom left.
As far as I know this is not possible yet. Both IDEs have different systems to store settings on global or project level. I know that there is a plugin that lets you import Ecplise projects into NetBeans.