About Stream Debugger in IntelliJ IDEA plugin

Overview

There was a plug-in called Stream Debugger of IntelliJ IDEA that visualizes the data flow of Stream API, so I tried using it.

environment

reference

Java Stream Debugger

How to use

Set a breakpoint on the stream you want to debug and run it in debug mode.

s1.png

Click the "Trace Current Stream Chain" icon that has been added to the Debug panel.

s2.png

The Stream Trace screen will appear and you can check the data flow. (It may take some time to display depending on the amount of data etc.) There are two display modes, "Flat Mode" and "Split Mode", which can be switched with the button at the bottom of the screen. The figure below is "Flat Mode".

Sample code


List<String> colors = Arrays.asList(
    "pink", "red", "orange", "brown", "yellow", "green", "blue", "gray", "white", "black", "purple",
    "red", "white", "brown", "pink", "white", "orange", "yellow", "blue", "gray"
);

colors.stream()
    .peek(System.out::println)
    .distinct()
    .sorted(Comparator.comparing(String::length))
    .map(String::toUpperCase)
    .forEach(System.out::println);

As shown in this figure, you can check on the screen how the data is handled in the intermediate processing.

s3.png

Installation

Open Plugins and click the [Browse Repositories ...] button at the bottom of the screen.

p1.png

Enter "Stream Debugger" in the search field to narrow down the Plugin. Once you find the Stream Debugger, click the Install button to install it.

p2.png

After installation, restart.

Kotlin Sequence Debugger

A Kotlin extension for Java Stream Debugger plugin.

There is also a Kotlin extension plugin for Stream Debugger. The usage is the same, set a breakpoint in the Sequence you want to debug, run it in debug mode, and click the "Trace Current Stream Chain" icon in the Debug panel.

listOf(5, 5, 2, 1, 6, 4, 3, 2, 4, 3).asSequence()
    .filter { it % 2 == 0 }
    .distinct()
    .sorted()
    .forEach { println(it) }

st.png

Recommended Posts

About Stream Debugger in IntelliJ IDEA plugin
Write Processing in IntelliJ IDEA
Java + OpenCV 3.X in IntelliJ IDEA
I made a plugin for IntelliJ IDEA
Java --Introduce CheckStyle plugin to IntelliJ IDEA and reflect it in formatter
About the idea of anonymous classes in Java
Settings to display Japanese Javadoc in IntelliJ IDEA
IntelliJ IDEA settings
I tried installing the Docker Integration plugin in IntelliJ
About docker.credentials.errors.StoreErrorTraceback in wsl2
Build Jar files in plugin folder with one click in IntelliJ
Failed to launch checking at Kotlin Koans in IntelliJ IDEA
[Java] A story about IntelliJ IDEA teaching Map's putIfAbsent method