diff --git a/CHANGELOG.md b/CHANGELOG.md index 49a1271a..041d20f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # CheckStyle-IDEA Changelog +* **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. * **5.90.0** New: Added CheckStyle 10.15.0. diff --git a/build.gradle.kts b/build.gradle.kts index b7be8691..17fadd5d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ plugins { id("org.infernus.idea.checkstyle.build") } -version = "5.92.0" +version = "5.93.0" repositories { mavenCentral() @@ -48,6 +48,11 @@ java { } tasks { + // doesn't work, maybe waiting on https://github.com/JetBrains/intellij-platform-gradle-plugin/issues/1723 +// prepareSandbox { +// sandboxDirectory = intellijPlatform.sandboxContainer.dir("current") +// } + withType { dependsOn(copyClassesToSandbox, copyCheckstyleArtifactsToSandbox) } diff --git a/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/GradlePluginMain.java b/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/GradlePluginMain.java index 967802da..edcb08e6 100644 --- a/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/GradlePluginMain.java +++ b/buildSrc/src/main/java/org/infernus/idea/checkstyle/build/GradlePluginMain.java @@ -192,8 +192,8 @@ private void createCopyClassesToSandboxTask(final Project pProject, final boolea }); } - // TODO this will break when we change the base IDEA version; it should use SandboxAware or similar: https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-task-awares.html#SandboxAware private @NotNull String pluginSandboxDir(final boolean test, final String subDirectory) { + // must remain in sync with task configuration in Gradle file return "idea-sandbox/IC-2023.1.5/plugins" + (test ? "-test" : "") + "/CheckStyle-IDEA/" + subDirectory; diff --git a/src/main/java/org/infernus/idea/checkstyle/toolwindow/ResultTreeModel.java b/src/main/java/org/infernus/idea/checkstyle/toolwindow/ResultTreeModel.java index 9fc430c9..2cdbf91f 100644 --- a/src/main/java/org/infernus/idea/checkstyle/toolwindow/ResultTreeModel.java +++ b/src/main/java/org/infernus/idea/checkstyle/toolwindow/ResultTreeModel.java @@ -4,6 +4,7 @@ import java.util.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.MutableTreeNode; import javax.swing.tree.TreeNode; import com.intellij.psi.PsiFile; @@ -20,12 +21,12 @@ public class ResultTreeModel extends DefaultTreeModel { @Serial private static final long serialVersionUID = 2161855162879365203L; - private final DefaultMutableTreeNode visibleRootNode; + private final ToggleableTreeNode visibleRootNode; public ResultTreeModel() { super(new DefaultMutableTreeNode()); - visibleRootNode = new DefaultMutableTreeNode(); + visibleRootNode = new ToggleableTreeNode(); ((DefaultMutableTreeNode) getRoot()).add(visibleRootNode); setRootMessage(null); @@ -83,26 +84,31 @@ public void filter(final SeverityLevel... levels) { } private void filter(final boolean sendEvents, final SeverityLevel... levels) { - final Set changedNodes = new HashSet<>(); - - for (int fileIndex = 0; fileIndex < visibleRootNode.getChildCount(); ++fileIndex) { - final ToggleableTreeNode fileNode = (ToggleableTreeNode) visibleRootNode.getChildAt(fileIndex); + final Set changedNodes = new HashSet<>(); + for (final ToggleableTreeNode fileNode : visibleRootNode.getAllChildren()) { + boolean childChanged = false; for (final ToggleableTreeNode problemNode : fileNode.getAllChildren()) { final ResultTreeNode result = (ResultTreeNode) problemNode.getUserObject(); - final boolean currentVisible = problemNode.isVisible(); - final boolean desiredVisible = contains(levels, result.getSeverity()); - if (currentVisible != desiredVisible) { - problemNode.setVisible(desiredVisible); - - changedNodes.add(fileNode); + final boolean resultShouldBeVisible = contains(levels, result.getSeverity()); + if (problemNode.isVisible() != resultShouldBeVisible) { + problemNode.setVisible(resultShouldBeVisible); + childChanged = true; } } + + final boolean fileNodeShouldBeVisible = fileNode.getChildCount() > 0; + if (fileNode.isVisible() != fileNodeShouldBeVisible) { + fileNode.setVisible(fileNodeShouldBeVisible); + changedNodes.add(visibleRootNode); + } else if (childChanged) { + changedNodes.add(fileNode); + } } if (sendEvents) { - for (final ToggleableTreeNode node : changedNodes) { + for (final MutableTreeNode node : changedNodes) { nodeStructureChanged(node); } } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 5605819f..b3739b0e 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -18,6 +18,7 @@ +
  • 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.
  • 5.90.0: New: Added CheckStyle 10.15.0.