mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
fix remove redundant suppress from javadoc tag (IDEA-205073)
This commit is contained in:
@@ -140,14 +140,33 @@ public class RemoveSuppressWarningAction implements LocalQuickFix {
|
||||
private void removeFromJavaDoc(PsiDocComment docComment) throws IncorrectOperationException {
|
||||
PsiDocTag tag = docComment.findTagByName(SuppressionUtilCore.SUPPRESS_INSPECTIONS_TAG_NAME);
|
||||
if (tag == null) return;
|
||||
String newText = removeFromElementText(tag.getDataElements());
|
||||
if (newText != null && newText.isEmpty()) {
|
||||
tag.delete();
|
||||
String text = tag.getText();
|
||||
int i = text.indexOf(myID);
|
||||
if (i < 0) return;
|
||||
String noInspectionText = StringUtil.trimEnd(text.substring(0, i), " ");
|
||||
String nextText = StringUtil.trimStart(text.substring(i + myID.length()), " ");
|
||||
String nextTagText;
|
||||
|
||||
if (noInspectionText.endsWith(",")) {
|
||||
nextTagText = noInspectionText.substring(0, noInspectionText.length() - 1) + nextText;
|
||||
}
|
||||
else if (newText != null) {
|
||||
newText = "@" + SuppressionUtilCore.SUPPRESS_INSPECTIONS_TAG_NAME + " " + newText;
|
||||
PsiDocTag newTag = JavaPsiFacade.getElementFactory(tag.getProject()).createDocTagFromText(newText);
|
||||
tag.replace(newTag);
|
||||
else if (nextText.startsWith(",")) {
|
||||
nextTagText = noInspectionText + nextText.substring(1);
|
||||
}
|
||||
else {
|
||||
nextTagText = null;
|
||||
}
|
||||
|
||||
if (nextTagText != null) {
|
||||
tag.replace(JavaPsiFacade.getElementFactory(tag.getProject()).createDocTagFromText(nextTagText));
|
||||
}
|
||||
else {
|
||||
PsiElement[] descriptionElements =
|
||||
JavaPsiFacade.getElementFactory(tag.getProject()).createDocCommentFromText("/**" + nextText + "*/", tag).getDescriptionElements();
|
||||
if (descriptionElements.length > 0) {
|
||||
docComment.addRangeAfter(descriptionElements[0], descriptionElements[descriptionElements.length - 1], tag);
|
||||
}
|
||||
tag.delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// "Remove 'unchecked' suppression" "true"
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* unrelated text
|
||||
*/
|
||||
public class Test {
|
||||
@SafeVarargs
|
||||
static <T> List<T> foo(T... t){
|
||||
return null;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
List<ArrayList<String>> list = foo(new ArrayList<String>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// "Remove 'unchecked' suppression" "true"
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @noinspection a1, b2
|
||||
*/
|
||||
public class Test {
|
||||
@SafeVarargs
|
||||
static <T> List<T> foo(T... t){
|
||||
return null;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
List<ArrayList<String>> list = foo(new ArrayList<String>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// "Remove 'unchecked' suppression" "true"
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @noinspection unch<caret>ecked
|
||||
*
|
||||
* unrelated text
|
||||
*/
|
||||
public class Test {
|
||||
@SafeVarargs
|
||||
static <T> List<T> foo(T... t){
|
||||
return null;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
List<ArrayList<String>> list = foo(new ArrayList<String>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// "Remove 'unchecked' suppression" "true"
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @noinspection a1,unch<caret>ecked, b2
|
||||
*/
|
||||
public class Test {
|
||||
@SafeVarargs
|
||||
static <T> List<T> foo(T... t){
|
||||
return null;
|
||||
}
|
||||
|
||||
void foo() {
|
||||
List<ArrayList<String>> list = foo(new ArrayList<String>());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user