Skip to content

Commit 4ee4a2e

Browse files
committed
Fixes #174: Load PMD predefined menu properly
1 parent 35cdfea commit 4ee4a2e

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# PMDPlugin Changelog
44

55
## [Unreleased]
6+
### Added
7+
- Update to PMD version 7.2.0
8+
- Fix issue with disabled PMD predefined rules menu
9+
610
## [2.0.0]
711
### Added
812
- Update to PMD version 7.1.0

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
33

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

6-
val pmdVersion = "7.1.0"
6+
val pmdVersion = "7.2.0"
77

88
plugins {
99
id("java")

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# pluginGroup = com.intellij.plugins.bodhi.pmd
55
pluginName = PMDPlugin
6-
pluginVersion = 2.0.0
6+
pluginVersion = 2.0.1
77

88
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
99
# for insight into build numbers and IntelliJ Platform versions.

src/main/java/com/intellij/plugins/bodhi/pmd/actions/PreDefinedMenuGroup.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.intellij.plugins.bodhi.pmd.PMDUtil;
1010
import org.jetbrains.annotations.Nullable;
1111

12+
import java.io.InputStream;
1213
import java.util.Properties;
1314

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

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

75+
private @Nullable InputStream getRuleResourceStream() {
76+
InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(RULESETS_PROPERTY_FILE);
77+
if (resourceAsStream == null) {
78+
return Thread.currentThread().getContextClassLoader().getResourceAsStream(RULESETS_PROPERTY_FILE);
79+
}
80+
return resourceAsStream;
81+
}
82+
7583
public AnAction[] getChildren(@Nullable AnActionEvent event) {
7684
return new AnAction[]{this.children};
7785
}

0 commit comments

Comments
 (0)