mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Add quick fix to remove duplicate annotation without parameters (IDEA-249508)
GitOrigin-RevId: fea7daeb0bb40724325182d6041a20aa141fbbf2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f0726e3181
commit
4b18db9bfb
+8
-2
@@ -1,8 +1,10 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInsight.intention.impl;
|
||||
|
||||
import com.intellij.codeInsight.intention.QuickFixFactory;
|
||||
import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.java.analysis.JavaAnalysisBundle;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
@@ -94,11 +96,15 @@ public final class CollapseAnnotationsFix extends LocalQuickFixAndIntentionActio
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CollapseAnnotationsFix from(PsiAnnotation annotation) {
|
||||
public static LocalQuickFixAndIntentionActionOnPsiElement from(PsiAnnotation annotation) {
|
||||
PsiAnnotationOwner owner = annotation.getOwner();
|
||||
String name = annotation.getQualifiedName();
|
||||
if (owner == null || name == null) return null;
|
||||
PsiNameValuePair[] attributes = annotation.getParameterList().getAttributes();
|
||||
if (owner == null || name == null || attributes.length != 1) return null;
|
||||
if (attributes.length == 0) {
|
||||
return QuickFixFactory.getInstance().createDeleteFix(annotation, JavaAnalysisBundle.message("intention.text.remove.annotation"));
|
||||
}
|
||||
if (attributes.length != 1) return null;
|
||||
PsiNameValuePair attribute = attributes[0];
|
||||
if (attribute.getValue() == null) return null;
|
||||
PsiMethod annoMethod = findAttributeMethod(attribute);
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// "Remove" "true"
|
||||
|
||||
@XYZ
|
||||
class X{}
|
||||
@interface XYZ {}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Remove" "true"
|
||||
|
||||
@X<caret>YZ
|
||||
@XYZ
|
||||
class X{}
|
||||
@interface XYZ {}
|
||||
Reference in New Issue
Block a user