Skip to content

Commit b7338af

Browse files
committed
Merge pull request #177 from adangel:export-pmd-api
Export PMD API #177
2 parents 7fbd14f + d6bb812 commit b7338af

File tree

4 files changed

+40
-68
lines changed

4 files changed

+40
-68
lines changed

ReleaseNotes.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,26 @@ This is a minor release.
1818
### Fixed Issues
1919

2020
* [#176](https://github.com/pmd/pmd-eclipse-plugin/pull/176): Update to pmd 7.0.0-rc2
21+
* [#177](https://github.com/pmd/pmd-eclipse-plugin/pull/177): Export PMD API
2122

2223
### API Changes
2324

25+
The following PMD packages from pmd-core are exported and can be used by other plugins:
26+
* net.sourceforge.pmd
27+
* net.sourceforge.pmd.cpd
28+
* net.sourceforge.pmd.cpd.renderer
29+
* net.sourceforge.pmd.lang
30+
* net.sourceforge.pmd.lang.ast
31+
* net.sourceforge.pmd.lang.document
32+
* net.sourceforge.pmd.lang.metrics
33+
* net.sourceforge.pmd.lang.rule
34+
* net.sourceforge.pmd.lang.rule.xpath
35+
* net.sourceforge.pmd.properties
36+
* net.sourceforge.pmd.properties.constraints
37+
* net.sourceforge.pmd.renderers
38+
* net.sourceforge.pmd.reporting
39+
* net.sourceforge.pmd.util
40+
2441
### External Contributions
2542

2643
## 10-April-2023: 7.0.0.v20230410-1321-rc1

net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/BasicPMDTest.java

Lines changed: 4 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55
package net.sourceforge.pmd.eclipse;
66

7-
import java.io.ByteArrayInputStream;
8-
import java.io.IOException;
9-
import java.io.InputStream;
10-
import java.nio.charset.StandardCharsets;
117
import java.util.Arrays;
128
import java.util.List;
139

@@ -20,41 +16,13 @@
2016
import net.sourceforge.pmd.RuleSet;
2117
import net.sourceforge.pmd.RuleSetLoader;
2218
import net.sourceforge.pmd.RuleViolation;
23-
import net.sourceforge.pmd.lang.LanguageRegistry;
24-
import net.sourceforge.pmd.lang.java.JavaLanguageModule;
25-
import net.sourceforge.pmd.util.datasource.DataSource;
2619

2720
/**
28-
* Test if PMD can be run correctly
21+
* Test if PMD can be run correctly.
2922
*
3023
* @author Philippe Herlin
31-
*
3224
*/
3325
public class BasicPMDTest {
34-
35-
static class StringDataSource implements DataSource {
36-
private final ByteArrayInputStream is;
37-
38-
StringDataSource(final String source) {
39-
this.is = new ByteArrayInputStream(source.getBytes(StandardCharsets.UTF_8));
40-
}
41-
42-
@Override
43-
public InputStream getInputStream() {
44-
return is;
45-
}
46-
47-
@Override
48-
public String getNiceFileName(final boolean shortNames, final String inputFileName) {
49-
return "somefile.txt";
50-
}
51-
52-
@Override
53-
public void close() throws IOException {
54-
// no-op
55-
}
56-
}
57-
5826
/**
5927
* Try to load all the plugin known rulesets.
6028
*
@@ -66,10 +34,8 @@ public void testDefaulltRuleSets() {
6634
Assert.assertFalse("No Rulesets found", standardRuleSets.isEmpty());
6735
}
6836

69-
private void runPmd(String javaVersion) {
37+
private void runPmd() {
7038
PMDConfiguration configuration = new PMDConfiguration();
71-
configuration.setDefaultLanguageVersion(
72-
LanguageRegistry.PMD.getLanguageById(JavaLanguageModule.TERSE_NAME).getVersion(javaVersion));
7339
configuration.setRuleSets(Arrays.asList("category/java/codestyle.xml/UnnecessaryReturn"));
7440
configuration.setIgnoreIncrementalAnalysis(true);
7541

@@ -93,25 +59,7 @@ private void runPmd(String javaVersion) {
9359
*
9460
*/
9561
@Test
96-
public void testRunPmdJdk13() {
97-
runPmd("1.3");
98-
}
99-
100-
/**
101-
* Let see with Java 1.4.
102-
*
103-
*/
104-
@Test
105-
public void testRunPmdJdk14() {
106-
runPmd("1.4");
107-
}
108-
109-
/**
110-
* Let see with Java 1.5.
111-
*
112-
*/
113-
@Test
114-
public void testRunPmdJdk15() {
115-
runPmd("1.5");
62+
public void testRunPmd() {
63+
runPmd();
11664
}
11765
}

net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/runtime/properties/ProjectPropertiesModelTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.junit.Test;
4040

4141
import net.sourceforge.pmd.Rule;
42+
import net.sourceforge.pmd.RuleContext;
4243
import net.sourceforge.pmd.RuleSet;
4344
import net.sourceforge.pmd.RuleSetLoadException;
4445
import net.sourceforge.pmd.RuleSetLoader;
@@ -49,7 +50,8 @@
4950
import net.sourceforge.pmd.eclipse.runtime.preferences.IPreferencesManager;
5051
import net.sourceforge.pmd.eclipse.ui.actions.RuleSetUtil;
5152
import net.sourceforge.pmd.lang.LanguageRegistry;
52-
import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
53+
import net.sourceforge.pmd.lang.ast.Node;
54+
import net.sourceforge.pmd.lang.rule.AbstractRule;
5355

5456
/**
5557
* Test the project properties model.
@@ -270,7 +272,7 @@ public void testProjectRuleSet2() throws PropertiesException, RuleSetLoadExcepti
270272
}
271273

272274
/**
273-
* When rules are added to the plugin preferences, these rules should also be added to the project
275+
* When rules are added to the plugin preferences, these rules should also be added to the project.
274276
*/
275277
@Test
276278
public void testProjectRuleSet3() throws PropertiesException, RuleSetLoadException, CoreException {
@@ -284,11 +286,16 @@ public void testProjectRuleSet3() throws PropertiesException, RuleSetLoadExcepti
284286
this.initialPluginRuleSet.getRules(), projectRuleSet.getRules());
285287

286288
// 2. add a rule to the plugin rule set
287-
final Rule myRule = new AbstractJavaRule() {
289+
final Rule myRule = new AbstractRule() {
288290
@Override
289291
public String getName() {
290292
return "MyRule";
291293
}
294+
295+
@Override
296+
public void apply(Node target, RuleContext ctx) {
297+
// do nothing
298+
}
292299
};
293300
myRule.setLanguage(LanguageRegistry.PMD.getLanguageById("java"));
294301

net.sourceforge.pmd.eclipse.plugin/META-INF/MANIFEST.MF

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ Bundle-ClassPath: .,
9090
Bundle-Localization: plugin
9191
Export-Package: ch.qos.logback.classic;x-friends:="net.sourceforge.pmd.eclipse.plugin.test",
9292
name.herlin.command,
93-
net.sourceforge.pmd;x-friends:="net.sourceforge.pmd.eclipse.plugin.test";
93+
net.sourceforge.pmd;
9494
uses:="net.sourceforge.pmd.lang,
9595
net.sourceforge.pmd.util.datasource,
9696
net.sourceforge.pmd.renderers,
9797
net.sourceforge.pmd.lang.rule.properties,
9898
net.sourceforge.pmd.lang.dfa.report",
99-
net.sourceforge.pmd.cpd;x-friends:="net.sourceforge.pmd.eclipse.plugin.test",
100-
net.sourceforge.pmd.cpd.renderer;x-friends:="net.sourceforge.pmd.eclipse.plugin.test",
99+
net.sourceforge.pmd.cpd,
100+
net.sourceforge.pmd.cpd.renderer,
101101
net.sourceforge.pmd.eclipse.core;uses:="net.sourceforge.pmd",
102102
net.sourceforge.pmd.eclipse.core.impl,
103103
net.sourceforge.pmd.eclipse.plugin;
@@ -170,15 +170,15 @@ Export-Package: ch.qos.logback.classic;x-friends:="net.sourceforge.pmd.eclipse.p
170170
org.eclipse.jface.viewers,
171171
org.eclipse.swt.widgets",
172172
net.sourceforge.pmd.eclipse.util.internal;x-friends:="net.sourceforge.pmd.eclipse.plugin.test",
173-
net.sourceforge.pmd.lang;x-friends:="net.sourceforge.pmd.eclipse.plugin.test",
173+
net.sourceforge.pmd.lang,
174+
net.sourceforge.pmd.lang.ast,
174175
net.sourceforge.pmd.lang.document,
175-
net.sourceforge.pmd.lang.java;x-friends:="net.sourceforge.pmd.eclipse.plugin.test",
176-
net.sourceforge.pmd.lang.java.rule;x-friends:="net.sourceforge.pmd.eclipse.plugin.test",
177-
net.sourceforge.pmd.lang.rule;x-friends:="net.sourceforge.pmd.eclipse.plugin.test",
176+
net.sourceforge.pmd.lang.metrics,
177+
net.sourceforge.pmd.lang.rule,
178178
net.sourceforge.pmd.lang.rule.xpath,
179179
net.sourceforge.pmd.properties,
180-
net.sourceforge.pmd.properties.builders,
180+
net.sourceforge.pmd.properties.constraints,
181181
net.sourceforge.pmd.renderers,
182+
net.sourceforge.pmd.reporting,
182183
net.sourceforge.pmd.util;uses:="net.sourceforge.pmd.lang.java.ast",
183-
net.sourceforge.pmd.util.datasource,
184184
org.slf4j;x-friends:="net.sourceforge.pmd.eclipse.plugin.test"

0 commit comments

Comments
 (0)