Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off type hint in java stream sequences

When I have code in java that uses streams intellij displays type hints about the result of the stream.

I would like to disable these hints

Example with the following code:

Stream.of (1, 2. 3)
    .map (n -> n + 1)
    .map (n -> n % 2 == 0 ? "even number " + n : "odd number " + n)
    .peek (System.out:println)
    .map (s -> Float.parseFloat (s.substring (s.lastIndexOf (" "))))
    ;

enter image description here

I have turned off other tool tips for parameters, but the hints after the streams are still present. They are visually very distracting while providing me with little extra information.

I would also be happy if I knew how to change the color or style of the hints (I have Material Theme UI installed)

like image 636
MiniMe Avatar asked Aug 02 '19 07:08

MiniMe


2 Answers

IntelliJ 2019.2 CE

  1. Navigate to: Preferences -> Editor -> Inlay Hints -> Java. Alternatively, press CMD (⌘)/Ctrl + Shift + A, search for Inlay Hints, open the first result, and select Java.
  2. Untick Method Chains tickbox

enter image description here

Alternatively, you can increase the count of unique types in streams/method chains from which the type hints will be shown. I.e., if your stream transforms from type A to type B, and then to type C, this would be 3 types. If you set it to 2, hints would be shown for 3 unique types and more.

like image 111
cegas Avatar answered Oct 18 '22 15:10

cegas


An easier way!

Just right click on where it says (in your example) Stream<Integer> and untick the option Show method chain hints

enter image description here

Alternatively, hit CTRL+ALT+A and type "show me" - you can see the setting for "Show method chain hints"

enter image description here

like image 42
vikingsteve Avatar answered Oct 18 '22 14:10

vikingsteve