From 8c0e1d6b3d3ed6a8934b48c0481d79ef6785ecde Mon Sep 17 00:00:00 2001 From: Ryan Gustafson Date: Tue, 11 Mar 2008 01:21:10 +0000 Subject: [PATCH] Fix 1909929 - clean violation review is not selective enough git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@5888 51baf565-9d33-0410-a72c-fc3788e3496d --- .../net/sourceforge/pmd/ui/actions/ClearReviewsAction.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pmd-eclipse-plugin/pmd-eclipse-ui/src/net/sourceforge/pmd/ui/actions/ClearReviewsAction.java b/pmd-eclipse-plugin/pmd-eclipse-ui/src/net/sourceforge/pmd/ui/actions/ClearReviewsAction.java index e27227ae9d..80b50b7954 100644 --- a/pmd-eclipse-plugin/pmd-eclipse-ui/src/net/sourceforge/pmd/ui/actions/ClearReviewsAction.java +++ b/pmd-eclipse-plugin/pmd-eclipse-ui/src/net/sourceforge/pmd/ui/actions/ClearReviewsAction.java @@ -266,6 +266,10 @@ public class ClearReviewsAction implements IObjectActionDelegate, IResourceVisit * @return */ private String removeReviews(IFile file) { + String name = file.getName().toLowerCase(); + if (!(name.endsWith(".java") || name.endsWith(".jsp"))) { + return null; + } ByteArrayOutputStream baos = new ByteArrayOutputStream(); boolean noChange = true; try { @@ -277,6 +281,7 @@ public class ClearReviewsAction implements IObjectActionDelegate, IResourceVisit String origLine = reader.readLine(); String line = origLine.trim(); int index = origLine.indexOf(PMDRuntimeConstants.PMD_STYLE_REVIEW_COMMENT); + int quoteIndex = origLine.indexOf('"'); if (line.startsWith("/*")) { if (line.indexOf("*/") == -1) { @@ -288,7 +293,7 @@ public class ClearReviewsAction implements IObjectActionDelegate, IResourceVisit out.println(origLine); } else if (!comment && line.startsWith(PMDRuntimeConstants.PLUGIN_STYLE_REVIEW_COMMENT)) { noChange = false; - } else if (!comment && (index != -1)) { + } else if (!comment && (index != -1) && !(quoteIndex != -1 && quoteIndex < index && index < origLine.lastIndexOf('"'))) { noChange = false; out.println(origLine.substring(0, index)); } else {