Skip to content

Commit

Permalink
Fixes #174: Load PMD predefined menu properly
Browse files Browse the repository at this point in the history
  • Loading branch information
amitdev committed Jun 2, 2024
1 parent 35cdfea commit 4ee4a2e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# PMDPlugin Changelog

## [Unreleased]
### Added
- Update to PMD version 7.2.0
- Fix issue with disabled PMD predefined rules menu

## [2.0.0]
### Added
- Update to PMD version 7.1.0
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

fun properties(key: String) = project.findProperty(key).toString()

val pmdVersion = "7.1.0"
val pmdVersion = "7.2.0"

plugins {
id("java")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# pluginGroup = com.intellij.plugins.bodhi.pmd
pluginName = PMDPlugin
pluginVersion = 2.0.0
pluginVersion = 2.0.1

# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
# for insight into build numbers and IntelliJ Platform versions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.intellij.plugins.bodhi.pmd.PMDUtil;
import org.jetbrains.annotations.Nullable;

import java.io.InputStream;
import java.util.Properties;

/**
Expand Down Expand Up @@ -45,7 +46,7 @@ public void actionPerformed(AnActionEvent e) {
Properties props = new Properties();
try {
//Load the property file which has all the rulesets.
props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(RULESETS_PROPERTY_FILE));
props.load(getRuleResourceStream());
String[] rulesetFilenames = props.getProperty(RULESETS_FILENAMES_KEY).split(PMDInvoker.RULE_DELIMITER);

//We have 'All' rules in addition to the rulesets
Expand All @@ -67,11 +68,18 @@ public void actionPerformed(AnActionEvent e) {
children.add(ruleAction);
}
} catch (Exception e) {
//Should not happen
//e.printStackTrace();
throw new RuntimeException(e);
}
}

private @Nullable InputStream getRuleResourceStream() {
InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(RULESETS_PROPERTY_FILE);
if (resourceAsStream == null) {
return Thread.currentThread().getContextClassLoader().getResourceAsStream(RULESETS_PROPERTY_FILE);
}
return resourceAsStream;
}

public AnAction[] getChildren(@Nullable AnActionEvent event) {
return new AnAction[]{this.children};
}
Expand Down

0 comments on commit 4ee4a2e

Please sign in to comment.