@Override public void actionPerformed(AnActionEvent e) { final Project project = e.getProject(); assert project != null; final PsiAnnotation annotation = KotlinSignatureUtil.findKotlinSignatureAnnotation(annotationOwner); assert annotation != null; if (annotation.getContainingFile() != annotationOwner.getContainingFile()) { // external annotation new WriteCommandAction(project) { @Override protected void run(@NotNull Result result) throws Throwable { ExternalAnnotationsManager.getInstance(project) .deannotate(annotationOwner, KOTLIN_SIGNATURE.asString()); ExternalAnnotationsManager.getInstance(project) .deannotate(annotationOwner, OLD_KOTLIN_SIGNATURE.asString()); } }.execute(); } else { new WriteCommandAction(project) { @Override protected void run(@NotNull Result result) throws Throwable { annotation.delete(); } }.execute(); } KotlinSignatureUtil.refreshMarkers(project); }
public DeleteSignatureAction(@NotNull PsiModifierListOwner elementInEditor) { super("Delete"); this.annotationOwner = KotlinSignatureUtil.getAnnotationOwner(elementInEditor); getTemplatePresentation().setVisible(KotlinSignatureUtil.isAnnotationEditable(elementInEditor)); }