myPairs = values;
}
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
final PsiModifierList modifierList = myModifierListOwner.getModifierList();
LOG.assertTrue(modifierList != null);
if (modifierList.findAnnotation(myAnnotation) != null) {
return;
}
final PsiFile containingFile = myModifierListOwner.getContainingFile();
if (!CodeInsightUtilBase.preparePsiElementForWrite(containingFile)) {
return;
}
for (String fqn : getAnnotationsToRemove()) {
PsiAnnotation annotation = AnnotationUtil.findAnnotation(myModifierListOwner, fqn);
if (annotation != null) {
annotation.delete();
}
}
PsiAnnotation inserted = modifierList.addAnnotation(myAnnotation);
for (PsiNameValuePair pair : myPairs) {
inserted.setDeclaredAttributeValue(pair.getName(), pair.getValue());
}
JavaCodeStyleManager.getInstance(project).shortenClassReferences(inserted);
if (containingFile != file) {