How can I get Intellij to stop underlining my scala code? - scala

Basically, Intellij is making my code extremely hard to read by underlining lots of my code. It kind of makes a chess board on the left of my screen as well! =>
I have looked through the code editor settings but I can't find one under scala which controls these underlines. I am using the twilight theme but I have only just noticed the issue. Any ideas Intellij buffs?

IntelliJ 12:
Settings -> Editor -> Colors & Fonts -> Scala -> Implicit Conversions
Uncheck "Effects -> Underline"
IntellIJ 11 or Before:
Settings -> Code Style -> Scala -> Other -> Other settings -> Highlight methods added via implicit conversion.
However anyway it's usability problem of this feature. Something different should be done to highlight implicit conversion for such places.

The attributes used for different kinds of highlighting are configured under Settings | Editor | Colors & Fonts.

In Idea 12, it can be disabled at Settings | Editor | Colors&Fonts | Scala | Implicit conversion. I just unchecked Effects but it's also possible to choose something else than Underscore.
Hope that helps.

To disable underlining in JSP/HTML I usually click the little man in a hat in the bottom right corner and set highlighting levels to None:
I think it should be the same with Scala

Related

Android Studio/Intellij hard Wrap (Flutter?)

I dont understand how do I change this new line "line" and change the point where the IDE starts a new line when I press STRG+ALT+ENTER. I also tried "Code style -> General -> Hardwrap" but it dosent change anything!
I saw it depends on the Programming langurage I use.... Now I have really no idea how to change this
It can be configured in Settings | Editor | Code Style | Dart > Line length.

How to make Eclipse format according to template when typing

I'm using eclipse Version: 2019-09 R (4.13.0) on mac High Sierra.
I didn't like the default formatting. For example when I write a method, it puts a space before the brace like this myMethod() { instead of myMethod(){ which I prefer.
So I changed the formatting template in Preferences -> Java -> Code Style -> Formatter
Now when I do CMD+shift+F it formats it how I want without the whitespace.
However, it STILL adds the white space as I type in the method! I can't figure out how to stop it doing that. When I type CMD+shift+F it corrects it, so it knows what I want, but retains the old behaviour when I type. Please save my sanity!
(Yes I've tried restarting eclipse!)
Thanks!
In Preferences: Java > Editor > Typing in section Automatically insert at correct position uncheck the checkbox Braces.

How to specify indentations on multiline parameter lists in IntelliJ Scala?

This has been bothering me for a while, but I can't seem to figure out how to change this formatting. Let's take a case class as an example:
I prefer two tabs after a line-continuation; however, IntelliJ seems to force this style:
This behavior seems to be controlled by Preferences -> Editor -> Code Style -> Scala -> Other -> Alternate indentation for constructor args and parameter declarations, which specifies a minimum of 0 spaces, and that simply brings the arg list inline with the opening parentheses. This isn't a big deal by itself, but whenever I copy/paste blocks of code, it reformats everything and I have to go back and shift-tab ad nauseam. Is there a style field that I'm missing somewhere?
There's an Intellij only solution:
Under Wrapping and Braces, disable Method declaration parameters > Use normal indent for parameters.
Then, under Other, enable Alternate indentation for constructor args and parameter declarations and set to the number of spaces you want to indent from the declaration level (in your case 4).
You want "Align when multiline" checked in the code style settings
You can also look into scalari-form plugin. It gives you much more and IDE independent. You are particuliary interested in alignArguments=true and if I remember correctly defaults should make the indentation as you want.
*Note, that it formats code after some sbt task, for instance sbt test, not when you press Ctrl+Alt+L or similiar in IntelliJ

Is there a way to fold eclipse sub-blocks like an "if" statement?

Currently Eclipse only fold the java doc and at function level, but when reading long methods, there could be quite a lot of if/else etc, is there a way to fold them?
I found the Coffee-Bytes plugin. I downloaded it from this link and found this guide by the author, for using it.
You can find more details in these references:
What code folding plugins work on Eclipse 3.6?
How to use Coffee-Bytes code folding
in updated versions of Eclipse
Change folding preferences at:
Window -> Preferences -> C/C++ -> Editor -> Folding -> Enable folding of preprocessor branches (#if/#else)
Enable folding using ctrl + shift + /
No, in the Preferences Dialog (Menu Window/Prefernces): Java/Editor/Folding you may choose,
Comments
Head Comments
Inner Types
Members and Imports
if Enable Folding is checked.
If you wan't to do this because the blocks are so long that can't reconize the structure
you should consider to split if/else blocks into methods using Alt-Shift-M (Extract Method)
It appears Eclipse does not have built-in support for folding if/else statements but allows folding for other more complex cases like Anonymous inner classes. Try looking for plugins like this one (last modified 2007, try it if it supports your Eclipse version).
Ok, this is a little bit older, but maybe someone could find this useful:
In most cases you can surround the piece of code by an additional pair of scope brackets, and to remember what you folded you can add a line comment.
For example, if you want to collapse the following:
int SectionA_var1;
int SectionA_var2;
int SectionA_var3;
int SectionA_var4;
int SectionA_var5;
int SectionB_var1;
just add the brackets an the comment:
{ // SectionA
int SectionA_var1;
int SectionA_var2;
int SectionA_var3;
int SectionA_var4;
int SectionA_var5;
}
int SectionB_var1;
Then you get the (-) sign and you can collapse the whole section to this:
{ // SectionA[...]
int SectionB_var1;
No plugin necessary, and until now I had no situation where this gave me any downsides, except that you cannot use it on a top level declaration to collapse methods.
For now, there is built-in function.
Click "Window->Preferences->C/C++->Editor->Folding" and then enable appropriate option you want.
Apply, close and either refresh project or reopen eclipse.
As weird as it looks like, sounds like developers never thought about that. if you have a big if statement or any switch/loop ... just use notepad++ to be able to fold/unfold
For Python, i.e. Eclipse/PyDev, go to Windows > Preferences > PyDev > Editor > Code Folding and check all the boxes.
Fold java source code like "if else for" statement
install pluins com.cb.eclipse.folding
restart your Eclipse make sure the pluins enabled
Click "Window->Preferences->Java->Editor->Folding"
Select folding: select "Coffee Bytes Java Folding"
Switch to "User Defined Regions"
"Start Identifier" = { ; End Identifier = }
click "Apply and Close"
Reopen java source editor you will see "if" or "for" block is collapsable

Change Eclipse variable autohighlight color

I have customized my own colors in eclipse but cannot find where to change the auto highlight color when you click on a variable and it highlights all other uses. Has anyone done this before?
Preferences -> General -> Editors -> Text Editors -> Annotations -> Occurrences
How to change your various variable background-highlighting "occurrences" settings
For anyone who'd like a screenshot and more details:
Tested in Eclipse 2022-12 (4.26.0) on Ubuntu 22.04.
You may have various "Occurrences" settings to change. Each one causes variables of the same name from various language file types to be highlighted in different kinds of files. I have 5 or so "occurrences" settings in Window → Preferences → General → Editors → Text Editors → Annotations → in the “Annotation types” window:
Bash occurrences
C/C++ Occurrences
C/C++ Write Occurrences
Occurrences
Occurrences (LiClipse)
I have changed all 5 to the same custom color: #414104, which is a nice-looking brown which looks great for dark themes.
Here's a screenshot prior to changing that setting for "Occurrences (LiClipse)":
And here's the new color I set all 5 to: #414104:
References:
The accepted answer
I first wrote about this in my Eclipse setup instructions on a new Linux (or other OS) computer document, where I have documented this and a lot more.