Skip to content

Commit

Permalink
Fix NPE when filtering tree results with no children
Browse files Browse the repository at this point in the history
  • Loading branch information
jshiell committed Aug 18, 2024
1 parent b9e8f5d commit 649932d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# CheckStyle-IDEA Changelog

* **5.93.1** Fixed: NPE when filtering tree results with no children.
* **5.93.0** New: Files in results are now hidden when all of their children aren't visible in the current filtering state (#644).
* **5.92.0** New: Added CheckStyle 10.17.0.
* **5.91.0** New: Added CheckStyle 10.16.0.
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
id("org.infernus.idea.checkstyle.build")
}

version = "5.93.0"
version = "5.93.1"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.infernus.idea.checkstyle.toolwindow;

import org.jetbrains.annotations.NotNull;

import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import java.io.Serial;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -30,14 +33,22 @@ public void setVisible(final boolean visible) {
this.visible = visible;
}

@NotNull
List<ToggleableTreeNode> getAllChildren() {
return children.stream()
.map(child -> (ToggleableTreeNode) child)
.collect(Collectors.toList());
if (children != null) {
return children.stream()
.map(child -> (ToggleableTreeNode) child)
.collect(Collectors.toList());
}
return Collections.emptyList();
}

@Override
public TreeNode getChildAt(final int index) {
if (children == null) {
throw new ArrayIndexOutOfBoundsException("Invalid index: " + index + " (no children)");
}

int realIndex = -1;
int visibleIndex = -1;

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<change-notes>
<![CDATA[
<ul>
<li>5.93.1: Fixed: NPE when filtering tree results with no children.</li>
<li>5.93.0: New: Files in results are now hidden when all of their children aren't visible in the current filtering state (#644).</li>
<li>5.92.0: New: Added CheckStyle 10.17.0.</li>
<li>5.91.0: New: Added CheckStyle 10.16.0.</li>
Expand Down

0 comments on commit 649932d

Please sign in to comment.