mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
remove redundant suppressions: allow unrelated comment inside same noinspection comment
This commit is contained in:
+17
-2
@@ -113,14 +113,25 @@ public class RemoveSuppressWarningAction implements LocalQuickFix {
|
||||
}
|
||||
|
||||
private void removeFromComment(final PsiComment comment) throws IncorrectOperationException {
|
||||
String commentText = comment.getText();
|
||||
int secondCommentIdx = commentText.indexOf("//", 2);
|
||||
String suffix = "";
|
||||
if (secondCommentIdx > 0) {
|
||||
suffix = commentText.substring(secondCommentIdx);
|
||||
}
|
||||
String newText = removeFromElementText(comment);
|
||||
if (newText != null) {
|
||||
if (newText.isEmpty()) {
|
||||
comment.delete();
|
||||
if (suffix.isEmpty()) {
|
||||
comment.delete();
|
||||
}
|
||||
else {
|
||||
comment.replace(JavaPsiFacade.getElementFactory(comment.getProject()).createCommentFromText(suffix, comment));
|
||||
}
|
||||
}
|
||||
else {
|
||||
PsiComment newComment = JavaPsiFacade.getElementFactory(comment.getProject())
|
||||
.createCommentFromText("// " + SuppressionUtilCore.SUPPRESS_INSPECTIONS_TAG_NAME +" "+newText, comment);
|
||||
.createCommentFromText("// " + SuppressionUtilCore.SUPPRESS_INSPECTIONS_TAG_NAME +" "+newText + suffix, comment);
|
||||
comment.replace(newComment);
|
||||
}
|
||||
}
|
||||
@@ -147,6 +158,10 @@ public class RemoveSuppressWarningAction implements LocalQuickFix {
|
||||
text += StringUtil.trimStart(element.getText(), "//").trim();
|
||||
}
|
||||
text = StringUtil.trimStart(text, "@").trim();
|
||||
int secondCommentIdx = text.indexOf("//");
|
||||
if (secondCommentIdx > 0) {
|
||||
text = text.substring(0, secondCommentIdx);
|
||||
}
|
||||
text = StringUtil.trimStart(text, SuppressionUtilCore.SUPPRESS_INSPECTIONS_TAG_NAME).trim();
|
||||
List<String> ids = StringUtil.split(text, ",");
|
||||
int i = ArrayUtil.find(ids.toArray(), myID);
|
||||
|
||||
+2
-1
@@ -8,7 +8,8 @@ public class Test {
|
||||
}
|
||||
|
||||
void foo() {
|
||||
List<ArrayList<String>> list = foo(new ArrayList<String>());
|
||||
//comment1
|
||||
List<ArrayList<String>> list = foo(new ArrayList<String>());
|
||||
|
||||
//noinspection unchecked
|
||||
ArrayList<String> list = new ArrayList();
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ public class Test {
|
||||
}
|
||||
|
||||
void foo() {
|
||||
//noinspection unche<caret>cked
|
||||
//noinspection unche<caret>cked //comment1
|
||||
List<ArrayList<String>> list = foo(new ArrayList<String>());
|
||||
|
||||
//noinspection unchecked
|
||||
|
||||
Reference in New Issue
Block a user