Skip to content

Commit 39d8440

Browse files
committed
Merge branch 'pr-80'
2 parents 3299907 + 98e3d15 commit 39d8440

File tree

9 files changed

+278
-109
lines changed

9 files changed

+278
-109
lines changed

ReleaseNotes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ This is a minor release.
1414
### New and noteworthy
1515

1616
* The package `name.herlin` is deprecated and will be removed with the next major version of the plugin.
17+
* PMD markers are now problem markers again. This means, that rule violations appear in the Problem View.
18+
The project property "Handle high priority violations as Eclipse errors" now works again.
19+
* The PMD markers are now also visible on the overview ruler. They can be customized or disabled via
20+
workspace preferences, General, Editors, Text Editors, Annotations.
1721

1822
### Fixed Issues
1923

24+
* [#54](https://github.com/pmd/pmd-eclipse-plugin/issues/54): "violationsAsErrors" is completely ineffective
2025
* [#70](https://github.com/pmd/pmd-eclipse-plugin/issues/70): UnsupportedOperationException opening Rule Configuration
2126
* [#76](https://github.com/pmd/pmd-eclipse-plugin/issues/76): Global rule management is saved even if cancelled
2227
* [#78](https://github.com/pmd/pmd-eclipse-plugin/issues/78): Project properties cannot be loaded anymore
28+
* [#1359](https://sourceforge.net/p/pmd/bugs/1359/): PMD violations in eclipse should be shown on editor by scrollbar
2329

2430
### External Contributions
2531

net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/ReviewCmdTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
package net.sourceforge.pmd.eclipse.runtime.cmd;
66

77
import java.io.InputStream;
8+
import java.util.ArrayList;
9+
import java.util.Arrays;
10+
import java.util.List;
811
import java.util.Map;
912
import java.util.Set;
1013

1114
import org.eclipse.core.resources.IFile;
15+
import org.eclipse.core.resources.IMarker;
1216
import org.eclipse.core.resources.IProject;
1317
import org.eclipse.core.resources.IResource;
1418
import org.eclipse.core.resources.IncrementalProjectBuilder;
@@ -22,6 +26,7 @@
2226
import net.sourceforge.pmd.RuleSet;
2327
import net.sourceforge.pmd.eclipse.EclipseUtils;
2428
import net.sourceforge.pmd.eclipse.plugin.PMDPlugin;
29+
import net.sourceforge.pmd.eclipse.runtime.PMDRuntimeConstants;
2530
import net.sourceforge.pmd.eclipse.runtime.properties.IProjectProperties;
2631
import net.sourceforge.pmd.eclipse.ui.actions.RuleSetUtil;
2732

@@ -91,6 +96,17 @@ public void testReviewCmdBasic() throws CoreException {
9196
// We do not test PMD, only a non-empty report is enough
9297
Assert.assertNotNull(markers);
9398
Assert.assertTrue("Report size = " + markers.size(), markers.size() > 0);
99+
100+
// test the marker types - they should be problem markers...
101+
final IFile sourceFile = this.testProject.getFile("/src/Test.java");
102+
List<IMarker> imarkers = new ArrayList<>();
103+
for (String markerType : PMDRuntimeConstants.RULE_MARKER_TYPES) {
104+
imarkers.addAll(Arrays.asList(sourceFile.findMarkers(markerType, false, IResource.DEPTH_ONE)));
105+
}
106+
Assert.assertEquals(markers.get(sourceFile).size(), imarkers.size());
107+
for (IMarker marker : imarkers) {
108+
Assert.assertTrue(marker.isSubtypeOf(IMarker.PROBLEM));
109+
}
94110
}
95111

96112
/**

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ Require-Bundle: org.apache.commons.logging;bundle-version="1.0.4",
1616
org.eclipse.search,
1717
org.eclipse.help,
1818
org.eclipse.help.ui,
19-
org.eclipse.wst.xml.core
19+
org.eclipse.wst.xml.core,
20+
org.eclipse.ui.workbench.texteditor
2021
Bundle-ActivationPolicy: lazy
2122
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
2223
Bundle-Vendor: %plugin.provider

net.sourceforge.pmd.eclipse.plugin/plugin.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# PMD Eclipse Plugin externalized strings
22

3+
marker.category = PMD Markers
34
marker.pmd = PMD Marker
5+
marker.pmd.prio1 = PMD Marker (Prio 1)
6+
marker.pmd.prio2 = PMD Marker (Prio 2)
7+
marker.pmd.prio3 = PMD Marker (Prio 3)
8+
marker.pmd.prio4 = PMD Marker (Prio 4)
9+
marker.pmd.prio5 = PMD Marker (Prio 5)
410
marker.task = PMD Task Marker
511
marker.dfa = PMD DFA Marker
612

net.sourceforge.pmd.eclipse.plugin/plugin.xml

Lines changed: 190 additions & 76 deletions
Large diffs are not rendered by default.

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/plugin/PMDPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public static PMDPlugin getDefault() {
391391
* @return the image descriptor
392392
*/
393393
public static ImageDescriptor getImageDescriptor(String path) {
394-
return AbstractUIPlugin.imageDescriptorFromPlugin("net.sourceforge.pmd.eclipse.plugin", path);
394+
return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
395395
}
396396

397397
/**

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/PMDRuntimeConstants.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
*/
1616
public class PMDRuntimeConstants {
1717

18-
public static final String PMD_MARKER = PMDPlugin.PLUGIN_ID + ".pmdMarker"; // obsolete
18+
/** This marker type is the super type for all PMD markers (for rules, task, and dfa). */
19+
public static final String PMD_MARKER = PMDPlugin.PLUGIN_ID + ".pmdMarker";
1920

2021
public static final String PMD_MARKER_1 = PMDPlugin.PLUGIN_ID + ".pmdMarker1";
2122
public static final String PMD_MARKER_2 = PMDPlugin.PLUGIN_ID + ".pmdMarker2";
@@ -25,7 +26,7 @@ public class PMDRuntimeConstants {
2526

2627
public static final String PMD_DFA_MARKER = PMDPlugin.PLUGIN_ID + ".pmdDFAMarker";
2728
public static final String PMD_TASKMARKER = PMDPlugin.PLUGIN_ID + ".pmdTaskMarker";
28-
public static final String[] RULE_MARKER_TYPES = new String[] { PMD_MARKER, PMD_MARKER_1, PMD_MARKER_2,
29+
public static final String[] RULE_MARKER_TYPES = new String[] { PMD_MARKER_1, PMD_MARKER_2,
2930
PMD_MARKER_3, PMD_MARKER_4, PMD_MARKER_5 };
3031
public static final String[] ALL_MARKER_TYPES = new String[] { PMD_MARKER, PMD_DFA_MARKER, PMD_TASKMARKER,
3132
PMD_MARKER_1, PMD_MARKER_2, PMD_MARKER_3, PMD_MARKER_4, PMD_MARKER_5 };

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd/BaseVisitor.java

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -460,19 +460,16 @@ private int maxAllowableViolationsFor(Rule rule) {
460460
}
461461

462462
public static String markerTypeFor(RuleViolation violation) {
463-
464-
int priorityId = violation.getRule().getPriority().getPriority();
465-
466-
switch (priorityId) {
467-
case 1:
463+
switch (violation.getRule().getPriority()) {
464+
case HIGH:
468465
return PMDRuntimeConstants.PMD_MARKER_1;
469-
case 2:
466+
case MEDIUM_HIGH:
470467
return PMDRuntimeConstants.PMD_MARKER_2;
471-
case 3:
468+
case MEDIUM:
472469
return PMDRuntimeConstants.PMD_MARKER_3;
473-
case 4:
470+
case MEDIUM_LOW:
474471
return PMDRuntimeConstants.PMD_MARKER_4;
475-
case 5:
472+
case LOW:
476473
return PMDRuntimeConstants.PMD_MARKER_5;
477474
default:
478475
return PMDRuntimeConstants.PMD_MARKER;
@@ -625,35 +622,23 @@ private MarkerInfo2 getMarkerInfo(RuleViolation violation, String type) throws P
625622
info.add(PMDRuntimeConstants.KEY_MARKERATT_LINE2, violation.getEndLine());
626623
info.add(PMDRuntimeConstants.KEY_MARKERATT_RULENAME, rule.getName());
627624
info.add(PMDRuntimeConstants.KEY_MARKERATT_PRIORITY, rule.getPriority().getPriority());
625+
info.add(IMarker.PRIORITY, IMarker.PRIORITY_NORMAL);
628626

629-
switch (rule.getPriority().getPriority()) {
630-
case 1:
631-
info.add(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
627+
switch (rule.getPriority()) {
628+
case HIGH:
629+
case MEDIUM_HIGH:
632630
info.add(IMarker.SEVERITY,
633631
projectProperties.violationsAsErrors() ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING);
634632
break;
635-
case 2:
636-
if (projectProperties.violationsAsErrors()) {
637-
info.add(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
638-
} else {
639-
info.add(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
640-
info.add(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
641-
}
642-
break;
643633

644-
case 5:
645-
info.add(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
646-
break;
647-
648-
case 3:
649-
info.add(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
634+
case MEDIUM:
635+
case MEDIUM_LOW:
650636
info.add(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
651637
break;
652638

653-
case 4:
639+
case LOW:
654640
default:
655-
info.add(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
656-
info.add(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
641+
info.add(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
657642
break;
658643
}
659644

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
package net.sourceforge.pmd.eclipse.ui;
3+
4+
import org.eclipse.jface.resource.ImageDescriptor;
5+
import org.eclipse.jface.text.source.Annotation;
6+
import org.eclipse.swt.graphics.Image;
7+
import org.eclipse.ui.texteditor.IAnnotationImageProvider;
8+
9+
import net.sourceforge.pmd.eclipse.plugin.PMDPlugin;
10+
11+
public class PMDMarkerImageProvider implements IAnnotationImageProvider {
12+
13+
@Override
14+
public ImageDescriptor getImageDescriptor(String imageDescriptorId) {
15+
return null;
16+
}
17+
18+
@Override
19+
public String getImageDescriptorId(Annotation annotation) {
20+
return null;
21+
}
22+
23+
@Override
24+
public Image getManagedImage(Annotation annotation) {
25+
PMDPlugin plugin = PMDPlugin.getDefault();
26+
String type = annotation.getType();
27+
if ("net.sourceforge.pmd.eclipse.plugin.annotation.prio1".equals(type)) {
28+
return plugin.getImage(type, "icons/markerP1.png");
29+
} else if ("net.sourceforge.pmd.eclipse.plugin.annotation.prio2".equals(type)) {
30+
return plugin.getImage(type, "icons/markerP2.png");
31+
} else if ("net.sourceforge.pmd.eclipse.plugin.annotation.prio3".equals(type)) {
32+
return plugin.getImage(type, "icons/markerP3.png");
33+
} else if ("net.sourceforge.pmd.eclipse.plugin.annotation.prio4".equals(type)) {
34+
return plugin.getImage(type, "icons/markerP4.png");
35+
} else if ("net.sourceforge.pmd.eclipse.plugin.annotation.prio5".equals(type)) {
36+
return plugin.getImage(type, "icons/markerP5.png");
37+
}
38+
return null;
39+
}
40+
}

0 commit comments

Comments
 (0)