Skip to content

Commit e15df4f

Browse files
committed
Add rulename to marker message, which is shown as a tooltip.
Fixes #84
1 parent 32b591f commit e15df4f

File tree

2 files changed

+3
-1
lines changed
  • net.sourceforge.pmd.eclipse.plugin.test/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd
  • net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/runtime/cmd

2 files changed

+3
-1
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ public void testReviewCmdBasic() throws CoreException {
112112
Assert.assertEquals(markers.get(sourceFile).size(), imarkers.size());
113113
for (IMarker marker : imarkers) {
114114
Assert.assertTrue(marker.isSubtypeOf(IMarker.PROBLEM));
115+
Assert.assertTrue(marker.getAttribute(IMarker.MESSAGE, "")
116+
.startsWith(marker.getAttribute(PMDRuntimeConstants.KEY_MARKERATT_RULENAME, "missing rule name")));
115117
}
116118
}
117119

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ private MarkerInfo2 getMarkerInfo(RuleViolation violation, String type) throws P
629629

630630
MarkerInfo2 info = new MarkerInfo2(type, 7);
631631

632-
info.add(IMarker.MESSAGE, violation.getDescription());
632+
info.add(IMarker.MESSAGE, rule.getName() + ": " + violation.getDescription());
633633
info.add(IMarker.LINE_NUMBER, violation.getBeginLine());
634634
info.add(PMDRuntimeConstants.KEY_MARKERATT_LINE2, violation.getEndLine());
635635
info.add(PMDRuntimeConstants.KEY_MARKERATT_RULENAME, rule.getName());

0 commit comments

Comments
 (0)