public class AddAnnotationPsiFix extends LocalQuickFixOnPsiElement
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
myAnnotation |
protected java.lang.String |
myText |
LOG, myEndElement, myStartElement
EMPTY_ARRAY
Constructor and Description |
---|
AddAnnotationPsiFix(java.lang.String fqn,
PsiModifierListOwner modifierListOwner,
PsiNameValuePair [] values,
java.lang.String... annotationsToRemove) |
Modifier and Type | Method and Description |
---|---|
static PsiAnnotation |
addPhysicalAnnotation(java.lang.String fqn,
PsiNameValuePair[] pairs,
PsiModifierList modifierList) |
static PsiAnnotation |
addPhysicalAnnotationTo(java.lang.String fqn,
PsiNameValuePair[] pairs,
PsiAnnotationOwner owner) |
static java.lang.String |
calcText(PsiModifierListOwner modifierListOwner,
java.lang.String annotation) |
static AddAnnotationPsiFix |
createAddNotNullFix(PsiModifierListOwner owner)
Creates a fix which will add default "NotNull" annotation to the given element.
|
static AddAnnotationPsiFix |
createAddNullableFix(PsiModifierListOwner owner)
Creates a fix which will add default "Nullable" annotation to the given element.
|
protected java.lang.String [] |
getAnnotationsToRemove() |
static PsiModifierListOwner |
getContainer(PsiFile file,
int offset) |
static PsiModifierListOwner |
getContainer(PsiFile file,
int offset,
boolean availableOnReference) |
java.lang.String |
getFamilyName() |
java.lang.String |
getText() |
void |
invoke(Project project,
PsiFile file,
PsiElement startElement,
PsiElement endElement) |
boolean |
isAvailable(Project project,
PsiFile file,
PsiElement startElement,
PsiElement endElement) |
static boolean |
isAvailable(PsiModifierListOwner modifierListOwner,
java.lang.String annotationFQN) |
static boolean |
isNullabilityAnnotationApplicable(PsiModifierListOwner owner) |
static void |
removePhysicalAnnotations(PsiModifierListOwner owner,
java.lang.String... fqns) |
boolean |
startInWriteAction()
Indicate whether this action should be invoked inside write action.
|
applyFix, applyFix, getEndElement, getName, getStartElement, isAvailable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getElementToMakeWritable
protected final java.lang.String myAnnotation
protected final java.lang.String myText
public AddAnnotationPsiFix(java.lang.String fqn, PsiModifierListOwner modifierListOwner, PsiNameValuePair [] values, java.lang.String... annotationsToRemove)
public static java.lang.String calcText(PsiModifierListOwner modifierListOwner, java.lang.String annotation)
public static PsiModifierListOwner getContainer(PsiFile file, int offset)
public static PsiModifierListOwner getContainer(PsiFile file, int offset, boolean availableOnReference)
public java.lang.String getText()
getText
in class LocalQuickFixOnPsiElement
public java.lang.String getFamilyName()
QuickFix.getName()
.public boolean isAvailable(Project project, PsiFile file, PsiElement startElement, PsiElement endElement)
isAvailable
in class LocalQuickFixOnPsiElement
public static boolean isAvailable(PsiModifierListOwner modifierListOwner, java.lang.String annotationFQN)
public boolean startInWriteAction()
WriteActionAware
false
if e.g. modal dialog is shown inside the action.
If false
is returned the action itself is responsible for starting write action
when needed, by calling Application.runWriteAction(Runnable)
.true
if the action requires a write action (default), false
otherwise.public void invoke(Project project, PsiFile file, PsiElement startElement, PsiElement endElement)
invoke
in class LocalQuickFixOnPsiElement
public static PsiAnnotation addPhysicalAnnotation(java.lang.String fqn, PsiNameValuePair[] pairs, PsiModifierList modifierList)
public static PsiAnnotation addPhysicalAnnotationTo(java.lang.String fqn, PsiNameValuePair[] pairs, PsiAnnotationOwner owner)
public static void removePhysicalAnnotations(PsiModifierListOwner owner, java.lang.String... fqns)
protected java.lang.String [] getAnnotationsToRemove()
public static boolean isNullabilityAnnotationApplicable(PsiModifierListOwner owner)
public static AddAnnotationPsiFix createAddNullableFix(PsiModifierListOwner owner)
owner
- an element to add the annotationpublic static AddAnnotationPsiFix createAddNotNullFix(PsiModifierListOwner owner)
owner
- an element to add the annotation